4 Replies Latest reply on Jun 19, 2007 3:24 AM by Mihai Anescu

    Question: how to make confirmation box work with h:commandLi

    Mihai Anescu Newbie

      Hi,

      !!!Possible bug???

      I have a "delete" button, and I want to make a "confirmation" box, so that the user can be sure he want's to delete the entity.

      I have stumbled upon some sort of bugs:

      The code is this:

      <s:link styleClass="welcome"
       title="#{messages['general.delete']}"
       id="fakeDelete" rendered="#{abcHome.managed}"
       onclick="deleteConfirm()"
       >
       <h:graphicImage value="img/delete.png" height="16" width="16"
       border="0"/>
       #{messages['general.delete']}
      </s:link>
      <h:commandLink id="delete" action="#{abcHome.remove}" style="display:none">
      </h:commandLink>
      
      <script>
      function deleteConfirm()
      {
       var answer = confirm( "Do you want to delete this entity?" );
       if( answer )
       {
       alert( 'delete!' );
       var btn = document.getElementById( "abc:delete" );
       alert( btn );
       btn.click();
       }
      }
      </script>


      Now, I am on the AbcEdit page, and I have in the AbcEdit.page.xml this part:
      <navigation from-action="#{abcHome.remove}">
       <end-conversation/>
       <redirect view-id="/AbcList.xhtml"/>
       </navigation>


      Before I made the modification, and used the normal button to do the delete, after I deleted one entity I was returned to the entity List. Now, 2 things happen.
      If I leave the code as above, I still remain on the AbcEdit page. If I add this part to the fakeButton:
      view="/AbcList.xhtml"

      then it goes to the AbcList, but it will go there always, even if the user doesn't click on Ok, but on Cancel. So this I think is a bug from the Seam framework???

      Any way, my question is if anybody has done this sort of thing with Seam?
      PS: I also tried this solution here, which doesn't work.
      http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces