struts validations

Hi

when am using the srtuts validator form(twin xml files) for my validations, the error messages which gets displayed like(email id not valid) is taken from the .properties file which i use..

but in the above messsage.. email id is hardcoded in the validation.xml..(<arg0 key=email id>)

Instead i want whatever i type to be captured and say for instance.. abcd not valid. usually we get the values from request object and capture the user input.. when am using struts how to do this? please help

[527 byte] By [cooljavaa] at [2007-10-2 15:42:52]
# 1

IF I understand you correctly (and I am not sure I do) construct your error message (in your properties file) using replacement strings, as "{0} not valid". Then use the ActionMessage constructor that takes a key and a String so you say something like:ActionMessage error = new ActionMessage(key, "abc");

As an aside - why did you choose this forum to post this question in?

Good Luck

Lee

tsitha at 2007-7-13 15:31:33 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
thx lee.. ya.. i got wat u said. but still u hardcode tat "abc" in ur Action Message. I want a dynamic message which is able to capture whatever i type..not just 'abc'.. how to give it in properties file..ok..by the way under which forum shud i post struts questions,,,,
cooljava2a at 2007-7-13 15:31:33 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> thx lee.. ya.. i got wat u said. but still u hardcode

> tat "abc" in ur Action Message. I want a dynamic

> message which is able to capture whatever i type..not

> just 'abc'.. how to give it in properties file..

Your validate method is inside your ActionForm class, which has access to all the current field values. Assuming the field that you are validating is called "someFormInput" then you would say something like:ActionMessage error = new ActionMessage(key, this.getSomeFormInput());

>

> ok..by the way under which forum shud i post struts

> questions,,,,

There's the struts-dev list:

http://struts.apache.org/mail.html

Or, you could try JavaRanch''s Struts forum

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=58

or the JSP forum here

http://forum.java.sun.com/forum.jspa?forumID=45

or even the "catch-all" Java Programming forum here

http://forum.java.sun.com/forum.jspa?forumID=31

Good luck

Lee

tsitha at 2007-7-13 15:31:33 > top of Java-index,Other Topics,Patterns & OO Design...