I have been trying to display some values from the list in a input text box in JSF 2.0. The value is not getting displayed.Below is the code that im trying to run
<h:inputText id="targetDaysValueID" value="#{demandBean.filterSelectionVOList.targetDays}" required="false" style="height:22px;width:155px;float: right"></h:inputText>
Below is the error message that Im getting when I try to run the page containing the above code in a xhtml page.
ava.lang.NumberFormatException: For input string: "targetDays"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at javax.el.ListELResolver.coerce(ListELResolver.java:166)
at javax.el.ListELResolver.getValue(ListELResolver.java:51)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
The code works fine in a datatable, I assign the list to the datatable & create a variable for the same and when I use the variable with the fieldname I want to display, the same works fine. But doesnt work when I try to display the value=”#{demandBean.filterSelectionVOList.targetDays}”
Please Assist. Thanks in Advance.
The problem is that
#{demandBean.filterSelectionVOList}resolves to a list.h:inputtextvalue CANNOT be a collection.If
filterSelectionVOListis not empty try for example:#{demandBean.filterSelectionVOList.get(0).targetDays}edited:
To display all data from the collection you can for example wrap your output component by
ui:repeat:also add a proper namespace definition:
You can also display elements using
h:dataTableif this suits you better.