Hi,

Thanks so much Martin.........but I am not trying to validate a date
field, I am actually trying to give a dynamic initial value to a text
box through struts-config.xml.

<form-property name="date" type="java.lang.String"
initial="rd.admin.DateFormat.getDate()"/>


Regards,

Shivani

 

-----Original Message-----
From: Martin Gainty [mailto:[EMAIL PROTECTED] 
Sent: 03 December, 2005 8:20 PM
To: Struts Users Mailing List
Subject: Re: Preserving the query string while validating a form & using
dynamic initialization with DynaAction

Good Morning Shivani/Raghu

Assuming the date for the QueryString is a valid date
following the tutorial for date-validation with struts validator at
http://www.roseindia.net/strutstutorial/usingstrutsvalidatorframewor.sht
ml

in your "form" capture the date information in a html:text tag e.g.
DATE: <html:text  property="date"/>

we have a string which needs to be transformed and validated to
well-formed 
date
we can use field level datePattern validation of "MM/dd/yyyy" to
validate 
the form value before attempting a populate e.g.
 <field     property="date"
               depends="required,date">
        <arg0 key="form.date"  />
        <var>
              <var-name>datePattern</var-name>
              <var-value>MM/dd/yyyy</var-value>
        </var>
</field>

Anyone else?
M-

----- Original Message ----- 
From: "Shivani Sawhney" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Saturday, December 03, 2005 4:32 AM
Subject: RE: Preserving the query string while validating a form & using

dynamic initialization with DynaAction



So Sorry, Raghu!
The option (a) for Query 1 actually works............ Thanks a ton!

In set up action, I was trying to get the values through
"request.getParameter("id0")", changing it to "form.get("id0")" worked.


About the 2nd query, when I write,

<form-property name="date" type="java.lang.String"
initial="rd.admin.DateFormat.getDate()"/>

..the text box displays "rd.admin.DateFormat.getDate()" literally. Is
there any way that I could get the form value to be evaluated rather
than just outputting it as is?

Regards,

Shivani




-----Original Message-----
From: Raghu Kanchustambham [mailto:[EMAIL PROTECTED]
Sent: 03 December, 2005 1:35 PM
To: Struts Users Mailing List
Subject: Re: Preserving the query string while validating a form & using
dynamic initialization with DynaAction

> Query 1:

There are two approaches I can think of right now. You will need to
"burn"
this querystring information into (a) the form object   or (b) the
session.

(a) If you are using dynaction form, then just adding another variable
to
hold the id0 in the config.xml definition should be less painful. But
even
if you are using the regular "typed" action form, then also it should
not be
too much of a trouble to add the extra parameter. You can then map this
parameter to a hidden variable in your jsp.

(b) Instead of reading the variable form querystring/request object,
burn it
in to the session and read it from there. You could have a helper
function (
a getId0( ) ) which checks if the variable is in the query string then
it
returns from the request object, else it should look up the session.
Prevalidation, it would find it in the the request object, post
validation
it can pick it up from the session. Be aware that the drawback of this
approach is that the user may have contamination of this variable if she
opens another window from the same browser (like a Ctrl N in internet
explorer) which will share the same cookie and hence the same session.
But
this is true in all cases where you use session scoped variables.

>Query 2:

I doubt if you could do that! The xml config files are fairly static in
my
opinion. But I am just guessing.


HTH,
Raghu

On 12/3/05, Shivani Sawhney <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
>
>
> Can someone please help solve the following problems?
>
>
>
> Query 1:
>
>
>
> I am trying to access an action through a hyperlink and provide some
> parameters through query string. This action forwards to a JSP, whose
> URL reads something like
> http://servername:port/rd/masters/SetupEditJobProfileAction.do?id0=13.
I
> have added validations on this JSP through DynaValidator Framework.
Now
> if the user feeds some incorrect input, the user is taken to the same
> JSP with the errors listed but the URL doesn't have the query string
> attached anymore, i.e., the URL becomes something like,
> http://servername:port/rd/masters/SetupEditJobProfileAction.do which
is
> causing errors in my code.
>
>
>
> Could someone please suggest how to keep the query string (request
> parameters) intact even when validation errors are caught and
displayed
> on the JSP?
>
>
>
>
>
> Query 2:
>
> Can I use user defined classes while initializing form fields using
Dyna
> Action?
>
> E.g., Can I write something like,
>
> <form-bean name="ChangePasswordForm"
> type="org.apache.struts.validator.DynaValidatorForm">
>
>      <form-property name="date" type="java.lang.String"
> initial="rd.admin.DateFormat.getDate()"/>
>
>
>
> Any help will be much appreciated.
>
> Thanks in advance.
>
> Regards,
>
> Shivani
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to