Re: Struts2 Collection validation

2010-05-25 Thread harpreet

Hi,
I am new to the Struts2 and facing the similar issue , 
u said u have managed to get the data from the dynmically  generated fields
to the action , can u share how it can be done...a sample will be of
great help...
my requirment is my form is dynamically generat the fileds for name date and
amount and it could raneg from one to man fields how would i get the details
of the form data in my actions  bcoz i am not sure how many  fields will
be filled out .


Thanks you 
java.harpr...@gmail.com


Julio Alberto Jalón wrote:
> 
> 
> May I didn't explain myself correctly. What I would like to know is how to
> validate multiple fields.  I'll write an example. I have a form in a JSP
> which generate the field dynamically. E.g: 
> 
> 
> 
> 
> ID
> First Name
> Last Name
> 
> 
> 
> 
> 
> 
> 
>  name="persons(%{id}).name" value="%{name}" theme="simple" />
> 
> 
>  name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Where person is a List in the action class. Now, what I would like to know
> is how could I achieve this fields to be validated. For example, I would
> like that if the name is filled the last name should be also filled and
> both can only contains letters and blanks. 
> 
> Well, I don't want you to give me the complete solution ( the expresion or
> reg expresion), just want to know how I can refer all these fields from
> the MyActionClass-validation.xml. 
> 
> Hope I've explained better than in the first post.
> 
> Please, help me.
> 
> Thanks in advance.
> 
> 
> - Mensaje original 
> De: Julio Alberto Jalón 
> Para: user@struts.apache.org
> Enviado: miércoles, 15 de octubre, 2008 12:32:05
> Asunto: Struts2 Collection validation
> 
> 
> I'm learning struts2 through the struts2-showcase application example.
> From the "Person Manager" functionality I've learned how to send multiples
> values from client to server using collections to manage these values, but
> now I'd like to know how to validate these values using struts2
> validation. I don't know what to put in *-validation.xml in order to
> validate these values. Should I use custom validation?
> 
> Thanks in advance.
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Struts2-Collection-validation-tp19991675p28674052.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Struts2 Collection validation

2008-10-30 Thread fgsantoyo

If you want  to validate generated fields, i mean a Collection you can do
something like this.

* Action class
private List collection;

public void setCollection(String collection) {
this.collection = collection;
}

public String getCollection() {
return collection;
}

 List list = this.getCollection() ; 
