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
<validators>
...
  <field name="user">
       <field-validator type="visitor">
          <param name="context">myContext</param>
          <param name="appendPrefix">true</param>
       </field-validator>
    </field>
</validators>
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..
  <field name="user">
       <field-validator type="visitor">
          <param name="appendPrefix">true</param>
          <param name="validator_filename">User-myContext-validation.xml</param>
       </field-validator>
    </field>
</validators>

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:
> >
> > <s:form action="editPerson" theme="simple" validate="false">
> >    <table>
> >        <tr>
> >            <th>ID</th>
> >            <th>First Name</th>
> >            <th>Last Name</th>
> >        </tr>
> >        <s:iterator id="p" value="persons">
> >            <tr>
> >                <td>
> >                    <s:property value="%{id}" />
> >                </td>
> >                <td>
> >                    <s:textfield label="First Name" 
> > name="persons(%{id}).name" value="%{name}" theme="simple" />
> >                </td>
> >                <td>
> >                    <s:textfield label="Last Name" 
> > name="persons(%{id}).lastName" value="%{lastName}" theme="simple"/>
> >                </td>
> >            </tr>
> >        </s:iterator>
> >    </table>
> >
> >    <s:submit method="save" value="Save all persons"/>
> > </s:form>
> >
> >
> >
> > 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

Reply via email to