Problems implementing an editable datatable
zzzz8 Jul 23, 2008 3:02 AMI'm having issues creating an inline editable datatable using the RichFaces components. I am currently using RichFaces 3.2.0, Seam 2.0.2 GA, Facelets 1.0, and JBoss AS 4.2.2. My editable datatable has the following requirements:
1. Inline row editing (i.e. I should be able to edit any input components on a row by row basis.
2. Delete row functionality. I need a delete button/link component for each row that will allow me to delete that particular row
3. Add row functionality. I need a single add row button/link that allows me to add a row to the last row of the datatable.
4. I must be able to add the row even if the other rows fail validation.
5. Adding the row does not remove or change the input values in the other rows.
Unfortunately, I've been having problems getting these requirements met as a whole - and I'm wondering if this is even possible with RichFaces' current component set. I'm able to meet requirement 1 (inline row editing) with no issue. However, I cannot get the delete row functionality working (the button doesn't seem to even respond). The add row functionality works...up to a point. I am able to add a row, but it seems to change/remove the input values (of the previously entered values) of the other rows.
Here's a snippet of my XHTML:
<s:validateAll> <rich:dataTable id="pluPurchase" value="#{pluPurchaseDatamodelSet}" var="purchase" rowClasses="rvgRowOne,rvgRowTwo"> <rich:column> <f:facet name="header">Unit</f:facet> <h:inputText id="unit" required="true" value="#{purchase.unit}" /> <rich:message for="unit" style="error" /> </rich:column> <rich:column> <f:facet name="header">Unit Price</f:facet> <h:inputText id="unitPrice" required="true" value="#{purchase.unitprice}" /> <rich:message for="unitPrice" style="error" /> </rich:column> <rich:column> <f:facet name="header">Remove Item</f:facet> <a:commandButton action="#{plupurchaseDatamodel.removePlupurchase}" immediate="true" value="Remove"> <s:conversationPropagation type="join" /> </a:commandButton> </rich:column> </rich:dataTable> </s:validateAll> <a:commandButton immediate="true" reRender="pluPurchase,pluPurchaseRepeat" action="#{plupurchaseDatamodel.addPlupurchaseAction}" value="Add Purchase"> <s:conversationPropagation type="join" /> </a:commandButton>
After I click on the "Add Purchase" button, the other rows' inputted values are wiped clean. The addPlupurchaseAction method returns null in this case. The immediate attribute does allow me to skip the validation of the other rows. Initially, the table has no rows. There is no effect after adding a row and then pressing the "Remove Item". I don't get any exceptions.
What am I doing wrong here? Thanks!