3 Replies Latest reply on Oct 20, 2010 3:03 AM by tienlantri

    how to do edit and new by using the same xhtml page

    tienlantri

      Hi,
      I have a page xhtml who list all the operations. On this page, we can open another page to create new operation by clicking on a button. We can also edit a selected operation.


      So I define the navigation in listOperation.page.xml




      <navigation from-action="#{gestionOperation.editOp(operation.id)}">
           <redirect view-id="/pages/admin/detailOperation.xhtml"/>
       </navigation>
      <navigation from-action="#{operationManager.newOp}">
           <redirect view-id="/pages/admin/detailOperation.xhtml"/>
      </navigation>



      The problem is that in detailOperation.xhtml, I don't know how to distinguish which action is edit or new.


      1. Can I add a param like this to make it different?


      <navigation from-action="#{gestionOperation.editOp(operation.id)}">
           <redirect view-id="/pages/admin/detailOperation.xhtml">
               <param name="mode" value="edit"/>
           </redirect>
       </navigation>
      <navigation from-action="#{operationManager.newOp}">
           <redirect view-id="/pages/admin/detailOperation.xhtml">
              <param name="mode" value="new"/>
           </redirect>
      </navigation>




      2. And so, in detailOperation.xhtml, how can I get value of param in order to show/hide component correctly?


      Thanks,
      Tina