You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian McSweeney <br...@aurium.net> on 2003/04/17 15:16:06 UTC

Wizard validation

Hi all,

I'm still only getting the hang of Struts and I've become stuck upon what I think 
is a common problem. Validation when using a "wizard" - or set of JSP pages 
used for a single purpose. 

My wizard uses one form and populates different parts of it as I step through 
each jsp page of the wizard. Obviously I want the info on each one of these 
pages to be validated but calling the validate method like with a normal form 
won't work.

I've searched this on the mail lists and I think I am beginning to understand. 
However before working ahead, I'd like to pass my understanding of this by 
you guys to see if I have the right idea. 

First off, I think the basic priciple here is to like my validate methods to my 
actions rather than my form. I presume I could hard code the validation in 
each Action class.

However what seems to be more suggested is using the Validator package. 
It seems I then have a choice - 

I can write my form bean so that it extends:
    
    org.apache.struts.validator.ValidatorActionForm. 

or I can get the framework to create a form for me on the fly using

    org.apache.struts.validator.DynaValidatorActionForm. 

and based on an xml file that I must pass describing the fields I want 
to create (not really sure about this yet.)

In both cases I can specify the fields to be validated using the validator 
package.

Where I'm a little bit confused is - how do I tell which fields to be validated 
on which step of the wizard.

hope someone can tell me if I'm on the right track.
cheers,
Brian



Re: Struts, Jboss & Tomcat

Posted by Dimitar Georgievski <di...@websyn.com>.
ignore this message. the WEB-INF directory was renamed, by mistake, web-inf.
It works just fine now.

dimitar
----- Original Message -----
From: "Dimitar Georgievski" <di...@websyn.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, April 17, 2003 8:35 PM
Subject: Struts, Jboss & Tomcat


> Hi,
>
> this is a newbie question. The web application I am working on should be
> ported to Struts. Currently it is running on JBoss 3.0 /Tomcat 4.1.12.
>
> When deploying the war file of the application to the deployment directory
> Tomcat is complaining about invalid resource path for the the TLD
libraries.
> The mapping of the tag libraries in web.xml is not valid any more. The
same
> configuration works fine on standalone Tomcat.
>
> This is the <taglib> part of my web.xml
>
> <taglib>
>     <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
>     <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
>   </taglib>
>
> if the deployment application file is callled myapp.war how do I map
> correctly the tag libraries in the web.xml file?
>
> I have checked the content of the war file. The tag libraries are in
WEB-INF
> directory.
>
> thanks,
>
> dimitar
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


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


Struts, Jboss & Tomcat

Posted by Dimitar Georgievski <di...@websyn.com>.
Hi,

this is a newbie question. The web application I am working on should be
ported to Struts. Currently it is running on JBoss 3.0 /Tomcat 4.1.12.

When deploying the war file of the application to the deployment directory
Tomcat is complaining about invalid resource path for the the TLD libraries.
The mapping of the tag libraries in web.xml is not valid any more. The same
configuration works fine on standalone Tomcat.

This is the <taglib> part of my web.xml

<taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

if the deployment application file is callled myapp.war how do I map
correctly the tag libraries in the web.xml file?

I have checked the content of the war file. The tag libraries are in WEB-INF
directory.

thanks,

dimitar




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


Re: Wizard validation

Posted by Patrick Refondini <pa...@pobox.com>.
Brian McSweeney wrote:

>thanks very much Patrick,
>
>can you tell me what types of forms these are?
>Are they DynaValidatorActionForms?
>
the userForm extends org.apache.struts.validator.ValidatorForm

then it simply looks like a regular bean:

  private String name;
  private String password;
  private String birthText;

  public void setName(String name) {
    this.name = name;
  }
  public String getName() {
    return name;
  }

...

>
>Can the page attribute be used in validate xml
>with any type of ValidatorForms?
>
I have no experience with DynaValidatorForms but I guess the same
strategy must apply ...

