I think i know more or less how the sortable-problem with my table can be explained:
1. edit button of a row is pressed 2. sort method is called (order is now descending) 3. the row is made editable (the wrong one, because the table is descending) 4. sort method is called again (order is now ascending). -----Original Message----- From: Boeckli, Dominique [mailto:[EMAIL PROTECTED] Sent: Donnerstag, 9. Februar 2006 15:32 To: MyFaces Discussion Subject: RE: dataTable item is not changed Many thanks for your help. I applied all of your suggestions but i have still same problem: the entered value in "t:inputText" is lost. But i got some new ideas! I replaced the commandlinks with commandbuttons and it works but my nice buttons are gone! I don't know what's difference between the commandbutton and the commandlink, but in this case their behaviour is complete different. Does anybody know why? <t:column> <f:facet name="header"> <t:outputText value="Action"/> </f:facet> <t:commandButton value="delete" id="button_delete" actionListener="#{userListBean.deleteUserFromDB}"/> <f:verbatim><br /></f:verbatim> <t:commandButton value="edit" id="button_edit" action="#{user.edit}" rendered="#{not user.editable}"/> <t:commandButton value="save" id="button_save" action="#{user.save}" rendered="#{user.saveable}"/> </t:column> There's another problem with my table. As you can see my table is sortable. Assuming i have 6 rowes: When i press the edit button on row 1, row 6 gets editable. When i press 2, row 5 gets editable, and for 3 row i get 4, etc. When i make the table not sortable then all works as expected. Kind regards Dominique -----Original Message----- From: Mike Kienenberger [mailto:[EMAIL PROTECTED] Sent: Mittwoch, 8. Februar 2006 23:03 To: MyFaces Discussion Subject: Re: dataTable item is not changed My recommendation would be to use action instead of action + actionListener. I'm not sure -- is it even legal to be calling both? Why would you want to? I'd also recommend that you create both an editable and save button rather than reusing the same button for both. <h:commandLink action="setEditable" id="edit" rendered="#{not user.editable}"> <h:graphicImage value="/graphics/edit.png" alt="edit" style="border:0"/> </h:commandLink> <h:commandLink action="save" id="save" rendered="#{user.saveable}"> <h:graphicImage value="/graphics/save.png" alt="edit" style="border:0"/> </h:commandLink> Note that, in any case, the value of "#{not user.editable}" and "#{user.saveable}" should remain constant between requests (maybe that's why you chose to use a single button, but that seems like a hack to me). Ie, the value can't change between the time the button is rendered and the next response when the button action is executed on click. On 1/27/06, Boeckli, Dominique <[EMAIL PROTECTED]> wrote: > > > Hi all, > > I have a datatable with a edit column which contains a delete and a > edit button. The delete button works fine (when pressed the row is > deleted). When the edit button is pressed all items in this row gets > editable. Works perfect as well. The edit button is replaced by a save > button. Now i can edit something in the row. When i finished editing > the save button can be pressed to save the new values, but they get > lost and the old value are displayed again (the actionlistener method > was called, but in tracing i saw the the actionlistener gets the old > value as well instead of the old value. So in fact the old value is > Saved). > > Following the code: > > <t:dataTable id="users" > value="#{userListBean.users}" > var="user" > border="0" > cellspacing="1" > cellpadding= "10" > sortColumn="#{userListBean.sort}" > sortAscending="#{userListBean.ascending}" > preserveDataModel="true" > preserveSort="true" > renderedIfEmpty="false" > styleClass="users" > headerClass="usersHeader" > rowClasses="evenRow,oddRow"> > > <t:column> > <f:facet name="header"> > <h:outputText value="Select"/> > </f:facet> > <t:selectBooleanCheckbox id="select" > value="#{user.selected}" > > valueChangeListener="#{userListBean.setSelected}"/> > </t:column> > > <t:column> > <f:facet name="header" > > <t:commandSortHeader columnName="userid" arrow="true" > styleClass="usersHeader"> > <t:outputText value="userid"/> > </t:commandSortHeader> > </f:facet> > <t:outputText value="#{user.userid}"/> > </t:column> > > <t:column> > <f:facet name="header"> > <t:commandSortHeader columnName="firstname" arrow="true" > styleClass="usersHeader"> > <h:outputText value="Firstname"/> > </t:commandSortHeader> > </f:facet> > <t:outputText value="#{user.firstname}" rendered="#{not > user.editable}"/> > <t:inputText value="#{user.firstname}" rendered="#{user.editable}"/> > </t:column> > > <t:column> > <f:facet name="header"> > <t:commandSortHeader columnName="lastname" arrow="true" > styleClass="usersHeader"> > <t:outputText value="Lastname"/> > </t:commandSortHeader> > </f:facet> > <t:outputText value="#{user.lastname}" rendered="#{not user.editable}"/> > <t:inputText value="#{user.lastname}" rendered="#{user.editable}" > required="true" /> > </t:column> > > <t:column> > <f:facet name="header"> > <t:commandSortHeader columnName="password" arrow="true" > styleClass="usersHeader"> > <t:outputText value="Password"/> > </t:commandSortHeader> > </f:facet> > <t:outputText value="#{user.password}" rendered="#{not user.editable}"/> > <t:inputText value="#{user.password}" rendered="#{user.editable}"/> > </t:column> > > <t:column> > <f:facet name="header"> > <t:commandSortHeader columnName="contact" arrow="true" > styleClass="usersHeader"> > <t:outputText value="Contact"/> > </t:commandSortHeader> > </f:facet> > <t:outputText value="#{user.contact}" rendered="#{not user.editable}"/> > <t:inputText value="#{user.contact}" rendered="#{user.editable}"/> > </t:column> > > <t:column> > <f:facet name="header"> > <t:outputText value="Roles"/> > </f:facet> > <t:dataTable id="roles" > value="#{user.roles}" > var="roles" > border="0"> > <t:column> > <t:outputText value="#{roles.role}"/> > </t:column> > </t:dataTable> > </t:column> > > <t:column> > <f:facet name="header"> > <t:outputText value=""/> > </f:facet> > <h:commandLink action="delete" id="delete" > actionListener="#{userListBean.deleteUserFromDB}"> > <h:graphicImage value="/graphics/delete.png" alt="delete" > style="border:0"/> > </h:commandLink> > <f:verbatim><br /></f:verbatim> > <h:commandLink action="setEditable" id="edit" > actionListener="#{userListBean.setEditable}"> > <h:graphicImage value="/graphics/edit.png" alt="edit" style="border:0" > rendered="#{not user.editable}"/> > <h:graphicImage value="/graphics/save.png" alt="edit" style="border:0" > rendered="#{user.editable}"/> > </h:commandLink> > </t:column> > </t:dataTable> > > Many thanks for your help > > Kind regards > > Dominique