-
1. Re: Correct annotation usage?
jee4hire Oct 31, 2011 12:57 PM (in response to jee4hire)Correction:
I removed the entries from faces-config.xml and was able to get the following working.
Am I causing any problems by using both @Named and @ManagedBean together?
PrimeFaces will not work with only @Named.@FacesConverter(
playerConverter
)
public class PlayerConverter implements Converter, Serializable {
...
}@SessionScoped
@Named
@ManagedBean
public class AutoCompleteBean implements Serializable {
...
} -
2. Re: Correct annotation usage?
jee4hire Oct 31, 2011 12:58 PM (in response to jee4hire)Does @Named have a bug?
What is the difference between @Named and @ManagedBean? -
3. Re: Correct annotation usage?
piklos Oct 31, 2011 6:18 PM (in response to jee4hire)No @Named does not have a bug. You shouldn't mix the two. It is enough to declare it as @Named, it will automatically be visible to JSF.
I guess that it doesn't work because you use the wrong @SessionScoped.
Are you usingjavax.faces.bean.SessionScoped
or
javax.enterprise.context.SessionScoped
?
-
4. Re: Correct annotation usage?
lightguard Nov 1, 2011 12:22 AM (in response to jee4hire)This is yet another instance of JSF missing the bandwagon for things, and of course because it's in the spec it probably won't ever go away. They may be deprecated in a newer spec, but they won't ever go away :( The argument was using plain JSF w/o CDI (i.e. in a servlet container). We'd like to see the Servlet container idea become an actual EE profile which would be even slimmer than the current Web Profile and would also contain CDI 1.1. No idea if this will happen or not though.
-
5. Re: Correct annotation usage?
ratking Nov 1, 2011 6:25 AM (in response to jee4hire)I do the following, and it work well.
1. create a new file WEB-INF/beans.xml
2. copy the following jars(http://in.relation.to/Bloggers/Seam31Beta4Released) into WEB-INF/lib
seam-faces.jar seam-faces-api.jar seam-international.jar seam-international-api.jar seam-persistence.jar seam-persistence-api.jar seam-security.jar seam-security-api.jar seam-transaction.jar seam-transaction-api.jar solder-api.jar solder-impl.jar solder-logging.jar
3. modify PlayerConverter.java
import javax.enterprise.context.RequestScoped; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; @RequestScoped @FacesConverter("player") public class PlayerConverter implements Converter { //... }
4. modify AutoCompleteBean.java
import javax.enterprise.context.RequestScoped; import javax.inject.Named; @Named @RequestScoped public class AutoCompleteBean { // ... }
5. remove the following lines from faces-config.xml:
<converter> <converter-id>playerConverter</converter-id> <converter-class>org.jboss.seam.examples.booking.PlayerConverter</converter-class> </converter> <managed-bean> <managed-bean-name>autoCompleteBean</managed-bean-name> <managed-bean-class>org.jboss.seam.examples.booking.AutoCompleteBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean>
6. compile and delpoy the war in GlassFish 3.1.2(http://dlc.sun.com.edgesuite.net/glassfish/3.1.2/promoted/) (or JBoss7)
7. browse http://localhost:8080/prime-showcase
-
6. Re: Correct annotation usage?
ratking Nov 1, 2011 6:33 AM (in response to jee4hire)In my case, the converter id is player(@FacesConverter("player"))(is not playerConverter).
So, my selectOneMenu.xhtml is:<p:selectOneMenu value="#{autoCompleteBean.selectedPlayer1}" effect="fade" *converter="player"*> <f:selectItem itemLabel="Select One" itemValue="" /> <f:selectItems value="#{autoCompleteBean.players}" var="player" itemLabel="#{player.name}" itemValue="#{player}"/> </p:selectOneMenu>
-
7. Re: Correct annotation usage?
jee4hire Nov 1, 2011 11:26 AM (in response to jee4hire)No, I am using the endorsed:
javax.enterprise.context.SessionScoped
-
8. Re: Correct annotation usage?
jee4hire Nov 1, 2011 11:54 AM (in response to jee4hire)Why do you prefer n GlassFish 3.1.2 over JBoss?
-
9. Re: Correct annotation usage?
hantsy Nov 1, 2011 12:07 PM (in response to jee4hire)Currently, I encountered several problems when using Seam3, such as the Ajax problem(the ajax only works with JSF reference impl 2.0.2) and the frequent StateHolder exception(If I used JBoss 7.0.2, the JSF reference impl was updated to 2.1.3 FCS, Richfaces components will throw such an exception frequently and did not work) ...I do not know if they are caused by the incompatibility between JSF scope and CDI scope, I always used CDI scopes in my applications.
Seam 2 filled the gap between JSF1.2 and EJB, why Seam 3 did not fill the gap between JSF and CDI?
-
10. Re: Correct annotation usage?
lightguard Nov 1, 2011 5:18 PM (in response to jee4hire)Seam 3 is more about extending Java EE than filling gaps. And actually Seam 2 became much more than filling the EJB / JSF gap as well.
The problems you're encountering are JSF problems, they're not Seam problems. If you look at the history of Mojarra 2.x you'll see a big list of incompatibilities and breakage wrt component libraries, CDI integration, composite components, etc. It's not our fault it was broken when it shipped and people coded to the breakage, then when they went and fixed things up right it broke those things that were coded to the breakage.
I've said it before, JSF 2.0, especially Mojarra, was pushed out the door way too early both at a spec level and implementation level, it's not really up to us to fix their bugs.
-
11. Re: Correct annotation usage?
lightguard Nov 1, 2011 5:20 PM (in response to jee4hire)
JEE 4 Hire wrote on Nov 01, 2011 11:54:
Why do you prefer n GlassFish 3.1.2 over JBoss?Glassfish 3.1.2 still contains a number of unpatched CDI integration incompatibilities which were there in 3.1.1. I believe they're all mentioned on the compatibility page.
-
12. Re: Correct annotation usage?
hantsy Nov 1, 2011 10:06 PM (in response to jee4hire)
Jason Porter wrote on Nov 01, 2011 17:18:
Seam 3 is more about extending Java EE than filling gaps. And actually Seam 2 became much more than filling the EJB / JSF gap as well.
The problems you're encountering are JSF problems, they're not Seam problems. If you look at the history of Mojarra 2.x you'll see a big list of incompatibilities and breakage wrt component libraries, CDI integration, composite components, etc. It's not our fault it was broken when it shipped and people coded to the breakage, then when they went and fixed things up right it broke those things that were coded to the breakage.
I've said it before, JSF 2.0, especially Mojarra, was pushed out the door way too early both at a spec level and implementation level, it's not really up to us to fix their bugs.So what I can do currently? wait for the next generation JSF 2.2 and CDI 1.1?
I am confused that JSF2.x(now JSF 2 was updated to 2.1) and CDI(it was released the 4th service pack) are parts of JEE6, why so much problems when using them together.
JEE6 was released two years, and the two specs are also updated in these two years, why the experts did not seat side by side to fix the incompatibilities.
-
13. Re: Correct annotation usage?
lightguard Nov 2, 2011 12:17 AM (in response to jee4hire)You could try using MyFaces. Short of that, yes wait.
I don't know all the reasons why things happened the way they did. People have some speculations, but that's just their own opinions. The facts are this: JSF 2.0 was one of the first specs included in Java EE 6. CDI was the last one completed. Because of that the integration isn't there. Ed Burns is working diligently to get JSF to have tighter CDI integration for the next version of JSF. Also he's planning on putting some of the ideas of Seam and also CODI into the core of JSF.
As for JSF being at 2.1, the 2.1 is a maintenance release of the specification. Because of the rules of the JCP a new feature such as CDI integration cannot be done in a maintenance release.
-
14. Re: Correct annotation usage?
hantsy Nov 22, 2011 8:19 AM (in response to jee4hire)
Jason Porter wrote on Nov 02, 2011 00:17:
You could try using MyFaces.But how to use MyFaces in JBoss 7, there is no guide for this.
I tried to added a myfaces api and impl modules in JBoss 7 modules folder, but it does not work.