This content has been marked as final.
Show 3 replies
-
1. Re: Updating a row in dataTable
vgarmash Sep 19, 2007 4:44 PM (in response to dev_team)If don't stick on Ajax this task become rather simple: you could just replace outputText elements in the some row with inputText ones using ActionListener on "Edit" link. You also should show "Save" button for this row. Then by ActionListener on "Save" button you could save data into Model layer and replace inputText elements back with outputTexts.
-
2. Re: Updating a row in dataTable
dev_team Sep 20, 2007 12:18 AM (in response to dev_team)Thanks a lot for your input.
I am new to JSF. It would be very nice if you can just detail out the Action Listener(replace outputText elements in the same row with inputText ones using ActionListener on "Edit" link).
Thanks once again for your time. -
3. Re: Updating a row in dataTable
ilya_shaikovsky Sep 20, 2007 7:58 AM (in response to dev_team)The simpliest example I can provide after a few minutes of work under my excisting table :
<rich:dataTable value="#{capitalsBean.capitals}" var="cap"> <rich:column> <a4j:outputPanel id="row1"> <h:inputText value="#{cap.name}" rendered="#{cap.checked}"></h:inputText> <h:outputText value="#{cap.name}" rendered="#{not cap.checked}"></h:outputText> </a4j:outputPanel> </rich:column> <rich:column> <a4j:outputPanel id="row2"> <h:inputText value="#{cap.state}" rendered="#{cap.checked}"></h:inputText> <h:outputText value="#{cap.state}" rendered="#{not cap.checked}"></h:outputText> </a4j:outputPanel> </rich:column> <rich:column> <h:selectBooleanCheckbox value="#{cap.checked}"> <a4j:support event="onclick" reRender="row1,row2"> <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender"></a4j:ajaxListener> </a4j:support> </h:selectBooleanCheckbox> </rich:column> </rich:dataTable>
My bean is session scoped. (Or should be saved through keepAlive)
In general :
1) checkBox fire an ajax request. It inverts its state. And corresponding rendered attributes - changes to inverted,
So its pretty simple as you can see.