You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <as...@gmail.com> on 2007/08/31 21:17:04 UTC

Validation using validation.xml issue

Hi
I have a defined following bean in struts-config.xml
<form-property name="color" type="java.lang.String" />
<form-property name="datereqList" type="java.util.List" />

In my action class i set datereqList and pass it along to the jsp, the jsp
displays it as drop down box,
in my validtion.xml i am checking to make sure that color is not blank,
So when validation finds that color is blank it send response to the jsp
page, but now datereqList is not in request, since it is lost.

What is the best way to solve it, should i put datereqList in session?


Ashish

Re: Validation using validation.xml issue

Posted by Laurie Harper <la...@holoweb.net>.
When the validator framework encounters an error, it forwards the 
request to the resource you identify with your 'input' attribute on the 
action mapping. I was suggesting making that point to an action, and 
using *that* action to load the lists.

L.

Ashish Kulkarni wrote:
> Hi
> The error is thrown by validator frame work, and hence it never reaches
> action class where i can load those list again,
> I am not very sure how validtor framework works
> 
> Ashish
> 
> On 8/31/07, Laurie Harper <la...@holoweb.net> wrote:
>> Ashish Kulkarni wrote:
>>> Hi
>>> I have a defined following bean in struts-config.xml
>>> <form-property name="color" type="java.lang.String" />
>>> <form-property name="datereqList" type="java.util.List" />
>>>
>>> In my action class i set datereqList and pass it along to the jsp, the
>> jsp
>>> displays it as drop down box,
>>> in my validtion.xml i am checking to make sure that color is not blank,
>>> So when validation finds that color is blank it send response to the jsp
>>> page, but now datereqList is not in request, since it is lost.
>>>
>>> What is the best way to solve it, should i put datereqList in session?
>> It sounds like you have your action's 'input' property pointing directly
>> at the JSP. Your best bet is to have two action mappings, one for
>> displaying the form and one for processing it on submission. Then set
>> the second mapping's 'input' to point to the first mapping. Now,
>> whenever the form is displayed -- either initially, or following
>> validation errors -- the form-display action will be called, giving you
>> a place to load the list into the form.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation using validation.xml issue

Posted by Ashish Kulkarni <as...@gmail.com>.
Hi
The error is thrown by validator frame work, and hence it never reaches
action class where i can load those list again,
I am not very sure how validtor framework works

Ashish

On 8/31/07, Laurie Harper <la...@holoweb.net> wrote:
>
> Ashish Kulkarni wrote:
> > Hi
> > I have a defined following bean in struts-config.xml
> > <form-property name="color" type="java.lang.String" />
> > <form-property name="datereqList" type="java.util.List" />
> >
> > In my action class i set datereqList and pass it along to the jsp, the
> jsp
> > displays it as drop down box,
> > in my validtion.xml i am checking to make sure that color is not blank,
> > So when validation finds that color is blank it send response to the jsp
> > page, but now datereqList is not in request, since it is lost.
> >
> > What is the best way to solve it, should i put datereqList in session?
>
> It sounds like you have your action's 'input' property pointing directly
> at the JSP. Your best bet is to have two action mappings, one for
> displaying the form and one for processing it on submission. Then set
> the second mapping's 'input' to point to the first mapping. Now,
> whenever the form is displayed -- either initially, or following
> validation errors -- the form-display action will be called, giving you
> a place to load the list into the form.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Validation using validation.xml issue

Posted by Laurie Harper <la...@holoweb.net>.
Ashish Kulkarni wrote:
> Hi
> I have a defined following bean in struts-config.xml
> <form-property name="color" type="java.lang.String" />
> <form-property name="datereqList" type="java.util.List" />
> 
> In my action class i set datereqList and pass it along to the jsp, the jsp
> displays it as drop down box,
> in my validtion.xml i am checking to make sure that color is not blank,
> So when validation finds that color is blank it send response to the jsp
> page, but now datereqList is not in request, since it is lost.
> 
> What is the best way to solve it, should i put datereqList in session?

It sounds like you have your action's 'input' property pointing directly 
at the JSP. Your best bet is to have two action mappings, one for 
displaying the form and one for processing it on submission. Then set 
the second mapping's 'input' to point to the first mapping. Now, 
whenever the form is displayed -- either initially, or following 
validation errors -- the form-display action will be called, giving you 
a place to load the list into the form.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org