4 Replies Latest reply on Dec 17, 2007 6:26 AM by razwed4ik

    Idea for a Cancel Link/Button needed

    razwed4ik

      Hi,

      i have this code:

      Form

      <h:form id="form">
       <h:outputText rendered="#{!bean.editable}" value="#{bean.firstName}" />
       <br />
       <h:outputText rendered="#{!bean.editable}" value="#{bean.lastName}" />
      
      <h:inputText rendered="#{bean.editable}" value="#{bean.firstName}" id="firstName"/>
      <h:inputText rendered="#{bean.editable}" value="#{bean.lastName}" id="firstName"/>
      
      <t:div rendered="#{bean.owner && !bean.editable}">
       <a4j:commandLink action="#{bean.edit}" reRender="form" value="Edit" id="editButton" ajaxSingle="true"
       onclick="if (!isEditable()) {alert('#{msg['warnings.edit']}');return false};" oncomplete="setEditable(false);" />
      </t:div>
      
      <t:div rendered="#{bean.owner && ben.editable}">
       <a4j:commandLink value="Save" id="saveButton" action="#{bean.save}" reRender="form"
       oncomplete="setEditable(true);" />
       <a4j:commandLink value="Cancel" id="cancelButton" action="#{bean.cancel}" reRender="form"
       immediate="true" oncomplete="setEditable(true);" />
      </t:div>
      
      


      This Form has two States Editable and Not Editable. I can Edit and Save this Form , but I have no idea how to realize a Cancel Link. At the moment, if i click cancel, the Output is like it should the old value, but if I click edit again, in the InputField is the value what I entered before click cancel. Any Ideas, what i can put in my bean? I tried to get the Data from Database and overwrite the InputFields but the I get errors, because im using Lazyinitialization.


      Thx. i. A.