>
>cheers,
>Brian
>
>
>----- Original Message -----
>From: "Patrick Refondini" <pa...@pobox.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Thursday, April 17, 2003 3:30 PM
>Subject: Re: Wizard validation
>
>
>  
>
>>Brian McSweeney wrote:
>>
>>    
>>
>>>Hi all,
>>>
>>>I'm still only getting the hang of Struts and I've become stuck upon what
>>>      
>>>
>I think
>  
>
>>>is a common problem. Validation when using a "wizard" - or set of JSP
>>>      
>>>
>pages
>  
>
>>>used for a single purpose.
>>>
>>>My wizard uses one form and populates different parts of it as I step
>>>      
>>>
>through
>  
>
>>>each jsp page of the wizard. Obviously I want the info on each one of
>>>      
>>>
>these
>  
>
>>>pages to be validated but calling the validate method like with a normal
>>>      
>>>
>form
>  
>
>>>won't work.
>>>
>>>I've searched this on the mail lists and I think I am beginning to
>>>      
>>>
>understand.
>  
>
>>>However before working ahead, I'd like to pass my understanding of this
>>>      
>>>
>by
>  
>
>>>you guys to see if I have the right idea.
>>>
>>>First off, I think the basic priciple here is to like my validate methods
>>>      
>>>
>to my
>  
>
>>>actions rather than my form. I presume I could hard code the validation
>>>      
>>>
>in
>  
>
>>>each Action class.
>>>
>>>However what seems to be more suggested is using the Validator package.
>>>It seems I then have a choice -
>>>
>>>I can write my form bean so that it extends:
>>>
>>>   org.apache.struts.validator.ValidatorActionForm.
>>>
>>>or I can get the framework to create a form for me on the fly using
>>>
>>>   org.apache.struts.validator.DynaValidatorActionForm.
>>>
>>>and based on an xml file that I must pass describing the fields I want
>>>to create (not really sure about this yet.)
>>>
>>>In both cases I can specify the fields to be validated using the
>>>      
>>>
>validator
>  
>
>>>package.
>>>
>>>Where I'm a little bit confused is - how do I tell which fields to be
>>>      
>>>
>validated
>  
>
>>>on which step of the wizard.
>>>
>>>
>>>      
>>>
>>Using the Validator (in Struts 1.1-rc1).
>>
>>1. Given a user form with name, password, birthText fields
>>2. A wizard first step to check the name and password
>>3. A wizard second step to check the birthday field birthText
>>
>>You might define the following in validation.xml
>>(note the field element page="..." attribute)
>>
>><form-validation>
>>
>>   <formset language="fr" >
>>
>>       <constant>
>>          <constant-name>datePattern</constant-name>
>>          <constant-value>dd.MM.yyyy</constant-value>
>>       </constant>
>>
>>      <form    name="userForm">
>>
>>         <field    property="name"
>>                depends="required"
>>                   page="1">
>>                  <arg0 key="User.name.display"/>
>>         </field>
>>
>>         <field    property="password"
>>                depends="required"
>>                   page="1">
>>                  <arg0
>>key="com.extentis.webapp.admin.user.UserForm.password.display"/>
>>         </field>
>>
>>         <field    property="birthText"
>>                depends="date"
>>                   page="2">
>>                  <arg0
>>key="com.extentis.webapp.common.Person.birth.display"/>
>>                     <var>
>>                       <var-name>datePatternStrict</var-name>
>>                       <var-value>${datePattern}</var-value>
>>                     </var>
>>         </field>
>>
>>      </form>
>>
>>   </formset>
>>
>>   <formset language="en" country="US">
>>
>>       <constant>
>>          <constant-name>datePattern</constant-name>
>>          <constant-value>dd/MM/yyyy</constant-value>
>>       </constant>
>>
>>(...)
>>
>>   </formset>
>>
>>
>></form-validation>
>>
>>
>>And set the corresponding
>>
>>  <html:javascript formName="userForm" page="1"/>
>>
>>for wizard page 1
>>
>>  <html:javascript formName="userForm" page="2" />
>>
>>for wizard page 2
>>
>>
>>That's about it. I think the Validator is most valuable, do not hesitate
>>using it !
>>
>>Patrick
>>
>>
>>    
>>
>>>hope someone can tell me if I'm on the right track.
>>>cheers,
>>>Brian
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>  
>




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


