Results 1 to 4 of 4

Thread: globalError get the message in ResourceBundleMessageSource

  1. #1
    Join Date
    Aug 2004
    Posts
    25

    Default globalError get the message in ResourceBundleMessageSource

    Hi,

    In my form, I ve 2 date fields which I define a "From" date and a "To" date.
    When the user give a "From" date greater than the "To" date, I would like to throw an error.

    So in my validator, I have :
    Code:
    public void validate(Object object, Errors errors) {
    		SomeObject so = (SomeObject ) object;
    		Date date1 = so .getDateBegin();
    		Date date2 = so .getDateEnd();
    		if (null != date1 && null != date2 && date1.getTime() > date2.getTime()) {
    			errors.reject("wrong dates",
    					"The From date can not be greater than the To date");
    		}
    	}
    And in my jsp I have :
    Code:
    <spring&#58;hasBindErrors name="command">
    <c&#58;out value="$&#123;errors.globalError.defaultMessage&#125;" />
    </spring&#58;hasBindErrors>
    In my JSP, I take the first globalError (there could be only one), but I ve seen in the API that I can only display the default message with the method "getDefaultMessage" (the one defined in the validator) and not the one defined in the ResourceBundleMessageSource with the code "wrong dates".

    Is there a way to display the message defined in the ResourceBundleMessageSource ?

    bye
    We are a football tribe!

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Yes. Try,
    Code:
    <spring&#58;bind path="command">
      <c&#58;out value="$&#123;status.errorMessage&#125;"/>
    </spring&#58;bind>
    Also, the error code (property key) shouldn't have whitespace. Try changing it to:
    Code:
    wrongDates

  3. #3
    Join Date
    Aug 2004
    Posts
    25

    Default

    Hi,

    Thx for your answer katentim, it works well

    But I have another problem :

    The "wrongDates" error should be thrown and displayed in my web page only when I have 2 valid dates and "From date" > "To date".
    But when I have this error displayed and then I fill a wrong date (like "aaa" instead of a valid date like "20/01/2004"), the field error is displayed (this is normal) but the "wrongDates" error is still displayed too.. :?

    How can I made this error not to be displayed when I have an "invalid date" error?
    We are a football tribe!

  4. #4
    Join Date
    Aug 2004
    Posts
    25

    Default

    Hi,

    In my form controller, I have removed this lines as I don't need session:
    Code:
    public ETradeQuoteController&#40;&#41; &#123;
      setSessionForm&#40;true&#41;;
    &#125;
    And all works well! 8)
    We are a football tribe!

Similar Threads

  1. Message Bundle - No Message Found exception
    By arumugamkasi in forum Web
    Replies: 18
    Last Post: Jun 20th, 2011, 04:24 AM
  2. UpgradeAcegi Security System from 0.6.1 to 0.8.3
    By mannobug in forum Security
    Replies: 3
    Last Post: Sep 23rd, 2005, 07:00 PM
  3. How to display message about last action?
    By pir8ped in forum Architecture
    Replies: 8
    Last Post: Jun 6th, 2005, 11:01 AM
  4. Channel and message transformation question
    By Alarmnummer in forum Architecture
    Replies: 12
    Last Post: May 11th, 2005, 05:06 PM
  5. Displaying Error from message resource
    By qtipz4ever in forum Web
    Replies: 3
    Last Post: Mar 16th, 2005, 04:48 PM

Posting Permissions

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