File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Simple Example for Enums and selectOneRadio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Simple Example for Enums and selectOneRadio" Watch "Simple Example for Enums and selectOneRadio" New topic
Author

Simple Example for Enums and selectOneRadio

Don Esteban Cerrojo
Greenhorn

Joined: Jan 21, 2011
Posts: 4
Hi to everybody,

I'm new in this forum and new to JSF. I have some experience in Java, JSP/Servlets but not very deep. My current environment is Eclipse Helios, Tomcat 7 and MyFaces 2. It took me a while arriving where I'm now . Before I had a look at Wicket and Google GWT/GAE. Hopefully I'll manage my project with the currently selected environment and technologies.

Until today, I made quite a bit of my road, but now I'm complete stuck with a very simple pattern. Using Enums in selectOneRadio. I can not even get a simple case working. Really frustrating. This I have done until now:







Navigating to the test page throws a NullpointerException. I would appreciate a lot, if someone could correct/complete my example or present a working example at the same basic beginner level as I tried to figure out. Thanks a lot!

SCHWERWIEGEND: Error Rendering View[/intranet/test-my-enum.xhtml]
java.lang.NullPointerException
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.renderGroupOrItemRadio(HtmlRadioRendererBase.java:213)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:118)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
21.01.2011 19:53:13 org.apache.myfaces.renderkit.ErrorPageWriter handleThrowable
SCHWERWIEGEND: An exception occurred
javax.faces.FacesException: java.lang.NullPointerException
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.renderGroupOrItemRadio(HtmlRadioRendererBase.java:213)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:118)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
... 16 more


Thank You, regards
Don Esteban
Don Esteban Cerrojo
Greenhorn

Joined: Jan 21, 2011
Posts: 4
The problem described is partially resolved now. I changed Apache MyFaces against Oracles Mojarra impementation of JSF 2.0. Further I had to change the the lines

to

To make things clear. This working version with strings as itemValue properties was my first, intuitive approach to the the use of selectOneRadio components. It raised some EnumConverterException. Don't remember the exceptions name exactly. Anyhow it seems like an issue with Apache MyFaces. Strange that I didn't find anything by searching the Web.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Example for Enums and selectOneRadio