Re: Wizard validation

Posted by Brian McSweeney <br...@aurium.net>.
thanks very much Patrick,

can you tell me what types of forms these are?
Are they DynaValidatorActionForms?

Can the page attribute be used in validate xml
with any type of ValidatorForms?

cheers,
Brian


----- Original Message -----
From: "Patrick Refondini" <pa...@pobox.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, April 17, 2003 3:30 PM
Subject: Re: Wizard validation


> Brian McSweeney wrote:
>
> >Hi all,
> >
> >I'm still only getting the hang of Struts and I've become stuck upon what
I think
> >is a common problem. Validation when using a "wizard" - or set of JSP
pages
> >used for a single purpose.
> >
> >My wizard uses one form and populates different parts of it as I step
through
> >each jsp page of the wizard. Obviously I want the info on each one of
these
> >pages to be validated but calling the validate method like with a normal
form
> >won't work.
> >
> >I've searched this on the mail lists and I think I am beginning to
understand.
> >However before working ahead, I'd like to pass my understanding of this
by
> >you guys to see if I have the right idea.
> >
> >First off, I think the basic priciple here is to like my validate methods
to my
> >actions rather than my form. I presume I could hard code the validation
in
> >each Action class.
> >
> >However what seems to be more suggested is using the Validator package.
> >It seems I then have a choice -
> >
> >I can write my form bean so that it extends:
> >
> >    org.apache.struts.validator.ValidatorActionForm.
> >
> >or I can get the framework to create a form for me on the fly using
> >
> >    org.apache.struts.validator.DynaValidatorActionForm.
> >
> >and based on an xml file that I must pass describing the fields I want
> >to create (not really sure about this yet.)
> >
> >In both cases I can specify the fields to be validated using the
validator
> >package.
> >
> >Where I'm a little bit confused is - how do I tell which fields to be
validated
> >on which step of the wizard.
> >
> >
> Using the Validator (in Struts 1.1-rc1).
>
> 1. Given a user form with name, password, birthText fields
> 2. A wizard first step to check the name and password
> 3. A wizard second step to check the birthday field birthText
>
> You might define the following in validation.xml
> (note the field element page="..." attribute)
>
> <form-validation>
>
>    <formset language="fr" >
>
>        <constant>
>           <constant-name>datePattern</constant-name>
>           <constant-value>dd.MM.yyyy</constant-value>
>        </constant>
>
>       <form    name="userForm">
>
>          <field    property="name"
>                 depends="required"
>                    page="1">
>                   <arg0 key="User.name.display"/>
>          </field>
>
>          <field    property="password"
>                 depends="required"
>                    page="1">
>                   <arg0
> key="com.extentis.webapp.admin.user.UserForm.password.display"/>
>          </field>
>
>          <field    property="birthText"
>                 depends="date"
>                    page="2">
>                   <arg0
> key="com.extentis.webapp.common.Person.birth.display"/>
>                      <var>
>                        <var-name>datePatternStrict</var-name>
>                        <var-value>${datePattern}</var-value>
>                      </var>
>          </field>
>
>       </form>
>
>    </formset>
>
>    <formset language="en" country="US">
>
>        <constant>
>           <constant-name>datePattern</constant-name>
>           <constant-value>dd/MM/yyyy</constant-value>
>        </constant>
>
> (...)
>
>    </formset>
>
>
> </form-validation>
>
>
> And set the corresponding
>
>   <html:javascript formName="userForm" page="1"/>
>
> for wizard page 1
>
>   <html:javascript formName="userForm" page="2" />
>
> for wizard page 2
>
>
> That's about it. I think the Validator is most valuable, do not hesitate
> using it !
>
> Patrick
>
>
> >hope someone can tell me if I'm on the right track.
> >cheers,
> >Brian
> >
> >
> >
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: Wizard validation

