[JBoss Seam] - Re: How to use si:selectItems with an object that has a Stri
by lawrieg
I've done some more investigating and the problem is that the <h:selectOneMenu> value property (which is #{customerHome.instance.customerType}) is passed to the BasicEntityConverter, and that customerHome.instance.customerType holds a new instance of CustomerType which doesn't have any fields set.
The issue seems to stem from the seam-gen generated entity home code:
@Name("customerHome")
| public class CustomerHome extends EntityHome<Customer> {
|
| @In(value = "#{customerTypeHome.instance}", required = false)
| CustomerType customerType;
| @In(value = "#{refCustomerStatusHome.instance}", required = false)
| RefCustomerStatus refCustomerStatus;
|
| public void setCustomerId(Integer id) {
| setId(id);
| }
|
| public Integer getCustomerId() {
| return (Integer) getId();
| }
|
| @Override
| protected Customer createInstance() {
| Customer result = new Customer();
| result.setCustomerType(customerType);
| result.setRefCustomerStatus(refCustomerStatus);
| return result;
| }
|
| public List<Activity> getActivities() {
| return getInstance() == null ? null : new ArrayList<Activity>(
| getInstance().getActivities());
| }
|
| }
|
Do I need to change the seam-gen generated code (i.e. is it incorrect)? (I presume I do if the BasicEntityConverter doesn't convert a null id to whatever is required for the "no item selected" item in the drop down list to be selected.
What value for #{customerHome.instance.customerType} in (<h:selectOneMenu> value property) would cause my drop down to correctly have the "Please Select..." (no item selected) item selected when the page is displayed? Should my CustomerHome createInstance() method instead be setting the customerType to null rather than #{customerTypeHome.instance}???
Any help would be really appreciated as I'm struggling to get my code working with <h:selectOneMenu> & <si:selectItems> and none of the examples are really helping to clarify things...
Thanks in advance,
Lawrie.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4009344#4009344
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4009344
17Â years, 11Â months
[JNDI/Naming/Network] - JBoss 4.05 GA Stateless Session Bean JNDI lookup ClassCastEx
by tomatkist
Hi,
I'm getting a strange ClassCastException when trying to lookup a Stateless Session Bean from within my myfaces managed bean. What I'm doing is simply call
| SicherheitsDatenBean sdb = (SicherheitsDatenBean) CTX.lookup("JSF-REACH/SicherheitsDatenBean/local");
|
to obtain a bean instance from FacesContext CTX.
The bean is registered in JNDI under that name, I can see it in my JBoss' jmx console (JBoss version 4.05 GA):
| +- JSF-REACH (class: org.jnp.interfaces.NamingContext)
| | +- SicherheitsDatenBean (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy104 implements interface business.SicherheitsDaten,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
|
This is the exception:
| 12:15:05,671 ERROR [STDERR] java.lang.ClassCastException: $Proxy104
| 12:15:05,671 ERROR [STDERR] at facesBeans.Questionnaire.<init>(Questionnaire.java:43)
| 12:15:05,671 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
| 12:15:05,671 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
| 12:15:05,671 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
| 12:15:05,671 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Unknown Source)
| 12:15:05,671 ERROR [STDERR] at java.lang.Class.newInstance0(Unknown Source)
| 12:15:05,671 ERROR [STDERR] at java.lang.Class.newInstance(Unknown Source)
| 12:15:05,671 ERROR [STDERR] at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:274)
| 12:15:05,671 ERROR [STDERR] at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:265)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:50)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:311)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
| 12:15:05,687 ERROR [STDERR] at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
| 12:15:05,687 ERROR [STDERR] at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
| 12:15:05,687 ERROR [STDERR] at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:135)
| 12:15:05,687 ERROR [STDERR] at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
| 12:15:05,687 ERROR [STDERR] at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
| 12:15:05,687 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:495)
| 12:15:05,687 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:363)
| 12:15:05,687 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspx_meth_h_inputText_0(questionnaire_jsp.java:438)
| 12:15:05,687 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspx_meth_h_form_0(questionnaire_jsp.java:383)
| 12:15:05,687 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspx_meth_f_subview_0(questionnaire_jsp.java:356)
| 12:15:05,687 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspx_meth_t_div_4(questionnaire_jsp.java:329)
| 12:15:05,718 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspx_meth_f_view_0(questionnaire_jsp.java:184)
| 12:15:05,718 ERROR [STDERR] at org.apache.jsp.docs.pages.main.questionnaire_jsp._jspService(questionnaire_jsp.java:97)
| 12:15:05,718 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
| 12:15:05,718 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| 12:15:05,718 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
| 12:15:05,718 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
| 12:15:05,718 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
| 12:15:05,718 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| 12:15:05,718 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| 12:15:05,718 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| 12:15:05,718 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
| 12:15:05,718 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
| 12:15:05,718 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
| 12:15:05,734 ERROR [STDERR] at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
| 12:15:05,734 ERROR [STDERR] at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
| 12:15:05,734 ERROR [STDERR] at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
| 12:15:05,734 ERROR [STDERR] at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:222)
| 12:15:05,734 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
| 12:15:05,734 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| 12:15:05,734 ERROR [STDERR] at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| 12:15:05,734 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| 12:15:05,734 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| 12:15:05,734 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| 12:15:05,734 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| 12:15:05,734 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| 12:15:05,734 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| 12:15:05,734 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| 12:15:05,734 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| 12:15:05,734 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| 12:15:05,734 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
|
any ideas?
Thanks!
TS
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4009339#4009339
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4009339
17Â years, 11Â months