6 Replies Latest reply: Jun 14, 2013 12:09 PM by ViswanathChandran RSS

    Text getting cleared after throwing OAException message

    505001
      Hi,

      I have a message text input item and a drop down if user does not enter anything in either and hits button then I am throwing a OAException with a message.

      The problem is each time the user enters let us say some text in the drop down and does not select anything in the list all the text the user enters is being cleared off. They want to be able to preserve the text they wrote as it could be a lots of words.

      I tried acheiving this through saving the text into a variable and displaying it after the error but it gives me compile error saying statement is not reachable.

      Here is my part my code....the one in bold is where I was trying to assign the saved text back but it throws me compile error. Can someone suggest some other way of doing what I am trying to do?

      else if(SaveButton !=null && ((NoteType.length() == 0 || (NoteText.length()==0 && !"".equals(NoteText.trim())))))
      {System.out.println("The Note Status is Null raise an error");
        saveNoteText = NoteText;
        String message = "You must enter a note and select a note type";
              throw new OAException(message, OAException.ERROR);
              *OAMessageTextInputBean Note = (OAMessageTextInputBean)webBean.findChildRecursive("NoteText"); // Does not work*

              *Note.setText(saveNoteText);}*
        • 1. Re: Text getting cleared after throwing OAException message
          505001
          Sorry this is my fault. I myself was setting the NoteText to Null in the beginning of the controller. By default it's not getting cleared.

          Thanks
          • 2. Re: Text getting cleared after throwing OAException message
            505001
            I still have an issue which needs to be fixed with this.
            • 3. Re: Text getting cleared after throwing OAException message
              505001
              Hi Guys,

              Actually yes I am setting the value to NULL in the beginning of the PR when the page first loads.

              But the issue is that if I don't do that then the comments / notes that the user enters are showing up if I hit cancel and come back to the page. So my requirement is that if the User comes in the page the notes and note type should be null or blank.

              There are 2 buttons on the page one is the Save button and the other is the Cancel button. I just want the to handle my items correctly on these events.

              * IF the user hits the save button without entering the required fields then I raise an OAexception but the all the fields are getting cleared out. ( I don't know how since I set them to NULL in the PR not in PFR). I want the error message but I don't want to clear out the fields.

              * IF the user hits the cancel button I don't want to retain or keep the fields I want to blank them out.

              Right now, I can make one or the other work but not both. Can anyone please suggest what I should do. Would really appreciate it. Below is my controller code that setting the stuff


              *********************************************************

              public void processRequest(OAPageContext pageContext, OAWebBean webBean)
              {
              super.processRequest(pageContext, webBean);
              String test = (String)pageContext.getParameter("ImcPartyId");
              String ExecuteQueryReport = pageContext.getParameter("ExecuteQueryReport");
              String retURL = pageContext.getParameter("retURL");
              String ExecuteQuery = pageContext.getParameter("ExecuteQuery");
              String SourceSystem = pageContext.getParameter("SourceSystem");
              pageContext.putSessionValue("SourceSystem", SourceSystem);
              System.out.println("The Party ID Here is "+ test);
              {  *OAMessageTextInputBean Note = (OAMessageTextInputBean)webBean.findChildRecursive("NoteText");*     // If I comment this out then in the error

              OAMessageChoiceBean NoteType = (OAMessageChoiceBean)webBean.findChildRecursive("NoteTypeID"); // message my fields are not getting blanked out
              Note.setText(null);
              NoteType.setText(pageContext, null); } // but if I cancel and come back it still shows up...
              pageContext.putSessionValue("retURL", retURL);
              pageContext.putSessionValue("ExecuteQuery", ExecuteQuery);
              pageContext.putSessionValue("ExecuteQueryReport", ExecuteQueryReport);
              // This code added to make the cursor busy after apply.
              OAWebBean body = pageContext.getRootWebBean();
              if (body instanceof OABodyBean)
              {
              ((OABodyBean)body).setBlockOnEverySubmit(true);
              }
              }

              /**
              * Procedure to handle form submissions for form elements in
              * a region.
              * @param pageContext the current OA page context
              * @param webBean the web bean corresponding to the region
              */
              public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
              {
              super.processFormRequest(pageContext, webBean);
                   System.out.println("Start the Controller");
              String SaveButton = (String)pageContext.getParameter("SaveNote");
              String CancelButton = (String)pageContext.getParameter("CancelNote");
              String NoteText = (String)pageContext.getParameter("NoteText");
              String NoteStatus = (String)pageContext.getParameter("NoteStatusID");
              String NoteType = (String)pageContext.getParameter("NoteTypeID");
              String Party = (String)pageContext.getParameter("ImcPartyId");
              String SourceSystem = (String)pageContext.getSessionValue("SourceSystem");
              String NewStatus = (String)pageContext.getSessionValue("NewStatus"); // This is working.
              String OldStatus = (String)pageContext.getSessionValue("OldStatus");
              String retURL = (String)pageContext.getSessionValue("retURL");
              String ExecuteQuery = (String)pageContext.getSessionValue("ExecuteQuery");
              String ExecuteQueryReport = (String)pageContext.getSessionValue("ExecuteQueryReport");

              System.out.println("THE OLD STATUS IS " + OldStatus + " New Stauts " + NewStatus);

              // System.out.println("The Note Type is " +NoteType);
              // System.out.println("The Party Cancelled is " + Party);
              String RespID = Integer.toString(pageContext.getResponsibilityId());
              String UserID = Integer.toString(pageContext.getUserId());

              OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
              Serializable[] params = {NoteText, RespID, UserID, Party, NoteStatus, NoteType};
              Serializable[] params1 = {Party, NewStatus, SourceSystem};


              if (CancelButton != null)
              { System.out.println("Inside Cancel");
              OAApplicationModule projectam = (OAApplicationModule)pageContext.getApplicationModule(webBean).findApplicationModule("ShipperOverviewAM1");
              projectam.invokeMethod("rollbackTransaction");
              CancelButton = null;
              // The user has clicked an "Cancel" icon so we want to navigate back keeping everything in Context.
              HashMap param = new HashMap();
              param.put("partyID", Party);
              param.put("ExecuteQueryReport", ExecuteQueryReport);
              param.put("SourceSystem", SourceSystem);
              param.put("ExecuteQuery", ExecuteQuery);
              param.put("retURL", retURL);
              pageContext.setForwardURL("OA.jsp?page=/xxksms/oracle/apps/imc/ksms/webui/ShipperOverviewPG"
              ,null
              ,OAWebBeanConstants.KEEP_MENU_CONTEXT
              , null
              , param
              ,true // Retain AM
              ,OAWebBeanConstants.ADD_BREAD_CRUMB_NO
              ,OAWebBeanConstants.IGNORE_MESSAGES);
              }
              else if(SaveButton !=null && ((NoteType.length() == 0 || (NoteText.length()==0 && !"".equals(NoteText.trim())))))
              {System.out.println("The Note Status is Null raise an error");
                String message = "You must enter a note and select a note type";
                  throw new OAException(message, OAException.ERROR);  }
              else if (SaveButton !=null && ((NoteType.length() > 0 && NoteText.length() > 0 && !"".equals(NoteText.trim()))))
              { System.out.println("Inside here Pressed Save Button");
              String returnValue = (String)am.invokeMethod("addNotes", params);
              //if (a != null && !"".equals(a.trim()))
              // Put an if condition here. Only commit if the Notes return a "S" otherwise throw an exception.
              if (returnValue.equals("S"))
              {  OAApplicationModule projectam = (OAApplicationModule)pageContext.getApplicationModule(webBean).findApplicationModule("ShipperOverviewAM1");
              projectam.invokeMethod("UpdateStatus", params1);
              // projectam.invokeMethod("commitTransaction");
              System.out.println("Commit Transaction Done.");

              MessageToken[] tokens =
              { new MessageToken("NEWSTATUS", NewStatus),
              new MessageToken("OLDSTATUS", OldStatus),
              };
              String MainUrl = "OA.jsp?page=/xxksms/oracle/apps/imc/ksms/webui/ShipperOverviewPG&retainAM=Y&ImcPartyId="+Party+"&ExecuteQueryReport="+ExecuteQueryReport+"&SourceSystem="+SourceSystem+"&ExecuteQuery="+ExecuteQuery+"&retURL="+retURL;
              OAException descMesg = new OAException("XXTSA", "XX_KSMS_SAVED_NOTES", tokens);
              OADialogPage dialogPage = new OADialogPage(OAException.INFORMATION, descMesg, null, MainUrl, null);
              pageContext.redirectToDialogPage(dialogPage);
              }
              else
              {   OAApplicationModule projectam = (OAApplicationModule)pageContext.getApplicationModule(webBean).findApplicationModule("ShipperOverviewAM1");
              projectam.invokeMethod("rollbackTransaction");
              System.out.println("Rollback Executed ");
              String MainUrl = "OA.jsp?page=/xxksms/oracle/apps/imc/ksms/webui/ShipperOverviewPG&retainAM=Y&ImcPartyId="+Party+"&ExecuteQueryReport="+ExecuteQueryReport+"&SourceSystem="+SourceSystem+"&ExecuteQuery="+ExecuteQuery+"&retURL="+retURL;
              OAException descMesg = new OAException("XXTSA", "XX_KSMS_ERROR_NOTES");
              OADialogPage dialogPage = new OADialogPage(OAException.INFORMATION, descMesg, null, MainUrl, null);
              pageContext.redirectToDialogPage(dialogPage);
              }
              // OAApplicationModule rootam = pageContext.getRootApplicationModule();

              //am.invokeMethod("commitTransaction");
              // System.out.println("Inside Save");
              // Try build your own Dialog Page here....

              /*String MainUrl = "OA.jsp?page=/xxksms/oracle/apps/imc/ksms/webui/ShipperOverviewPG&retainAM=Y&ImcPartyId="+Party;
              OAException descMesg = new OAException("XXTSA", "XX_KSMS_SAVED_NOTES");
              OADialogPage dialogPage = new OADialogPage(OAException.INFORMATION, descMesg, null, MainUrl, null);

              // This should take us to and OK Button after pressing the User should go back to Shipper Page. */

              }
              }

              }
              • 4. Re: Text getting cleared after throwing OAException message
                505001
                Can anyone suggest me a solution for this ?

                Thanks
                • 5. Re: Text getting cleared after throwing OAException message
                  1013533
                  I have the same issue , is there Can anyone with a solutions

                  Thanks
                  • 6. Re: Text getting cleared after throwing OAException message
                    ViswanathChandran

                    Hi,

                     

                    Enable PPR for the text field. Then as you tab out,the value will be set to the view attributes and the value will not be cleared while throwing an exception.

                     

                    On click of cancel,i hope you don't commit the data and hence that should be null when you return to the same page/record again.

                     

                    Thanks,

                    Viswanath