-1

It is displaying below when I use below code but I want it respective error message after respective field `

<dsp:droplet name="/atg/dynamo/droplet/Switch">
<dsp:param bean="/com/atg/ProductFormHandler.formError" name="value"/>
<dsp:oparam name="true">
  <font color=cc0000><STRONG><UL>
    <dsp:droplet name="/atg/dynamo/droplet/ErrorMessageForEach">
      <dsp:param bean="/com/atg/ProductFormHandler.formExceptions" name="exceptions"/>
      <dsp:oparam name="output">
     <LI> <dsp:valueof param="message"/>
      </dsp:oparam>
    </dsp:droplet>
    </UL></STRONG></font>
</dsp:oparam>
</dsp:droplet>

`

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
OVP10
  • 3
  • 2

1 Answers1

1

Apart from the output param, message, ErrorMessageForEach droplet has another output parameter, propertyName that indicates the form handler property associated with the current error message.

You can make use of this parameter to display the error message after/before the respective input field.

Add each error message to a Map with the propertyName as Key while iterating error messages using ErrorMessageForEach. While displaying each input field, you can get the corresponding error message from this map (if any) and display it in the front end.

OR

Instead of ErrorMessageForEach droplet, write a new droplet to accept the formExceptions as input parameter and outputs a map of error messages with propertyNames as keys. Each object in the formExceptions will be an object of DropletFormException, which will have the propertyName. (If you are displaying the error messages of a custom form handler, then make sure that the propertyName is specified while creating the DropletFormException.)

OR

While iterating through ErrorMessageForEach, instead of displaying the error message, hold each error message in different jstl variables and use these variables to display the error message for the respective fields. You can make use of propertyName parameter to differentiate the error messages.

Riju Thomas
  • 331
  • 3
  • 4