for (int i = 0; i < list.size(); i++) {
if(list.get(i).equals(""))
addFieldError("collection[" + i + " ]
",getText("validation.required")); 


}
by fgsantoyo

Julio Alberto Jalón wrote:
> 
> 
> I'm learning struts2 through the struts2-showcase application example.
> From the "Person Manager" functionality I've learned how to send multiples
> values from client to server using collections to manage these values, but
> now I'd like to know how to validate these values using struts2
> validation. I don't know what to put in *-validation.xml in order to
> validate these values. Should I use custom validation?
> 
> Thanks in advance.
> 
> 
> 
>
> 

-- 
View this message in context: 
http://www.nabble.com/Struts2-Collection-validation-tp19991675p20255180.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



RE: Struts2 Collection validation

2008-10-20 Thread Néstor Boscán
>From what I have investigated 6 months ago there is no validation for 
>collections. I think I even tested that you can create validators for 
>employees[0].firstName, employees[1].lastName, but not something that will 
>apply to all indexes. I even posted if it was possible to add expressions to 
>the fieldname so I can apply a validator form employees[.*].firstName. For my 
>projects this is the most required missing functionality of Struts 2.

Regards,

Néstor Boscán

-Mensaje original-
De: gaelle [mailto:[EMAIL PROTECTED] 
Enviado el: Monday, October 20, 2008 9:59 AM
Para: user@struts.apache.org
Asunto: Re: Struts2 Collection validation


I hope there exists a simpler solution, but here is my workaround: use an
expression validator.
This idea was taken from 
http://www.opensymphony.com/webwork/wikidocs/collection%20validator.html
webwork wiki: collection validator  (it seems that the collection validator
is not yet available in struts).

For example, if you want to say that lastName is a requiredString, then you
can create an expression validator like this:


   persons.{#this.lastName.length() > 0}.{? #this == false }.size() <= 0
   lastName cannot be empty
 

which means: the size of the sub-collection of persons that does not satisfy
the condition "lastName.length>0"  must be <=0.



Julio Alberto Jalón wrote:
> 
> 
> May I didn't explain myself correctly. What I would like to know is how to
> validate multiple fields.  I'll write an example. I have a form in a JSP
> which generate the field dynamically. E.g: 
> 
> 
> 
> 
> ID
> First Name
> Last Name
> 
> 
> 
> 
> 
> 
> 
>  name="persons(%{id}).name" value="%{name}" theme="simple" />
> 
> 
>  name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Where person is a List in the action class. Now, what I would like to know
> is how could I achieve this fields to be validated. For example, I would
> like that if the name is filled the last name should be also filled and
> both can only contains letters and blanks. 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts2-Collection-validation-tp19991675p20068978.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
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]



Re: Struts2 Collection validation

2008-10-20 Thread gaelle

I hope there exists a simpler solution, but here is my workaround: use an
expression validator.
This idea was taken from 
http://www.opensymphony.com/webwork/wikidocs/collection%20validator.html
webwork wiki: collection validator  (it seems that the collection validator
is not yet available in struts).

For example, if you want to say that lastName is a requiredString, then you
can create an expression validator like this:


   persons.{#this.lastName.length() > 0}.{? #this == false }.size() <= 0
   lastName cannot be empty
 

which means: the size of the sub-collection of persons that does not satisfy
the condition "lastName.length>0"  must be <=0.



Julio Alberto Jalón wrote:
> 
> 
> May I didn't explain myself correctly. What I would like to know is how to
> validate multiple fields.  I'll write an example. I have a form in a JSP
> which generate the field dynamically. E.g: 
> 
> 
> 
> 
> ID
> First Name
> Last Name
> 
> 
> 
> 
> 
> 
> 
>  name="persons(%{id}).name" value="%{name}" theme="simple" />
> 
> 
>  name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Where person is a List in the action class. Now, what I would like to know
> is how could I achieve this fields to be validated. For example, I would
> like that if the name is filled the last name should be also filled and
> both can only contains letters and blanks. 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts2-Collection-validation-tp19991675p20068978.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



RE: Struts2 Collection validation

2008-10-16 Thread Martin Gainty

thanks for the links gabriele
If I had to make a suggestion to the xwork committers I would suggest their 
attribute configurations be a bit more specific 
so instead of Login-validation.xml configured as

...
  
   
  myContext
  true
   


where by magic incantation and algorithmic manipulation a user object would 
reference field validations from
User-myContext-validation.xml

but is'nt this a bit more user-friendly..
  
   
  true
  User-myContext-validation.xml
   



this way a build / release manager can 'scan' the configuration file and 
understand this validator must be in the distro
vs
waiting for the app to be deployed to production and unsuspecting op gets NPE 
and then an email is posted to struts users
?

Thanks
Martin 
__ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business 
of Sender. This transmission is of a confidential nature and Sender does not 
endorse distribution to any party other than intended recipient. Sender does 
not necessarily endorse content contained within this transmission. 


> Date: Thu, 16 Oct 2008 10:19:05 -0300
> From: [EMAIL PROTECTED]
> To: user@struts.apache.org
> Subject: Re: Struts2 Collection validation
> 
> You may want to look at type conversion [1] and VisitorValidator [2]
> to validate those form fields.
> 
> Also, please note that collection indexing is done with [square]
> brackets, like in: "persons[2].name"
> 
> [1] 
> http://struts.apache.org/2.1.2/docs/type-conversion.html#TypeConversion-AnadvancedexampleforindexedListsandMaps
> [2] http://struts.apache.org/2.1.2/docs/visitor-validator.html
> 
> 2008/10/16 Julio Alberto Jalón <[EMAIL PROTECTED]>:
> >
> > May I didn't explain myself correctly. What I would like to know is how to 
> > validate multiple fields.  I'll write an example. I have a form in a JSP 
> > which generate the field dynamically. E.g:
> >
> > 
> >
> >
> >ID
> >First Name
> >Last Name
> >
> >
> >
> >
> >
> >
> >
> > > name="persons(%{id}).name" value="%{name}" theme="simple" />
> >
> >
> > > name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
> >
> >
> >
> >
> >
> >
> > 
> >
> >
> >
> > Where person is a List in the action class. Now, what I would like to know 
> > is how could I achieve this fields to be validated. For example, I would 
> > like that if the name is filled the last name should be also filled and 
> > both can only contains letters and blanks.
> >
> > Well, I don't want you to give me the complete solution ( the expresion or 
> > reg expresion), just want to know how I can refer all these fields from the 
> > MyActionClass-validation.xml.
> >
> > Hope I've explained better than in the first post.
> >
> > Please, help me.
> >
> > Thanks in advance.
> >
> >
> > - Mensaje original 
> > De: Julio Alberto Jalón <[EMAIL PROTECTED]>
> > Para: user@struts.apache.org
> > Enviado: miércoles, 15 de octubre, 2008 12:32:05
> > Asunto: Struts2 Collection validation
> >
> >
> > I'm learning struts2 through the struts2-showcase application example. 
> > >From the "Person Manager" functionality I've learned how to send multiples 
> > values from client to server using collections to manage these values, but 
> > now I'd like to know how to validate these values using struts2 validation. 
> > I don't know what to put in *-validation.xml in order to validate these 
> > values. Should I use custom validation?
> >
> > Thanks in advance.
> >
> >
> >
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

_
Store, manage and share up to 5GB with Windows Live SkyDrive.
http://skydrive.live.com/welcome.aspx?provision=1?ocid=TXT_TAGLM_WL_skydrive_102008

Re: Struts2 Collection validation

2008-10-16 Thread Gabriel Belingueres
You may want to look at type conversion [1] and VisitorValidator [2]
to validate those form fields.

Also, please note that collection indexing is done with [square]
brackets, like in: "persons[2].name"

[1] 
http://struts.apache.org/2.1.2/docs/type-conversion.html#TypeConversion-AnadvancedexampleforindexedListsandMaps
[2] http://struts.apache.org/2.1.2/docs/visitor-validator.html

2008/10/16 Julio Alberto Jalón <[EMAIL PROTECTED]>:
>
> May I didn't explain myself correctly. What I would like to know is how to 
> validate multiple fields.  I'll write an example. I have a form in a JSP 
> which generate the field dynamically. E.g:
>
> 
>
>
>ID
>First Name
>Last Name
>
>
>
>
>
>
>
> value="%{name}" theme="simple" />
>
>
> name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
>
>
>
>
>
>
> 
>
>
>
> Where person is a List in the action class. Now, what I would like to know is 
> how could I achieve this fields to be validated. For example, I would like 
> that if the name is filled the last name should be also filled and both can 
> only contains letters and blanks.
>
> Well, I don't want you to give me the complete solution ( the expresion or 
> reg expresion), just want to know how I can refer all these fields from the 
> MyActionClass-validation.xml.
>
> Hope I've explained better than in the first post.
>
> Please, help me.
>
> Thanks in advance.
>
>
> - Mensaje original 
> De: Julio Alberto Jalón <[EMAIL PROTECTED]>
> Para: user@struts.apache.org
> Enviado: miércoles, 15 de octubre, 2008 12:32:05
> Asunto: Struts2 Collection validation
>
>
> I'm learning struts2 through the struts2-showcase application example. From 
> the "Person Manager" functionality I've learned how to send multiples values 
> from client to server using collections to manage these values, but now I'd 
> like to know how to validate these values using struts2 validation. I don't 
> know what to put in *-validation.xml in order to validate these values. 
> Should I use custom validation?
>
> Thanks in advance.
>
>
>

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



Re: Struts2 Collection validation

2008-10-16 Thread Julio Alberto Jalón

May I didn't explain myself correctly. What I would like to know is how to 
validate multiple fields.  I'll write an example. I have a form in a JSP which 
generate the field dynamically. E.g: 




ID
First Name
Last Name





















Where person is a List in the action class. Now, what I would like to know is 
how could I achieve this fields to be validated. For example, I would like that 
if the name is filled the last name should be also filled and both can only 
contains letters and blanks. 

Well, I don't want you to give me the complete solution ( the expresion or reg 
expresion), just want to know how I can refer all these fields from the 
MyActionClass-validation.xml. 

Hope I've explained better than in the first post.

Please, help me.

Thanks in advance.


- Mensaje original 
De: Julio Alberto Jalón <[EMAIL PROTECTED]>
Para: user@struts.apache.org
Enviado: miércoles, 15 de octubre, 2008 12:32:05
Asunto: Struts2 Collection validation


I'm learning struts2 through the struts2-showcase application example. From the 
"Person Manager" functionality I've learned how to send multiples values from 
client to server using collections to manage these values, but now I'd like to 
know how to validate these values using struts2 validation. I don't know what 
to put in *-validation.xml in order to validate these values. Should I use 
custom validation?

Thanks in advance.