See, even though you just want firstname dependent on lastname,
you could tie the requirement to more than one other field,
hence the array notation:
        field[0], field-test[0], ... for the first conditional dependency.
        field[1], field-test[1], ... for the first conditional dependency, etc.

You only need firstname to be required if lastname is not null,
but you still have to use the array notation.

You can ignore the indexedListProperty and field-indexed[n]
for simple text fields.

So it would look something like:

<field property="firstName" depends="requiredif">
  <arg0 key="myForm.firstName.errorname"/>
  <var>
    <var-name>field[0]</var-name>
    <var-value>lastName</var-value>
  </var>
  <var>
    <var-name>field-test[0]</var-name>
    <var-value>NOTNULL</var-value>
  </var>
</field>

HTH,

-jeff

On Monday, February 24, 2003, at 08:44 AM, Zsolt Koppany wrote:

Hi Jeff,

thank you but my problem is that I just don't understand the examples.
I'm sure they are excellent but they do much more (as far I understand
them) than I need.

Could you please write me which example is the best for me? When I look
to the example below I don't understand what field[0], field-indexed[0],
field-test[0] and indexedListProperty mean and it is for me difficult to
adopt something I don't understand.



<form name="dependentlistForm">


<field
    property="firstName" indexedListProperty="dependents"
    depends="requiredif">
  <arg0 key="dependentlistForm.firstName.label"/>
  <var>
    <var-name>field[0]</var-name>
    <var-value>lastName</var-value>
  </var>
  <var>
    <var-name>field-indexed[0]</var-name>
    <var-value>true</var-value>
  </var>
  <var>
    <var-name>field-test[0]</var-name>
    <var-value>NOTNULL</var-value>
  </var>
</field>

...

</form>



On Mon, 2003-02-24 at 13:55, Jeff Kyser wrote:
Zsolt,

        There is a nice description of exactly what you want to do
        on the Struts web pages. Here's the link, see the bottom
        part of the page:

http://jakarta.apache.org/struts/userGuide/dev_validator.html

        It even has the exact fields you want to check. (represents #2
        below);

        You will need to:
                1. locate the struts-supplied validator-rules.xml
                2. create your own validation.xml file containing the mapping
                        of the rules (in your case, the "requiredif" rule) to the form
                        elements (firstname, lastname)
                3. reference these two files in your validator PlugIn which
                        gets included in your struts-config.xml
                4. provide an appropriate error message in your
                        application resources bundle
                5. add the appropriate <html:errors /> tag in the jsp that
                        displays the form elements

HTH,

-jeff

On Monday, February 24, 2003, at 01:45 AM, Zsolt Koppany wrote:

Thank you James,

I have read the documentation, and I'm sorry but I still don't
understand how to define the rule that a field for example "firstname"
is required if for example "lastname" is not empty.


Can somebody provide me an example please? I just don't understand the
examples in the documentation, they are just too complex.


Zsolt

On Sun, 2003-02-23 at 22:35, James Turner wrote:
See the requiredif validation in Struts 1.1


James


-----Original Message-----
From: Zsolt Koppany [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 23, 2003 3:01 PM
To: struts mail list
Subject: Validator: How to define that a field is mandatory
when an otheris not empty?


Hi,


how can I define that a field is mandatory when an other is
not empty but only in that case?

-- Zsolt


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


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


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



Reply via email to