3 Replies Latest reply on May 16, 2007 6:02 AM by Ilya Shaikovsky

    Proper use of modal panel for confirmantion & success messag

    Chetan Kadam Newbie

      I am trying to design following scenario :

      1. I have a data table containing bunch of employee names, and each row of the table has delete action (link)
      2. When user clicks on this link, I want to show confirmation modal panel "Do you really want to delete this record ?"
      3. If user clicks on OK, then delete operation happens, and user is shown success message in another modal panel.

      I am thinking about writing code as follows,

      <t:dataTable value="#{myBean.data}" var="d" >
       <f:facet name="header">Name</f:facet>
       <h:outputText value="#{d.name}" />
       <f:facet name="header">Action</f:facet>
       <a4j:commandLink action="#{myBean.deleteRowData}" value="delete"
       reRender="myPopUp1, myPopup2"
      <rich:modalPanel id="myPopUp1">
       <h:outputText value="Do you want to delete #{myBean.rowData.name} ?" />
      <rich:modalPanel id="myPopUp2">
       <h:outputText value="Successfully deleted #{myBean.rowData.name}" />

      But I am still not able to figure out :
      1. When I show modal panel on form submit, how can I update rowData property in backing bean ? I dont think its possible before posting the form.
      2. How can I close first modal panel and continue with form submit ?
      3. IF the delete operation fails, then how can I NOT show success popup.

        • 1. Re: Proper use of modal panel for confirmantion & success me
          Ilya Shaikovsky Master

          Main page:

           <rich:modalPanel id="_panel">
           <a4j:include viewId="/pages/greeting.xhtml"></a4j:include>
           <h:form id="_form">
           <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"
           rowKeyVar="row" id="table" >
           <a4j:commandButton oncomplete="javascript:Richfaces.showModalPanel('_panel')" value="Delete" ajaxSingle="true">
           <a4j:actionparam value="#{row}" assignTo="#{capitalsBean.deletedRow}" name="row"/>

          first include (popup):
           <h:outputText value="Sure to delete?"></h:outputText>
           <a4j:commandLink action="#{capitalsBean.delete}" value="Delete">
           <h:outputLink value="#" onclick="javascript:Richfaces.hideModalPanel('_panel')">
           <h:outputText value="Close"></h:outputText>

          Second include (if needed):
          <h:form onsubmit="javascript:Richfaces.hideModalPanel('_panel')">
           <a4j:commandLink value="Hide" reRender="table"></a4j:commandLink>

          public String delete() {
           //String sid=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("row");
           int intid = Integer.parseInt(getDeletedRow());
           return "greeting1";

          Looks like your use case.

          • 2. Re: Proper use of modal panel for confirmantion & success me
            Chetan Kadam Newbie

            Thanks for the response .

            I understand how you are showing the first confirmation dialog and updating Backing bean prior to that. However from your example, it was not very clear as in :

            1. Where is the second include actually included ? (in main page or in the greetings dialog )
            2. How does the second modal panel invoked. ? Based on the delete action on first modal panel, its simply calling action on the backing bean. Does this action have some navigation rules, which cause first modal panel to close and display second modal panel ?

            • 3. Re: Proper use of modal panel for confirmantion & success me
              Ilya Shaikovsky Master

              There is navigation occurs as far as I used ajax action component inside the a4j:include which is returns navigation outcome.
              So there will be navigation inside the include after delete link activated or closure if close pressed.