Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDI portable extension for @ViewScoped #1087

Closed
eclipse-faces-bot opened this issue Apr 3, 2012 · 16 comments
Closed

CDI portable extension for @ViewScoped #1087

eclipse-faces-bot opened this issue Apr 3, 2012 · 16 comments

Comments

@eclipse-faces-bot
Copy link

For JSF 2.2, it has been announced that the javax.faces.bean package may possible be deprecated in a future version. Advise is being given to use annotations from other appropriate Java EE specifications where possible (see #976).

In practice this mostly boils down to using CDI managed beans.

While those beans are a near drop-in replacement for JSF's native managed beans, one important feature is missing for them: the view scope (@ViewScoped).

This scope is not that hard to add, as shown in Steven Verborgh's article Porting the ViewScoped JSF annotation to CDI and the availability of this annotation in e.g. Seam 3.

Since the new @FlowScoped annotation requires a JSF implementation to provide a portable CDI extension that implements this scope (see #730), I wonder if we can ask the same for @ViewScoped?

Affected Versions

[2.2]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by @arjantijms

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
depends on
JAVASERVERFACES_SPEC_PUBLIC-1034
JAVASERVERFACES-2620
blocks
JAVASERVERFACES-2506

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
gerhard_petracek said:
most implementations don't work in some cases.

if< needed please check:
https://svn.apache.org/repos/asf/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/view/

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@arjantijms said:

most implementations don't work in some cases.

Any pointers to that?

If JSF native managed beans are ever to be deprecated these problems should of course be fixed. Possibly #787 makes this job easier.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
gerhard_petracek said:
the implementation in myfaces codi supports client side state saving, destroys beans correctly (SystemEventListener for PreDestroyViewMapEvent),...
you can compare the implementations for further details.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
ova2 said:
+1. Must to have feature!

Currently I have headache with CODI mapping / porting of JSF @ViewScope to CDI (see Gerhard's link). This is quite good with OWB, but not with Weld. @Inject in a base class doesn't work in JBoss 7 if the derived class has JSF @ViewScope. It works if it has CODI's @ViewAccessScope. But not with @ViewScope. Example:

public abstract class A implement Serializable {
    @Inject private SomeSessionScopedBean bean;

    public SomeSessionScopedBean getBean() {
        return bean;
    }  
}

@Named
@ViewScope
public class B extends A {
    public void doSomething() {
        getBean().someMethod();   // NullPointerException here because bean was not injected
    } 
}

It works with OWB as I said. And it works in Weld too if I move @Inject ... to the class B. Sorry for off-topic, but I think this is because Weld doesn't know about mapping of ViewScope.class, there isn't a SPI Extension in META-INF/services (no new annotation). Right? Sorry again.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@arjantijms said:
For the ones monitoring this issue; the SVN commit against this issue is only the new annotation. The actual implementation of the scope is tracked here: JAVASERVERFACES-2506

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Manfred suggested:

1. move javax.faces.flow.ViewScoped to javax.faces.view.ViewScoped.

2. Rename implicit object to be "flowScope" instead of "facesFlowScope".

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Modify the javadoc for javax.faces.bean.ViewScoped and javax.faces.view.ViewScoped to explicitly require that UIViewRoot.getViewMap() is used to store the beans.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Modify the spec for Scoped Attribute ELResolver (table 5-14) so that it requires checking the view map after the request and before the session.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Modify the spec for UIViewRoot.getViewMap(boolean) to explicitly state that the map is backed by the session. And that passing true will cause a new session to be created if one does not exist already.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Wednesday, December 12th 2012, 2:50:29 pm

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@manfredriem said:
Closing resolved issue out

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1087

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant