Announcement Announcement Module
No announcement yet.
<form:errors> tag seems to be appending commandName? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • <form:errors> tag seems to be appending commandName?

    With the following code:
    <form:form path="cmd" commandName="cmd" action="doStuff.action" >
    		<form:errors path="*" cssClass="error"/>
    In my controller if I use errors.reject("Some message"), the page is instead displaying with; "Some message.cmd"

    Is this the expected behavior? Can it be changed?

  • #2
    Is this the expected behavior?

    Can it be changed?
    No... I suggest a read of the reference guide and the API docs.

    In short the method you use takes a code NOT a message. codes are resolved using a MessageSource. If you want to hard code the message in your code use the appropriate reject method (the one that takes a code AND a default message).


    • #3
      Thanks Marten, this makes sense seeing the API docs. What I was trying to accomplish was to reject with an exception message (which can be variable since I am catching a generic type of exception).

      What I did to still allow this is create a message code with a parameter:
      ERROR.MESSAGE=It crashed! Details: {0}

      and then using the reject method which takes parameters:

      errors.reject("ERROR.MESSAGE", new Object[] { e.getMessage(); }, null);
      Thanks for your help.