Giter Site home page Giter Site logo

Comments (7)

BalusC avatar BalusC commented on May 23, 2024 1

I went for a different approach: https://balusc.omnifaces.org/2023/11/using-omnifaces-cdi-viewscoped-with.html

from joinfaces.

larsgrefer avatar larsgrefer commented on May 23, 2024

The first and most important step would be to implement the org.springframework.beans.factory.config.Scope interface in order to give Spring access to the OmniFaces ViewScope. Our Implementation for the "normal" ViewScope can be found here: https://github.com/joinfaces/joinfaces/blob/4.7.x/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/viewscope/ViewScope.java

After this, a bit of plumbing is needed to get it to work:

The new Scope Implementation needs to be registered with the Spring ApplicationContext. We do this here: https://github.com/joinfaces/joinfaces/blob/4.7.x/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/viewscope/ViewScopeAutoConfiguration.java

With these two steps, the new Scope could be used with the @org.springframework.context.annotation.Scope("omnifaces-view") annotation. (Or whatever name you have chosen for the scope)

In order to support @org.omnifaces.cdi.ViewScoped as marker-annotation as well, you can define a CustomScopeAnnotationConfigurer as we do here for the "normal" JSF Scope annotations: https://github.com/joinfaces/joinfaces/blob/4.7.x/joinfaces-autoconfigure/src/main/java/org/joinfaces/autoconfigure/scopemapping/JsfScopeAnnotationsAutoConfiguration.java
(This is a BeanFactoryPostProcessor which modifies the scope information in the BeanDefinitions if the bean class has a given annotation)

from joinfaces.

BalusC avatar BalusC commented on May 23, 2024

Thank you for the response. So in other words, the OmniFaces ViewScopeManager needs to be ported to Spring in its entirety, including the unload/destroy features?

from joinfaces.

JohannesProbst avatar JohannesProbst commented on May 23, 2024

@BalusC we tried your approach but the cdi-extension doesn't get our @Named annotated class - so weld doesn't found them in the first place?

Can you please have a look at our example project based on the joinfaces example project? Would be a great feature for joinfaces to deliver full omnifaces capabilities :)

Here the forked example: https://github.com/JohannesProbst/joinfaces-gradle-war-example

from joinfaces.

zeners avatar zeners commented on May 23, 2024

@JohannesProbst it's not working inside IntelliJ.

Building a .war file and run it alone works as expected.

from joinfaces.

zeners avatar zeners commented on May 23, 2024

the following org.jboss.weld.environment.deployment.discovery.BeanArchiveHandler service helped out:

@Priority(Integer.MAX_VALUE)
public class IntelliJFileSystemBeanArchivHandler extends FileSystemBeanArchiveHandler {
    @Override
    public BeanArchiveBuilder handle(String path) {
        final Path target;
        try {
            target = Path.of(path);
        } catch (Exception e) {
            return null;
        }
        return super.handle(target.getParent().resolve(Path.of("classes")).toString());
    }
}

from joinfaces.

JohannesProbst avatar JohannesProbst commented on May 23, 2024

@zeners Thx - you are right - it was the different places of binaries and resources while running it in intellij! Your ArchiveHandler helped.

from joinfaces.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.