Posted by Patrick Refondini <pa...@pobox.com>.
Brian McSweeney wrote:

>Hi all,
>
>I'm still only getting the hang of Struts and I've become stuck upon what I think 
>is a common problem. Validation when using a "wizard" - or set of JSP pages 
>used for a single purpose. 
>
>My wizard uses one form and populates different parts of it as I step through 
>each jsp page of the wizard. Obviously I want the info on each one of these 
>pages to be validated but calling the validate method like with a normal form 
>won't work.
>
>I've searched this on the mail lists and I think I am beginning to understand. 
>However before working ahead, I'd like to pass my understanding of this by 
>you guys to see if I have the right idea. 
>
>First off, I think the basic priciple here is to like my validate methods to my 
>actions rather than my form. I presume I could hard code the validation in 
>each Action class.
>
>However what seems to be more suggested is using the Validator package. 
>It seems I then have a choice - 
>
>I can write my form bean so that it extends:
>    
>    org.apache.struts.validator.ValidatorActionForm. 
>
>or I can get the framework to create a form for me on the fly using
>
>    org.apache.struts.validator.DynaValidatorActionForm. 
>
>and based on an xml file that I must pass describing the fields I want 
>to create (not really sure about this yet.)
>
>In both cases I can specify the fields to be validated using the validator 
>package.
>
>Where I'm a little bit confused is - how do I tell which fields to be validated 
>on which step of the wizard.
>  
>
Using the Validator (in Struts 1.1-rc1).

1. Given a user form with name, password, birthText fields
2. A wizard first step to check the name and password
3. A wizard second step to check the birthday field birthText

You might define the following in validation.xml
(note the field element page="..." attribute)

<form-validation>

   <formset language="fr" >

       <constant>
          <constant-name>datePattern</constant-name>
          <constant-value>dd.MM.yyyy</constant-value>
       </constant>

      <form    name="userForm">

         <field    property="name"
                depends="required"
                   page="1">
                  <arg0 key="User.name.display"/>
         </field>

         <field    property="password"
                depends="required"
                   page="1">
                  <arg0 
key="com.extentis.webapp.admin.user.UserForm.password.display"/>
         </field>

         <field    property="birthText"
                depends="date"
                   page="2">
                  <arg0 
key="com.extentis.webapp.common.Person.birth.display"/>
                     <var>
                       <var-name>datePatternStrict</var-name>
                       <var-value>${datePattern}</var-value>
                     </var>
         </field>

      </form>

   </formset>

   <formset language="en" country="US">

       <constant>
          <constant-name>datePattern</constant-name>
          <constant-value>dd/MM/yyyy</constant-value>
       </constant>

(...)

   </formset>


</form-validation>


And set the corresponding

  <html:javascript formName="userForm" page="1"/>

for wizard page 1

  <html:javascript formName="userForm" page="2" />

for wizard page 2


That's about it. I think the Validator is most valuable, do not hesitate 
using it !

Patrick


>hope someone can tell me if I'm on the right track.
>cheers,
>Brian
>
>
>
>  
>




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


Re: Wizard validation

Posted by Brian McSweeney <br...@aurium.net>.
nice idea, baby steps is the answer eh :-)
thanks very much,
Brian

----- Original Message -----
From: "Jeff Smith" <je...@centralscheduling.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, April 17, 2003 2:50 PM
Subject: Re: Wizard validation


