wood burning stoves 2.0*
The moose likes JSF and the fly likes JSF drop down problems again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF drop down problems again" Watch "JSF drop down problems again" New topic

JSF drop down problems again

Anoop V. Kumar

Joined: Jan 21, 2006
Posts: 18
Hi All,

I have been reading a lot about drop-down boxes in JSF. Most of them have been very useful but have not been able to completely solve my problem here...

I have a very simple page that displays a dropdown with model-id numbers. There is also a button below the dropdown which when clicked takes the user to another page and says "You selected this model: <model-id number from dropdown>"

So far so good - all works fine. Now I wanted to add a description so that after clicking on the button I get the modelId as well as the model description - This just does not work - the page does not even come up and shows a lot of errors.

In order to show the description as well I used the SelectItem constructor that accepts a value and a label. I used the modelId as the label and the model-description as value.

Here is the jsp page code:

Here is the java backing bean code:
This code is supposed to put the modelDescription as well - but does not work....

I get these errors:
On the browser:

javax.faces.el.EvaluationException: Expression: '#{modelBean.models}'
at net.sourceforge.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:463)
at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
at net.sourceforge.myfaces.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:357)
at net.sourceforge.myfaces.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:300)
at net.sourceforge.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:369)
at net.sourceforge.myfaces.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:328)
at net.sourceforge.myfaces.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:64)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:329)
at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:376)
at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:280)
at org.apache.jsp.gse.model_jsp._jspx_meth_h_selectOneMenu_0(org.apache.jsp.gse.model_jsp:306)
at org.apache.jsp.gse.model_jsp._jspx_meth_h_form_0(org.apache.jsp.gse.model_jsp:183)
at org.apache.jsp.gse.model_jsp._jspx_meth_f_view_0(org.apache.jsp.gse.model_jsp:147)
at org.apache.jsp.gse.model_jsp._jspService(org.apache.jsp.gse.model_jsp:92)
Caused by: javax.faces.el.EvaluationException: Bean: com.sigma.gse.view.ModelPageBean, property: models
at net.sourceforge.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:458)
at net.sourceforge.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:113)
at net.sourceforge.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:541)
at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
at net.sourceforge.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:438)
... 56 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:454)
... 60 more
Caused by: java.lang.NullPointerException: value
at javax.faces.model.SelectItem.(SelectItem.java:55)
at com.sigma.gse.view.ModelPageBean.getModels(ModelPageBean.java:48)
... 65 more

On the Tomcat console:
ERROR - PropertyResolverImpl.getValue(117) | com.sigma.gse.view.ModelPageBean
javax.faces.el.EvaluationException: Bean: com.sigma.gse.view.ModelPageBean, property: models
at net.sourceforge.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:4
at net.sourceforge.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:113)
at net.sourceforge.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java

Code that worked:

I need help in figuring out what I am doing wrong? If you notice, there is very little difference between the code that worked and the above defective code.

Thanks a TON in advance,
Anoop V. Kumar

Joined: Jan 21, 2006
Posts: 18
Ok - I figured out the answer to this issue of mine - I need to use converters because I am using application specific objects..

subject: JSF drop down problems again
Similar Threads
Problems using h:selectOneMenu
ERROR - ValueBindingImpl.getValue | Cannot get value for expression '#{modelPage
SelectItem Pardox
dataTable objects as inner class