specific @SelectItem Question -
mrohad Aug 13, 2006 3:07 AMplease help me with this issue , I tried to fix it in the last 4 days with no success
I'm using the SelectItems DataBinder and it doesn't work
I am getting this Exception , please tell me what do I do wrong
the only differences betwen my EAR and the example EAR file of seam-selectitems that do work for me is the version of jboss-seam.jar(I'm using the newset - 1.0.1GA)
it seem to me that it does called the method fetchLanguges()(@factory method)
I tried to change the SB to be SF -> i am getting there a different exception
that says that the List doesn't contains Object instance of SelectItem.
11:03:27,697 INFO [STDOUT] Hibernate: select codestable0_.ID as ID1_, codestable0_.TABLE as TABLE1_, codestable0_.DESCRIPTION as DESCRIPT3_1_, codestable0_.CODE as CODE1_, codestable0_.LABEL as LABEL1_ from wannabet.codes_table codestable0_ where codestable0_.TABLE=?
11:03:27,867 INFO [STDOUT] Hibernate: select codestable0_.ID as ID1_, codestable0_.TABLE as TABLE1_, codestable0_.DESCRIPTION as DESCRIPT3_1_, codestable0_.CODE as CODE1_, codestable0_.LABEL as LABEL1_ from wannabet.codes_table codestable0_ where codestable0_.TABLE=?
11:03:27,887 ERROR [STDERR] 13/08/2006 11:03:27 com.sun.facelets.FaceletViewHandler handleRenderException
SEVERE: Error Rendering View[/login/register.xhtml]
java.lang.NullPointerException
at org.jnp.interfaces.NamingContext.bind(NamingContext.java:556)
at org.jnp.interfaces.NamingContext.bind(NamingContext.java:531)
at javax.naming.InitialContext.bind(InitialContext.java:359)
at org.jboss.seam.contexts.StatelessContext.set(StatelessContext.java:42)
at org.jboss.seam.Component.handleFactoryMethodResult(Component.java:1415)
at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1390)
at org.jboss.seam.Component.getInstance(Component.java:1339)
at org.jboss.seam.Component.getInstance(Component.java:1323)
at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:44)
at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
at org.apache.myfaces.shared_impl.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:102)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:477)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:453)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:277)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:251)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:54)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:442)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:216)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:98)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
11:03:27,937 INFO [STDOUT] Hibernate: select codestable0_.ID as ID1_, codestable0_.TABLE as TABLE1_, codestable0_.DESCRIPTION as DESCRIPT3_1_, codestable0_.CODE as CODE1_, codestable0_.LABEL as LABEL1_ from wannabet.codes_table codestable0_ where codestable0_.TABLE=?
my stateless-
@Stateless @Name("login") public class LoginAction implements Login { private static final String USER_VAR = "loggedIn"; @PersistenceContext private EntityManager em; @In Context sessionContext; @In(required=false) @Valid CodesTable codesTable; @SelectItems(labelMethod="getLabel",valueMethod="getId") public List<CodesTable> lang; @Factory("lang") public void fetchLanguages() { /*ArrayList<SelectItem> a = new ArrayList<SelectItem>(); SelectItem selectedItem = new SelectItem(1,"one"); SelectItem selectedItem1 = new SelectItem(2,"two"); a.add(selectedItem); a.add(selectedItem1); selectedItem.*/ List resultList = em.createQuery("select c from CodesTable c where c.table=:table") .setParameter("table","languages").getResultList(); this.lang = resultList; } }
here is my xhtml-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <body> <ui:composition template="/WEB-INF/template.xhtml"> <ui:define name="topnav"> <ui:include src="/WEB-INF/incl/store_nav.xhtml"> <ui:param name="page" value="home" /> </ui:include> </ui:define> <ui:define name="sidebar"> <ui:include src="/WEB-INF/incl/login.xhtml" /> </ui:define> <ui:define name="body"> <f:view> <h:form> <h:outputText value="Registration date: #{user.regDate}" rendered="#{loggedIn!=null}" /> <h:panelGrid columns="2"> <h:outputText value="First name: " /> <h:inputText value="#{user.firstName}" /> <h:outputText value="Last name: " /> <h:inputText value="#{user.lastName}" /> <h:outputText value="Username: " /> <h:panelGroup> <h:inputText id="usernameField" value="#{user.username}" /> <h:message for="usernameField" /> </h:panelGroup> <h:outputText value="Password: " /> <h:inputSecret value="#{user.password}" /> <h:outputText value="Language: " /> <h:selectOneMenu > <f:selectItems value="#{lang}" /> </h:selectOneMenu> </h:panelGrid> <h:commandButton value="Register" action="#{login.register}" rendered="#{loggedIn==null}" /> <h:commandButton value="Update" action="#{login.update}" rendered="#{loggedIn!=null}" /> </h:form> </f:view> </ui:define> </ui:composition> </body> </html>
Thanks