DataTable issue.
Hi,
i have a datatable, and i am creating some fields based List received. in that datatable i have one textarea, and also i want to pass a value i am receiving from the list back to the bean. my code is like this ......
<t:dataTable id="curEmployees" value="#{focal.commentstates}" var="comstate">
<h:column id="head">
<h:outputText value="#{comstate.model.commentType.commentTypeDesc}" />
</h:column>
<h:column id="ta1">
<h:form id="f1">
<h:inputTextarea id="ta1" value="#{focal.comment1}" rows="5" cols="40">
</h:inputTextarea>
</h:form>
when i click on the Update button, how can i differentiate between the textareas of every row? is there any array strutture...?
Help me....thanks in Advance,
# 1
Where is the update button? In each row? If so, bind the datatable component to the backing bean and use HtmlDataTable#getRowData() to retrieve the row object.
If the update button is just a single button outside the datatable, then changes are just reflected in the same list as you've passed to the datatable.
Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html for some insights.
# 2
Hi Balu Thanks for reply... yes,, i can iterate through the list as you said, but how can i get the values entered in the textarea ... my textarea is pointing to a property called comment1 in the managed bean, i have getter and setter methods defined for that.... Help me...
# 3
What BalusC meant was to do something like this:
Create a HtmlDataTable component in your backing bean like this:
private HtmlDataTable modelTable = new HtmlDataTable();
modelTable.setValue(commentStates);
and in the Jsp:
<t:dataTable binding="#{focal.modelTable}" id="curEmployees" value="#{focal.commentstates}" var="comstate">
</t:dataTable>
If you click "Update" button, then the all the values (that are entered on the JSP) will be reflected in the "setter" method of "modelTable".
You can iterate through the modelTable and get the rows
Hope this helps.