7 Replies Latest reply: Sep 13, 2012 5:44 AM by RMishra RSS

    how to print our custom message in jsp page

    333
      i have used the below line, but its not displaying in jsp
      addFormException(new DropletException("Out Of Stock"));




      regards
      shya
        • 1. Re: how to print our custom message in jsp page
          Gopinath Ramasamy
          1. Make sure that your form handler extends GenericFormHandler (This FH defines formError and formExceptions Vector).
          2. When you add form exceptinos in your FH, set the formError flag as true.
          3. In the jsp, check for the form error flag, if it is set, iterate through the formExceptions vector and display the error message.
          Below is the sample code:

          <dsp:droplet name="/atg/dynamo/droplet/Switch">
               <dsp:param bean="MyFormHandler.formError" name="value"/>
               <dsp:oparam name="true">
               <dsp:droplet name="/atg/dynamo/droplet/ErrorMessageForEach">
               <dsp:param bean="MyFormHandler.formExceptions" name="exceptions"/>
               <dsp:oparam name="output">
               <dsp:valueof param="message" />
          </dsp:oparam>
          </dsp:droplet>
          </dsp:oparam
          </dsp:droplet>

          If it is not working even after the above steps, request you to provide some more details including your display logic in jsp.

          Edited by: Gopinath Ramasamy on Sep 12, 2012 5:06 PM
          • 2. Re: how to print our custom message in jsp page
            333
            i have used error message for each , but its not displaying,
            • 3. Re: how to print our custom message in jsp page
              Praveer.Rai
              Print these values in JSP and check :

              MyFormHandler.formError

              MyFormHandler.formExceptions
              • 4. Re: how to print our custom message in jsp page
                Samdani Gulam
                Have you tried this way as Gopinath posted in your jsp ?

                <dsp:droplet name="/atg/dynamo/droplet/ErrorMessageForEach">
                <dsp:param bean="MyFormHandler.formExceptions" name="exceptions"/>
                <dsp:oparam name="output">
                <dsp:valueof param="message"/>
                </dsp:oparam>
                </dsp:droplet>

                Try to print what Praveer is suggesting, or if you want to debug the code and check whether your DropletExceptions is being added or not then call getFormError() and getFormExceptions() from your method to see what values you are getting.


                my suggestion would be to create message repository and versioned it so that to avoid the hard coding of exceptions in formhandlers.

                Edited by: sampro07 on Sep 12, 2012 10:42 PM
                • 5. Re: how to print our custom message in jsp page
                  Praveer.Rai
                  Hi Samdani,
                  create message repository and versioned it so that to avoid the hard coding of exceptions in formhandlers.
                  Can you shed more light on this on how you implemented it , it will be helpful :)

                  ~ Praveer
                  • 6. Re: how to print our custom message in jsp page
                    Samdani Gulam
                    Create a normal repository and make it versioned.

                    in formhandler call like this

                    addFormException(new DropletException(getMessageTools().getMessage("missingField", DEFAULT_MESSAGE_CODE), "firstName"));
                    addFormException(new DropletException(getMessageTools().getMessage("missingField", DEFAULT_MESSAGE_CODE), "lastName"));

                    MessageTools#getMessage(String code, String defaultCode)

                    MessageTools I have written to fetch the repository item , MessageDroplet to display the messages on jsp.

                    Email me if you want to see my implementation.

                    Thanks,

                    Edited by: sampro07 on Sep 13, 2012 1:45 AM
                    • 7. Re: how to print our custom message in jsp page
                      RMishra
                      Hi in your xxxFormHandler.properties set parameter loggingDebug=true and add exception like
                      if(isLoggingDebug()){
                      System.out.println("excetion added");
                      addFormException(new DropletException("exception ......."));
                      }
                      it may help to check if it is adding..
                      -Also check carefully names of formhandler and component it may have small/captal letter mistake.
                      -RMishra