6 Replies Latest reply on Oct 21, 2013 5:08 PM by OraGeek17

    show dialog box using javascript with yes or no button for deleting the records

    OraGeek17

      Hi ,

       

      I am new to OAF.

      I have a requirement to show dialog box when user clicks on Update or delete button.

      I have tried 2 options to show dialog box.

      I am able to show dialog box as well but not able to capture the yes or No button event.

      Please help me.

      Its urgent.

      Below is the option I have tried and both shows dialog box.

      (1) In PR

      StringBuffer jsString = new StringBuffer();
      jsString.append(" function validatePage() { ");
      jsString.append("var x;");
      jsString.append("if(window.confirm('Are you sure you want to delete this record?'))");
      jsString.append("{return false;}");
      jsString.append(" } ");
      pageContext.putJavaScriptFunction("validatePage", jsString.toString());
      OABodyBean bB = (OABodyBean)pageContext.getRootWebBean();
      bB.setOnClick(jsString.toString());
      OASubmitButtonBean okButton = (OASubmitButtonBean)webBean.findChildRecursive("updatebtn");

      okButton.setOnClick("return validatePage()");

      (2) In PFR

      if(pageContext.getParameter("updatebtn") != null){
      StringBuffer jsString = new StringBuffer();
      jsString.append("javascript:");
      jsString.append("var x");
      jsString.append("if(window.confirm('Are you sure you want to delete this record?'))");
      jsString.append("{return false}");
      jsString.append(" } ");
      pageContext.putJavaScriptFunction("SomePage", jsString.toString());
      }

      Please help me...

       

      Thanks,

      Suhani

        • 1. Re: show dialog box using javascript with yes or no button for deleting the records
          keerthioaf

                  Hi there ,

           

                 OA Framework has different way to show the dialog page , you can import the dialouge bean

                ( OADialogPage )

           

                 and follow the code mentioned below in your controller class ( PFR ) :

           

              
          OADialogPage dialogPage = new OADialogPage(OAException.WARNING,
          mainMessage, null, "", "");

          String yes = pageContext.getMessage("AK", "FWK_TBX_T_YES", null);
          String no = pageContext.getMessage("AK", "FWK_TBX_T_NO", null);

          dialogPage.setOkButtonItemName("DeleteYesButton");

          dialogPage.setOkButtonToPost(true);
          dialogPage.setNoButtonToPost(true);
          dialogPage.setPostToCallingPage(true);

          pageContext.redirectToDialogPage(dialogPage);

                 

          Please let me know if its not clear / if you need any further input .

           

            Regards ,

            Keerthi

          • 2. Re: show dialog box using javascript with yes or no button for deleting the records
            OraGeek17

            Hey Keerthi,

             

            Thanks for your help.

             

            But I already tried dialogpage option and the main thing I am using Aadvaced table with multiselection. I am storing the selected rows in the arraylist.

            And when I am calling dialog page it I am not able to pass arraylist with the dialog page and when the dialog page even fire arraylist will have null selected rows.

             

            I did try with setretainAM(true) but this also didnt work for me.

             

            And as per the requirement of the client it is recommanded that page should not redirect to new page just for the message.

             

            Please let me know if you have any idea how to achieve this

             

            Thanks,

            Suhani

            • 3. Re: show dialog box using javascript with yes or no button for deleting the records
              keerthioaf

                      Hi Suhani ,

               

                     We have very limited feature when it comes to incorporating java script with OAF , you can try this bolg

                       http://mukx.blogspot.in/2007/07/javascript-in-oa-framework.html

               

                       What is the kind of validation you 're looking for in multi selection , can you tell us little more about your requirement .      

               

                       Regards ,

                       Keerthi

              1 person found this helpful
              • 4. Re: show dialog box using javascript with yes or no button for deleting the records
                OraGeek17

                Hi Keerthi,

                 

                The proper requirement is.

                When the page render with advanced table region who allows multiselection and user select the rows and click on global update button then the dialog box should open asking conformation message as "would you like to update?" with yes or no button if user clicks on yes it should call the method in the AM with the selected rows parameter and update the values and if No then nothing should happen.

                 

                Please let me know how would I achieve this.

                 

                I tried a lot but nothing work for me

                 

                Thanks,

                Suhani

                • 5. Re: show dialog box using javascript with yes or no button for deleting the records
                  Bhardwaj Ankur

                  Hi Suhani,

                   

                  Just display the message and on click of Yes button call the method of AM in which you will get all the selected rows of the VO using iterator where Select Flag should be "Y".

                  and perform the operation.

                   

                   

                  Regards,

                  Ankur

                  • 6. Re: show dialog box using javascript with yes or no button for deleting the records
                    OraGeek17

                    Hi Ankur & Keerthi,

                     

                    I have solved the issue.

                    Here is the code I have used.

                     

                    PR Method:

                          String upStatus =  "function upRec() { "+

                          " if(confirm('Are you sure you want to set the batch status to NEW'))" +

                          "{" +

                          "submitForm('DefaultFormName',0,{'updateRec':'token'});" +

                          "}"+

                            "}";

                            OAButtonBean okButton = (OAButtonBean)webBean.findChildRecursive("setToNewbtn");

                            okButton.setOnClick("upRec()");

                     

                    PFR Method:

                    if("token".equals(pageContext.getRenderingContext().getServletRequest().getParameter("updateRec"))){

                              //Business logic

                    }

                     

                    I hope this will help others to solve the issue.