> You have two conflicting problems. First, you are trying to absorb Struts.
> And to do that effectively (from my recent and ongoing experience) you
want
> to minimize how much of the universe you pull in to your first few
projects.
> As such, I can't comment on the utility of the validator package, as I
> haven't started using it yet. :-)
>
> But I had a similar problem to yours in validating a sequential operation.
> What I did was put a hidden variable called "whereAmI" on each page of the
> wizard. That way, I could switch on that value in my validator and only
test
> the fields that had been modified by that form page. I found this solution
> to be the simplest of several I tried, which also included putting a
string
> array into the session scope with the list of field names expected after
> each step of the wizard, and using that list to index through the fields
in
> the validator.
>
> HTH,
> Jefficus
>
> ----- Original Message -----
> From: "Brian McSweeney" <br...@aurium.net>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Thursday, April 17, 2003 7:16 AM
> Subject: Wizard validation
>
>
> Hi all,
>
> I'm still only getting the hang of Struts and I've become stuck upon what
I
> think
> is a common problem. Validation when using a "wizard" - or set of JSP
pages
> used for a single purpose.
>
> My wizard uses one form and populates different parts of it as I step
> through
> each jsp page of the wizard. Obviously I want the info on each one of
these
> pages to be validated but calling the validate method like with a normal
> form
> won't work.
>
> I've searched this on the mail lists and I think I am beginning to
> understand.
> However before working ahead, I'd like to pass my understanding of this by
> you guys to see if I have the right idea.
>
> First off, I think the basic priciple here is to like my validate methods
to
> my
> actions rather than my form. I presume I could hard code the validation in
> each Action class.
>
> However what seems to be more suggested is using the Validator package.
> It seems I then have a choice -
>
> I can write my form bean so that it extends:
>
>     org.apache.struts.validator.ValidatorActionForm.
>
> or I can get the framework to create a form for me on the fly using
>
>     org.apache.struts.validator.DynaValidatorActionForm.
>
> and based on an xml file that I must pass describing the fields I want
> to create (not really sure about this yet.)
>
> In both cases I can specify the fields to be validated using the validator
> package.
>
> Where I'm a little bit confused is - how do I tell which fields to be
> validated
> on which step of the wizard.
>
> hope someone can tell me if I'm on the right track.
> cheers,
> Brian
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: Wizard validation

Posted by Jeff Smith <je...@centralscheduling.net>.
You have two conflicting problems. First, you are trying to absorb Struts.
And to do that effectively (from my recent and ongoing experience) you want
to minimize how much of the universe you pull in to your first few projects.
As such, I can't comment on the utility of the validator package, as I
haven't started using it yet. :-)

But I had a similar problem to yours in validating a sequential operation.
What I did was put a hidden variable called "whereAmI" on each page of the
wizard. That way, I could switch on that value in my validator and only test
the fields that had been modified by that form page. I found this solution
to be the simplest of several I tried, which also included putting a string
array into the session scope with the list of field names expected after
each step of the wizard, and using that list to index through the fields in
the validator.

HTH,
Jefficus

----- Original Message -----
From: "Brian McSweeney" <br...@aurium.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, April 17, 2003 7:16 AM
Subject: Wizard validation


Hi all,

I'm still only getting the hang of Struts and I've become stuck upon what I
think
is a common problem. Validation when using a "wizard" - or set of JSP pages
used for a single purpose.

My wizard uses one form and populates different parts of it as I step
through
each jsp page of the wizard. Obviously I want the info on each one of these
pages to be validated but calling the validate method like with a normal
form
won't work.

I've searched this on the mail lists and I think I am beginning to
understand.
However before working ahead, I'd like to pass my understanding of this by
you guys to see if I have the right idea.

First off, I think the basic priciple here is to like my validate methods to
my
actions rather than my form. I presume I could hard code the validation in
each Action class.

However what seems to be more suggested is using the Validator package.
It seems I then have a choice -

I can write my form bean so that it extends:

    org.apache.struts.validator.ValidatorActionForm.

or I can get the framework to create a form for me on the fly using

    org.apache.struts.validator.DynaValidatorActionForm.

and based on an xml file that I must pass describing the fields I want
to create (not really sure about this yet.)

In both cases I can specify the fields to be validated using the validator
package.

Where I'm a little bit confused is - how do I tell which fields to be
validated
on which step of the wizard.

hope someone can tell me if I'm on the right track.
cheers,
Brian




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