You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shivani Sawhney <sh...@netedgecomputing.com> on 2005/12/03 08:51:41 UTC

Preserving the query string while validating a form & using dynamic initialization with DynaAction

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


Re: Preserving the query string while validating a form & using dynamic initialization with DynaAction

Posted by Raghu Kanchustambham <kr...@gmail.com>.
> 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 <sh...@netedgecomputing.com> 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
>
>
>