You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by m Komma <mk...@gmail.com> on 2005/05/12 22:46:35 UTC

how to validate when the form-property is of type="java.lang.String[]"

Hi, 
I have a problem using validatorplugin for multiselection box.
my filed is of type <form-property name="departments"
type="java.lang.String[]" />

I can't validate when the form-property is of type="java.lang.String[]" 

I have the validation working correctly when form-property is of
type="java.lang.String".  I can't however validate when the
form-property is of type="java.lang.String[]".

any help is appreciated.

Thanks,
Mallik

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


Re: how to validate when the form-property is of type="java.lang.String[]"

Posted by The Jasper <th...@gmail.com>.
Hi,

So...how are you putting them on the form. I assume you some form of
iterative tag to put them on a form. There is probably a better
solution, but you could write a custom validator, or validate() method
to do what you want. I had to do this for a similar situation, but I
had at least 2 levels of arrays to traverse. I seem to remember
thinking I could solve it with just one level array to deal with. Also
the validation was a little complex.

mvg,
Jasper

On 6/22/06, lingan <sa...@gmail.com> wrote:
>
> Hi,
> I am trying to validate a field declared as String[] in the form bean.
> I think you should have solved this earlier.
> can u help me ??
> thanks.
> --
> View this message in context: http://www.nabble.com/how-to-validate-when-the-form-property-is-of-type%3D%22java.lang.String--%22-t11119.html#a4983501
> Sent from the Struts - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: how to validate when the form-property is of type="java.lang.String[]"

Posted by lingan <sa...@gmail.com>.
Hi,
I am trying to validate a field declared as String[] in the form bean.
I think you should have solved this earlier.
can u help me ??
thanks.
--
View this message in context: http://www.nabble.com/how-to-validate-when-the-form-property-is-of-type%3D%22java.lang.String--%22-t11119.html#a4983501
Sent from the Struts - User forum at Nabble.com.


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


Re: how to validate when the form-property is of type="java.lang.String[]"

Posted by m Komma <mk...@gmail.com>.
My problem is not accessing the values but is with validator.
I have the validation working correctly if within the
struts-config.xml file the form-property type="java.lang.String"

My issue is that I can't validate when the form-property is of
type="java.lang.String[]" (I can't validate the form-property
departments in the example listed below).  Do I need to include
something in the validation.xml that indicates I am working with
type="java.lang.String[]"

struts-config.xml:

     <form-bean name="empForm"
type="org.apache.struts.validator.DynaValidatorForm">
        <form-property name="departments" type="java.lang.String[]" />
        <form-property name="city" type="java.lang.String" />
     </form-bean>

validation.xml:

    <form name="empForm">
            <field property="departments" depends="required">
                   <arg0 key="departments.req"/>
            </field>
           <field property="city" depends="required">
                   <arg0 key="city.req"/>
           </field>
    </form>

Again, I have the validation working correctly when form-property is
of type="java.lang.String".  I can't however validate when the
form-property is of type="java.lang.String[]".

Mallik

On 5/12/05, David Johnson <ch...@gmail.com> wrote:
> What exactly is the problem you're having? Normally I'd say you'd loop
> through the array of values passed in thru the form bean
> 
> 
> On 5/12/05, m Komma < mkomma@gmail.com> wrote:
> > 
> > Hi,
> > I have a problem using validatorplugin for multiselection box. 
> > my filed is of type <form-property name="departments"
> > type="java.lang.String[]" />
> > 
> > I can't validate when the form-property is of type="java.lang.String[]"
> > 
> > I have the validation working correctly when form-property is of 
> > type="java.lang.String".  I can't however validate when the
> > form-property is of type="java.lang.String[]".
> > 
> > any help is appreciated.
> > 
> > Thanks,
> > Mallik
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org 
> > 
> > 
> 
> 
> 
> -- 
> -Dave
> ChaChaNY@Gmail.com

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


Re: how to validate when the form-property is of type="java.lang.String[]"

Posted by David Johnson <ch...@gmail.com>.
What exactly is the problem you're having? Normally I'd say you'd loop 
through the array of values passed in thru the form bean

On 5/12/05, m Komma <mk...@gmail.com> wrote:
> 
> Hi,
> I have a problem using validatorplugin for multiselection box.
> my filed is of type <form-property name="departments"
> type="java.lang.String[]" />
> 
> I can't validate when the form-property is of type="java.lang.String[]"
> 
> I have the validation working correctly when form-property is of
> type="java.lang.String". I can't however validate when the
> form-property is of type="java.lang.String[]".
> 
> any help is appreciated.
> 
> Thanks,
> Mallik
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
-Dave
ChaChaNY@Gmail.com