Results 1 to 3 of 3

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

  1. #1

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

    With the following code:
    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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Is this the expected behavior?
    Yes...

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    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:

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •