You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emmanouil Batsis <Em...@eurodyn.com> on 2004/10/05 15:14:36 UTC

[validator] dependent field

Consider two fields, type and time. The first mandatory, the second 
dependent on the value of the first.

What I'm trying to do enforce a not null and not empty value for the 
time field, when the type has a value of 'time'. I've been trying to do 
this for more than an hour; I was hoping someone can spot my error as i 
have become really unproductive here :-)

Below I have both my generated validator.xml fragment and my webdoclet 
tags. Please let me know whats wrong with either!

type field
@struts.validator type="required"  msgkey="error.form.eauction.type"


time field
@struts.validator type="minlength"
                  arg1value="${var:minlength}"
@struts.validator type="validwhen"
 
@struts.validator-args arg0resource="error.form.eauction.time"

@struts.validator-var name="minlength"
                       value="1"
@struts.validator-var name="test"
                       value="((type != 'time') or (*this* != null))"


And my XML fragment:


<field property="type"
     depends="required">
  <msg
    name="required"
    key="error.form.eauction.type"/>

  <arg0 key="auctionDefinitionForm.type"/>
</field>

<field property="time"
     depends="minlength,validwhen">

  <arg0
    key="error.form.eauction.time"
  />
  <arg1
      name="minlength"
    key="${var:minlength}"
      resource="false"
  />
  <var>
    <var-name>minlength</var-name>
    <var-value>1</var-value>
  </var>

  <var>
    <var-name>test</var-name>
    <var-value>((type != 'time') or (*this* != null))</var-value>
  </var>
</field>

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


Re: [validator] dependent field

Posted by Emmanouil Batsis <Em...@eurodyn.com>.
One day later, I figured it out. One must split the validators to 
multiple struts.validator tags, each one having it's own msgkey...

Emmanouil Batsis wrote:

>
> Consider two fields, type and time. The first mandatory, the second 
> dependent on the value of the first.
>
> What I'm trying to do enforce a not null and not empty value for the 
> time field, when the type has a value of 'time'. I've been trying to 
> do this for more than an hour; I was hoping someone can spot my error 
> as i have become really unproductive here :-)
>
> Below I have both my generated validator.xml fragment and my webdoclet 
> tags. Please let me know whats wrong with either!
>
> type field
> @struts.validator type="required"  msgkey="error.form.eauction.type"
>
>
> time field
> @struts.validator type="minlength"
>                  arg1value="${var:minlength}"
> @struts.validator type="validwhen"
>
> @struts.validator-args arg0resource="error.form.eauction.time"
>
> @struts.validator-var name="minlength"
>                       value="1"
> @struts.validator-var name="test"
>                       value="((type != 'time') or (*this* != null))"
>
>
> And my XML fragment:
>
>
> <field property="type"
>     depends="required">
>  <msg
>    name="required"
>    key="error.form.eauction.type"/>
>
>  <arg0 key="auctionDefinitionForm.type"/>
> </field>
>
> <field property="time"
>     depends="minlength,validwhen">
>
>  <arg0
>    key="error.form.eauction.time"
>  />
>  <arg1
>      name="minlength"
>    key="${var:minlength}"
>      resource="false"
>  />
>  <var>
>    <var-name>minlength</var-name>
>    <var-value>1</var-value>
>  </var>
>
>  <var>
>    <var-name>test</var-name>
>    <var-value>((type != 'time') or (*this* != null))</var-value>
>  </var>
> </field>
>
> ---------------------------------------------------------------------
> 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