You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Bruno Goldberg <go...@prosites.com.br> on 2002/11/26 18:27:18 UTC

perform() or execute()?

Hi, people!
	
	I am trying to develop a little system in struts for 3 weeks now and I
can't solve some (very basic) problems. I try read the documentations,
but some I can resolve anyway. Please, I need some help!
	My questions:

	1. When I try to use the execute() in a Action, the method is nota
called. When I try with perform() works fine, but I known this is
deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same result).
	2. I try to prepopulate a form (request scope) and does not works. I
try to set: request.setAttribute("myfield","myvalue"), and nothing.
	3. To prepopulate a Form, I must to call a Action, prepopulate a bean
and then call a Form? That right?

	Please, I need some help. Thanks to all.



-- 
        CUL8R,[]s
    Jim Bruno Goldberg
http://www.prosites.com.br

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: validate() is working !!!!! Thanks Patrice!

Posted by Patrice <pp...@nerim.net>.
Hi,

Struts will use the form name defined in your struts-config.xml file, for
the action:
For example:

<form-bean name="UserForm" type="UserForm"/>
...
<action  path="/UserFormAction"
        type="UserFormAction"
        name="UserForm"
        scope="request"
        input="/groups/user_form.jsp">
</action>

If you put <html:form action="/UserFormAction">,
it will be replaced with <form name="UserForm"
action="/yourWebApp/UserFormAction.do" method="post">

So, your link will be:
<a href="javascript:UserForm.submit();">

Best regards
Patrice

----- Original Message -----
From: "Jim Bruno Goldberg" <go...@prosites.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 27, 2002 6:53 PM
Subject: Re: validate() is working !!!!! Thanks Patrice!


>
> Thanks a lot, Patrice. It works now!
>
> Now I need to solve another question: how can I define the form name on
> form without use name="TheForm" on <html:form>? I need this to use a
> link likes <a href="javascript:myformname.submit();">[Submit]</a>. Do
> you know how to solve that? Anyone kowns?
> Thanks a lot, again!
>
> Patrice wrote:
> >
> > I suppose that's because you have declared a name in your <html:form>
tag
> > that is not corresponds to those on the struts-config.xml file.
> > The attributes "type" and "name" of the <html:form> tag are deprecated
in
> > Struts 1.1.
> >
> > Try to replace:
> > 
> >
> > with:
> > <html:form action="UserForm">
> >
> > Regards
> > Patrice
> >
> > ----- Original Message -----
> > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, November 27, 2002 5:36 PM
> > Subject: validate() almost working.....
> >
> > > My code is aslmost working....
> > > Validation and messages are ok. Now I need to solve one more
> > > problem....
> > > When these validate function returns some errors, and forward back to
> > > form,jsp, the fields are empty. Follow I put the code, the page and
the
> > > struts-config. Whats wrong?
> > >
> > > struts-config BEGIN-------------------------------------------------
> > >
> > > <form-bean name="UserForm"      type="UserForm"/>
> > >
> > >          <action
> > >                 path="/UserForm"
> > >                 type="UserFormAction"
> > >                 name="UserForm"
> > >                 scope="request"
> > >                 input="/groups/user_form.jsp">
> > >         </action>
> > >
> > >
> > > struts-config END-------------------------------------------------
> > >
> > > Jsp BEGIN---------------------------------------------------------
> > > <html>
> > > <body>
> > > <html:form action="UserForm" type="UserForm" name="TheForm">
> > > Usename:<html:text property="username" size="60" /><br>
> > > Password:<html:password property="password" size="60"/><br>
> > > Retype:<html:password property="passwordagain" size="60"/><br>
> > > <a href='/parker/team/usuarios.htm'>[Cancela]</a> <a
> > > href='javascript:TheForm.submit();'>[Adiciona]</a><br>
> > > </html:form>
> > > </body>
> > > </html>
> > > Jsp END-----------------------------------------------------------
> > >
> > >
> > >
> > > Code BEGIN--------------------------------------------------------
> > > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > > request) {
> > >
> > >                 ActionErrors errors = new ActionErrors();
> > >
> > >                 servlet.log("Validating UserForm");
> > >
> > >                 if ((username == null) || (username.length() < 1))
> > >                         errors.add("username", new
> > > ActionError("errors.nousername"));
> > >
> > >                 if ((password == null) || (password.length() < 1))
> > >                        errors.add("password", new
> > > ActionError("errors.nopassword"));
> > >
> > >
> > >                 if ( !password.equals(again))
> > >                        errors.add("passwordagain",new
> > > ActionError("errors.passwordnotmatch"));
> > >
> > >                 return errors;
> > >
> > >
> > >         }
> > >
> > >
> > > Code END----------------------------------------------------------
> > >
> > > Patrice wrote:
> > > >
> > > > I don't see anything wrong...
> > > > All I know is that empty String is returned when the key on an
> > ActionError
> > > > is not present in the default application resource files (defined in
> > > > web.xml).
> > >
> > > Yes. I make some confusion and has 2 application.properties on the
> > > structure. Thanks for the tip.
> > >
> > > > Best regards
> > > > Patrice
> > > >
> > > > ----- Original Message -----
> > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > > Sent: Wednesday, November 27, 2002 12:44 PM
> > > > Subject: Re: perform() or execute()? (Mistery)
> > > >
> > > > >
> > > > > I check that an all is ok.
> > > > > On the truth, the method is executed and the variables checked,
the
> > > > > errors "listed" on the original form , but they is empty strings
> > > > > (?!?!?!?!) I just dont understand....
> > > > >
> > > > > Patrice wrote:
> > > > > >
> > > > > > Perhaps I miss something, but I don't see any problem in your
code.
> > > > > > Check that form implement ActionForm (and not ValidatorForm) to
> > execute
> > > > > > correctly the validate() method.
> > > > > > Check also that you don't forget the <html:errors/> tag on your
JSP.
> > > > > >
> > > > > > Hope it helps
> > > > > > Patrice
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > > > > Sent: Tuesday, November 26, 2002 9:40 PM
> > > > > > Subject: Re: perform() or execute()?
> > > > > >
> > > > > > >
> > > > > > > I try it again, from the beginning and now this works. I don
know
> > what
> > > > > > > I do before but I am happy now. Thanks for David and Patrice
to
> > help
> > > > me.
> > > > > > > Now I have a new (and diferent) problem. I construct the
follow
> > > > > > > validate() in a ActionForm class:
> > > > > > >
> > > > > > >
> > > > > > > CODE BEGIN-----------------------------------
> > > > > > >
> > > > > > > public ActionErrors validate(ActionMapping mapping,
> > HttpServletRequest
> > > > > > > request) {
> > > > > > >
> > > > > > > ActionErrors errors = new ActionErrors();
> > > > > > >
> > > > > > > if ((username == null) || (username.length() < 1))
> > > > > > > errors.add("username", new ActionError("errors.nousername"));
> > > > > > >
> > > > > > > if ((password == null) || (username.length() < 1))
> > > > > > >                 errors.add("password", new
> > > > > > > ActionError("errors.nopassword"));
> > > > > > >
> > > > > > >         if ( !password.equals(again))
> > > > > > >                 errors.add("passwordagain",new
> > > > > > > ActionError("errors.passwordnotmatch"));
> > > > > > >
> > > > > > > return errors;
> > > > > > > }
> > > > > > >
> > > > > > > CODE
> > > > END----------------------------------------------------------------
> > > > > > >
> > > > > > > ...and I have the follow entrys on my message resource file:
> > > > > > >
> > > > > > > FILE BEGIN
> > > > > > >
(application.properties)------------------------------------------
> > > > > > >
> > > > > > > # -- standard errors --
> > > > > > > errors.nousername=O campo username deve ser preenchido
> > > > > > > errors.nopassword=O campo senha deve ser preenchido
> > > > > > > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > > > > > > errors.header=<UL>
> > > > > > > errors.prefix=<LI>
> > > > > > > errors.suffix=</LI>
> > > > > > > errors.footer=</UL>
> > > > > > > # -- validator --
> > > > > > > errors.invalid={0} is invalid.
> > > > > > > errors.maxlength={0} can not be greater than {1} characters.
> > > > > > > errors.minlength={0} can not be less than {1} characters.
> > > > > >
> ------------------------------------------------------------------
> > > > > > >
> > > > > > > .... The behavior on form looks like OK, but the messages
(inside
> > the
> > > > > > > <li> and </li>) are empty. No errors, behavior ok but empty
> > Strings.
> > > > > > > Please, can someone help to me again? Thanks a lot.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Patrice wrote:
> > > > > > > >
> > > > > > > > ----- Original Message -----
> > > > > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > > > > To: <st...@jakarta.apache.org>
> > > > > > > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > > > > > > Subject: perform() or execute()?
> > > > > > > >
> > > > > > > > > Hi, people!
> > > > > > > > >
> > > > > > > > > I am trying to develop a little system in struts for 3
weeks
> > now
> > > > and I
> > > > > > > > > can't solve some (very basic) problems. I try read the
> > > > documentations,
> > > > > > > > > but some I can resolve anyway. Please, I need some help!
> > > > > > > > > My questions:
> > > > > > > > >
> > > > > > > > > 1. When I try to use the execute() in a Action, the method
is
> > nota
> > > > > > > > > called. When I try with perform() works fine, but I known
this
> > is
> > > > > > > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 -
same
> > > > result).
> > > > > > > >
> > > > > > > > The  method has been deprecated since struts 1.1: so it
can't
> > work
> > > > in
> > > > > > struts
> > > > > > > > 1.0.2
> > > > > > > >
> > > > > > > > > 2. I try to prepopulate a form (request scope) and does
not
> > works.
> > > > I
> > > > > > > > > try to set: request.setAttribute("myfield","myvalue"), and
> > > > nothing.
> > > > > > > >
> > > > > > > > To populate a form from an action, you need to cast the
> > ActionForm
> > > > > > passed as
> > > > > > > > parameter to the perform (or execute) method of your action
and
> > > > then,
> > > > > > set
> > > > > > > > the different properties to the appropriate values:
> > > > > > > > for example:
> > > > > > > >
> > > > > > > > MyForm myForm = (MyForm) form;
> > > > > > > > myForm.setMyField("myValue");
> > > > > > > >
> > > > > > > > > 3. To prepopulate a Form, I must to call a Action,
prepopulate
> > a
> > > > bean
> > > > > > > > > and then call a Form? That right?
> > > > > > > >
> > > > > > > > I don't know what you mean with "call a Form".
> > > > > > > > You just need to set the properties of the form with the
values
> > you
> > > > want
> > > > > > > > Then, the taglib will display the values in the field of the
> > form,
> > > > on
> > > > > > your
> > > > > > > > JSP.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Please, I need some help. Thanks to all.
> > > > > > > > >
> > > > > > > >
> > > > > > > > Hope it helps
> > > > > > > > Patrice
> > > > > > > >
> > > > > > > > --
> > > > > > > > To unsubscribe, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > > > > For additional commands, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > > >
> > > > > > > --
> > > > > > >         CUL8R,[]s
> > > > > > >     Jim Bruno Goldberg
> > > > > > > http://www.prosites.com.br
> > > > > > >
> > > > > > > --
> > > > > > > To unsubscribe, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > > > For additional commands, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > > >
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > > > --
> > > > >         CUL8R,[]s
> > > > >     Jim Bruno Goldberg
> > > > > http://www.prosites.com.br
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > > --
> > >         CUL8R,[]s
> > >     Jim Bruno Goldberg
> > > http://www.prosites.com.br
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
>         CUL8R,[]s
>     Jim Bruno Goldberg
> http://www.prosites.com.br
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: validate() is working !!!!! Thanks Patrice!

Posted by Jim Bruno Goldberg <go...@prosites.com.br>.
	Thanks a lot, Patrice. It works now!

	Now I need to solve another question: how can I define the form name on
form without use name="TheForm" on <html:form>? I need this to use a
link likes <a href="javascript:myformname.submit();">[Submit]</a>. Do
you know how to solve that? Anyone kowns?
	Thanks a lot, again!

Patrice wrote:
> 
> I suppose that's because you have declared a name in your <html:form> tag
> that is not corresponds to those on the struts-config.xml file.
> The attributes "type" and "name" of the <html:form> tag are deprecated in
> Struts 1.1.
> 
> Try to replace:
> 
> 
> with:
> <html:form action="UserForm">
> 
> Regards
> Patrice
> 
> ----- Original Message -----
> From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 27, 2002 5:36 PM
> Subject: validate() almost working.....
> 
> > My code is aslmost working....
> > Validation and messages are ok. Now I need to solve one more
> > problem....
> > When these validate function returns some errors, and forward back to
> > form,jsp, the fields are empty. Follow I put the code, the page and the
> > struts-config. Whats wrong?
> >
> > struts-config BEGIN-------------------------------------------------
> >
> > <form-bean name="UserForm"      type="UserForm"/>
> >
> >          <action
> >                 path="/UserForm"
> >                 type="UserFormAction"
> >                 name="UserForm"
> >                 scope="request"
> >                 input="/groups/user_form.jsp">
> >         </action>
> >
> >
> > struts-config END-------------------------------------------------
> >
> > Jsp BEGIN---------------------------------------------------------
> > <html>
> > <body>
> > <html:form action="UserForm" type="UserForm" name="TheForm">
> > Usename:<html:text property="username" size="60" /><br>
> > Password:<html:password property="password" size="60"/><br>
> > Retype:<html:password property="passwordagain" size="60"/><br>
> > <a href='/parker/team/usuarios.htm'>[Cancela]</a> <a
> > href='javascript:TheForm.submit();'>[Adiciona]</a><br>
> > </html:form>
> > </body>
> > </html>
> > Jsp END-----------------------------------------------------------
> >
> >
> >
> > Code BEGIN--------------------------------------------------------
> > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > request) {
> >
> >                 ActionErrors errors = new ActionErrors();
> >
> >                 servlet.log("Validating UserForm");
> >
> >                 if ((username == null) || (username.length() < 1))
> >                         errors.add("username", new
> > ActionError("errors.nousername"));
> >
> >                 if ((password == null) || (password.length() < 1))
> >                        errors.add("password", new
> > ActionError("errors.nopassword"));
> >
> >
> >                 if ( !password.equals(again))
> >                        errors.add("passwordagain",new
> > ActionError("errors.passwordnotmatch"));
> >
> >                 return errors;
> >
> >
> >         }
> >
> >
> > Code END----------------------------------------------------------
> >
> > Patrice wrote:
> > >
> > > I don't see anything wrong...
> > > All I know is that empty String is returned when the key on an
> ActionError
> > > is not present in the default application resource files (defined in
> > > web.xml).
> >
> > Yes. I make some confusion and has 2 application.properties on the
> > structure. Thanks for the tip.
> >
> > > Best regards
> > > Patrice
> > >
> > > ----- Original Message -----
> > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Wednesday, November 27, 2002 12:44 PM
> > > Subject: Re: perform() or execute()? (Mistery)
> > >
> > > >
> > > > I check that an all is ok.
> > > > On the truth, the method is executed and the variables checked, the
> > > > errors "listed" on the original form , but they is empty strings
> > > > (?!?!?!?!) I just dont understand....
> > > >
> > > > Patrice wrote:
> > > > >
> > > > > Perhaps I miss something, but I don't see any problem in your code.
> > > > > Check that form implement ActionForm (and not ValidatorForm) to
> execute
> > > > > correctly the validate() method.
> > > > > Check also that you don't forget the <html:errors/> tag on your JSP.
> > > > >
> > > > > Hope it helps
> > > > > Patrice
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > > > Sent: Tuesday, November 26, 2002 9:40 PM
> > > > > Subject: Re: perform() or execute()?
> > > > >
> > > > > >
> > > > > > I try it again, from the beginning and now this works. I don know
> what
> > > > > > I do before but I am happy now. Thanks for David and Patrice to
> help
> > > me.
> > > > > > Now I have a new (and diferent) problem. I construct the follow
> > > > > > validate() in a ActionForm class:
> > > > > >
> > > > > >
> > > > > > CODE BEGIN-----------------------------------
> > > > > >
> > > > > > public ActionErrors validate(ActionMapping mapping,
> HttpServletRequest
> > > > > > request) {
> > > > > >
> > > > > > ActionErrors errors = new ActionErrors();
> > > > > >
> > > > > > if ((username == null) || (username.length() < 1))
> > > > > > errors.add("username", new ActionError("errors.nousername"));
> > > > > >
> > > > > > if ((password == null) || (username.length() < 1))
> > > > > >                 errors.add("password", new
> > > > > > ActionError("errors.nopassword"));
> > > > > >
> > > > > >         if ( !password.equals(again))
> > > > > >                 errors.add("passwordagain",new
> > > > > > ActionError("errors.passwordnotmatch"));
> > > > > >
> > > > > > return errors;
> > > > > > }
> > > > > >
> > > > > > CODE
> > > END----------------------------------------------------------------
> > > > > >
> > > > > > ...and I have the follow entrys on my message resource file:
> > > > > >
> > > > > > FILE BEGIN
> > > > > > (application.properties)------------------------------------------
> > > > > >
> > > > > > # -- standard errors --
> > > > > > errors.nousername=O campo username deve ser preenchido
> > > > > > errors.nopassword=O campo senha deve ser preenchido
> > > > > > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > > > > > errors.header=<UL>
> > > > > > errors.prefix=<LI>
> > > > > > errors.suffix=</LI>
> > > > > > errors.footer=</UL>
> > > > > > # -- validator --
> > > > > > errors.invalid={0} is invalid.
> > > > > > errors.maxlength={0} can not be greater than {1} characters.
> > > > > > errors.minlength={0} can not be less than {1} characters.
> > > > > > ------------------------------------------------------------------
> > > > > >
> > > > > > .... The behavior on form looks like OK, but the messages (inside
> the
> > > > > > <li> and </li>) are empty. No errors, behavior ok but empty
> Strings.
> > > > > > Please, can someone help to me again? Thanks a lot.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Patrice wrote:
> > > > > > >
> > > > > > > ----- Original Message -----
> > > > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > > > To: <st...@jakarta.apache.org>
> > > > > > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > > > > > Subject: perform() or execute()?
> > > > > > >
> > > > > > > > Hi, people!
> > > > > > > >
> > > > > > > > I am trying to develop a little system in struts for 3 weeks
> now
> > > and I
> > > > > > > > can't solve some (very basic) problems. I try read the
> > > documentations,
> > > > > > > > but some I can resolve anyway. Please, I need some help!
> > > > > > > > My questions:
> > > > > > > >
> > > > > > > > 1. When I try to use the execute() in a Action, the method is
> nota
> > > > > > > > called. When I try with perform() works fine, but I known this
> is
> > > > > > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same
> > > result).
> > > > > > >
> > > > > > > The  method has been deprecated since struts 1.1: so it can't
> work
> > > in
> > > > > struts
> > > > > > > 1.0.2
> > > > > > >
> > > > > > > > 2. I try to prepopulate a form (request scope) and does not
> works.
> > > I
> > > > > > > > try to set: request.setAttribute("myfield","myvalue"), and
> > > nothing.
> > > > > > >
> > > > > > > To populate a form from an action, you need to cast the
> ActionForm
> > > > > passed as
> > > > > > > parameter to the perform (or execute) method of your action and
> > > then,
> > > > > set
> > > > > > > the different properties to the appropriate values:
> > > > > > > for example:
> > > > > > >
> > > > > > > MyForm myForm = (MyForm) form;
> > > > > > > myForm.setMyField("myValue");
> > > > > > >
> > > > > > > > 3. To prepopulate a Form, I must to call a Action, prepopulate
> a
> > > bean
> > > > > > > > and then call a Form? That right?
> > > > > > >
> > > > > > > I don't know what you mean with "call a Form".
> > > > > > > You just need to set the properties of the form with the values
> you
> > > want
> > > > > > > Then, the taglib will display the values in the field of the
> form,
> > > on
> > > > > your
> > > > > > > JSP.
> > > > > > >
> > > > > > > >
> > > > > > > > Please, I need some help. Thanks to all.
> > > > > > > >
> > > > > > >
> > > > > > > Hope it helps
> > > > > > > Patrice
> > > > > > >
> > > > > > > --
> > > > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > >
> > > > > > --
> > > > > >         CUL8R,[]s
> > > > > >     Jim Bruno Goldberg
> > > > > > http://www.prosites.com.br
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > > > --
> > > >         CUL8R,[]s
> > > >     Jim Bruno Goldberg
> > > > http://www.prosites.com.br
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> >         CUL8R,[]s
> >     Jim Bruno Goldberg
> > http://www.prosites.com.br
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
        CUL8R,[]s
    Jim Bruno Goldberg
http://www.prosites.com.br

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: validate() almost working.....

Posted by Patrice <pp...@nerim.net>.
I suppose that's because you have declared a name in your <html:form> tag
that is not corresponds to those on the struts-config.xml file.
The attributes "type" and "name" of the <html:form> tag are deprecated in
Struts 1.1.

Try to replace:
<html:form action="UserForm" type="UserForm" name="TheForm">

with:
<html:form action="UserForm">

Regards
Patrice

----- Original Message -----
From: "Jim Bruno Goldberg" <go...@prosites.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 27, 2002 5:36 PM
Subject: validate() almost working.....


> My code is aslmost working....
> Validation and messages are ok. Now I need to solve one more
> problem....
> When these validate function returns some errors, and forward back to
> form,jsp, the fields are empty. Follow I put the code, the page and the
> struts-config. Whats wrong?
>
> struts-config BEGIN-------------------------------------------------
>
> <form-bean name="UserForm"      type="UserForm"/>
>
>          <action
>                 path="/UserForm"
>                 type="UserFormAction"
>                 name="UserForm"
>                 scope="request"
>                 input="/groups/user_form.jsp">
>         </action>
>
>
> struts-config END-------------------------------------------------
>
> Jsp BEGIN---------------------------------------------------------
> <html>
> <body>
> <html:form action="UserForm" type="UserForm" name="TheForm">
> Usename:<html:text property="username" size="60" /><br>
> Password:<html:password property="password" size="60"/><br>
> Retype:<html:password property="passwordagain" size="60"/><br>
> <a href='/parker/team/usuarios.htm'>[Cancela]</a> <a
> href='javascript:TheForm.submit();'>[Adiciona]</a><br>
> </html:form>
> </body>
> </html>
> Jsp END-----------------------------------------------------------
>
>
>
> Code BEGIN--------------------------------------------------------
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request) {
>
>                 ActionErrors errors = new ActionErrors();
>
>                 servlet.log("Validating UserForm");
>
>                 if ((username == null) || (username.length() < 1))
>                         errors.add("username", new
> ActionError("errors.nousername"));
>
>                 if ((password == null) || (password.length() < 1))
>                        errors.add("password", new
> ActionError("errors.nopassword"));
>
>
>                 if ( !password.equals(again))
>                        errors.add("passwordagain",new
> ActionError("errors.passwordnotmatch"));
>
>                 return errors;
>
>
>         }
>
>
> Code END----------------------------------------------------------
>
> Patrice wrote:
> >
> > I don't see anything wrong...
> > All I know is that empty String is returned when the key on an
ActionError
> > is not present in the default application resource files (defined in
> > web.xml).
>
> Yes. I make some confusion and has 2 application.properties on the
> structure. Thanks for the tip.
>
> > Best regards
> > Patrice
> >
> > ----- Original Message -----
> > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, November 27, 2002 12:44 PM
> > Subject: Re: perform() or execute()? (Mistery)
> >
> > >
> > > I check that an all is ok.
> > > On the truth, the method is executed and the variables checked, the
> > > errors "listed" on the original form , but they is empty strings
> > > (?!?!?!?!) I just dont understand....
> > >
> > > Patrice wrote:
> > > >
> > > > Perhaps I miss something, but I don't see any problem in your code.
> > > > Check that form implement ActionForm (and not ValidatorForm) to
execute
> > > > correctly the validate() method.
> > > > Check also that you don't forget the <html:errors/> tag on your JSP.
> > > >
> > > > Hope it helps
> > > > Patrice
> > > >
> > > > ----- Original Message -----
> > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > > Sent: Tuesday, November 26, 2002 9:40 PM
> > > > Subject: Re: perform() or execute()?
> > > >
> > > > >
> > > > > I try it again, from the beginning and now this works. I don know
what
> > > > > I do before but I am happy now. Thanks for David and Patrice to
help
> > me.
> > > > > Now I have a new (and diferent) problem. I construct the follow
> > > > > validate() in a ActionForm class:
> > > > >
> > > > >
> > > > > CODE BEGIN-----------------------------------
> > > > >
> > > > > public ActionErrors validate(ActionMapping mapping,
HttpServletRequest
> > > > > request) {
> > > > >
> > > > > ActionErrors errors = new ActionErrors();
> > > > >
> > > > > if ((username == null) || (username.length() < 1))
> > > > > errors.add("username", new ActionError("errors.nousername"));
> > > > >
> > > > > if ((password == null) || (username.length() < 1))
> > > > >                 errors.add("password", new
> > > > > ActionError("errors.nopassword"));
> > > > >
> > > > >         if ( !password.equals(again))
> > > > >                 errors.add("passwordagain",new
> > > > > ActionError("errors.passwordnotmatch"));
> > > > >
> > > > > return errors;
> > > > > }
> > > > >
> > > > > CODE
> > END----------------------------------------------------------------
> > > > >
> > > > > ...and I have the follow entrys on my message resource file:
> > > > >
> > > > > FILE BEGIN
> > > > > (application.properties)------------------------------------------
> > > > >
> > > > > # -- standard errors --
> > > > > errors.nousername=O campo username deve ser preenchido
> > > > > errors.nopassword=O campo senha deve ser preenchido
> > > > > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > > > > errors.header=<UL>
> > > > > errors.prefix=<LI>
> > > > > errors.suffix=</LI>
> > > > > errors.footer=</UL>
> > > > > # -- validator --
> > > > > errors.invalid={0} is invalid.
> > > > > errors.maxlength={0} can not be greater than {1} characters.
> > > > > errors.minlength={0} can not be less than {1} characters.
> > > > > ------------------------------------------------------------------
> > > > >
> > > > > .... The behavior on form looks like OK, but the messages (inside
the
> > > > > <li> and </li>) are empty. No errors, behavior ok but empty
Strings.
> > > > > Please, can someone help to me again? Thanks a lot.
> > > > >
> > > > >
> > > > >
> > > > > Patrice wrote:
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > > To: <st...@jakarta.apache.org>
> > > > > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > > > > Subject: perform() or execute()?
> > > > > >
> > > > > > > Hi, people!
> > > > > > >
> > > > > > > I am trying to develop a little system in struts for 3 weeks
now
> > and I
> > > > > > > can't solve some (very basic) problems. I try read the
> > documentations,
> > > > > > > but some I can resolve anyway. Please, I need some help!
> > > > > > > My questions:
> > > > > > >
> > > > > > > 1. When I try to use the execute() in a Action, the method is
nota
> > > > > > > called. When I try with perform() works fine, but I known this
is
> > > > > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same
> > result).
> > > > > >
> > > > > > The  method has been deprecated since struts 1.1: so it can't
work
> > in
> > > > struts
> > > > > > 1.0.2
> > > > > >
> > > > > > > 2. I try to prepopulate a form (request scope) and does not
works.
> > I
> > > > > > > try to set: request.setAttribute("myfield","myvalue"), and
> > nothing.
> > > > > >
> > > > > > To populate a form from an action, you need to cast the
ActionForm
> > > > passed as
> > > > > > parameter to the perform (or execute) method of your action and
> > then,
> > > > set
> > > > > > the different properties to the appropriate values:
> > > > > > for example:
> > > > > >
> > > > > > MyForm myForm = (MyForm) form;
> > > > > > myForm.setMyField("myValue");
> > > > > >
> > > > > > > 3. To prepopulate a Form, I must to call a Action, prepopulate
a
> > bean
> > > > > > > and then call a Form? That right?
> > > > > >
> > > > > > I don't know what you mean with "call a Form".
> > > > > > You just need to set the properties of the form with the values
you
> > want
> > > > > > Then, the taglib will display the values in the field of the
form,
> > on
> > > > your
> > > > > > JSP.
> > > > > >
> > > > > > >
> > > > > > > Please, I need some help. Thanks to all.
> > > > > > >
> > > > > >
> > > > > > Hope it helps
> > > > > > Patrice
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > > > --
> > > > >         CUL8R,[]s
> > > > >     Jim Bruno Goldberg
> > > > > http://www.prosites.com.br
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > > --
> > >         CUL8R,[]s
> > >     Jim Bruno Goldberg
> > > http://www.prosites.com.br
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
>         CUL8R,[]s
>     Jim Bruno Goldberg
> http://www.prosites.com.br
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


validate() almost working.....

Posted by Jim Bruno Goldberg <go...@prosites.com.br>.
	My code is aslmost working....
	Validation and messages are ok. Now I need to solve one more
problem.... 
	When these validate function returns some errors, and forward back to
form,jsp, the fields are empty. Follow I put the code, the page and the
struts-config. Whats wrong?

struts-config BEGIN-------------------------------------------------

	<form-bean name="UserForm"      type="UserForm"/>

         <action
                path="/UserForm"
                type="UserFormAction"
                name="UserForm"
                scope="request"
                input="/groups/user_form.jsp">
        </action>


struts-config END-------------------------------------------------

Jsp BEGIN---------------------------------------------------------
<html>
<body>
<html:form action="UserForm" type="UserForm" name="TheForm">
Usename:<html:text property="username" size="60" /><br>
Password:<html:password property="password" size="60"/><br>
Retype:<html:password property="passwordagain" size="60"/><br>
<a href='/parker/team/usuarios.htm'>[Cancela]</a> <a
href='javascript:TheForm.submit();'>[Adiciona]</a><br>
</html:form>
</body>
</html>
Jsp END-----------------------------------------------------------



Code BEGIN--------------------------------------------------------
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {

                ActionErrors errors = new ActionErrors();

                servlet.log("Validating UserForm");

                if ((username == null) || (username.length() < 1))
                        errors.add("username", new
ActionError("errors.nousername"));

                if ((password == null) || (password.length() < 1))
                       errors.add("password", new
ActionError("errors.nopassword"));


                if ( !password.equals(again))
                       errors.add("passwordagain",new
ActionError("errors.passwordnotmatch"));

                return errors;


        }


Code END----------------------------------------------------------

Patrice wrote:
> 
> I don't see anything wrong...
> All I know is that empty String is returned when the key on an ActionError
> is not present in the default application resource files (defined in
> web.xml).

	Yes. I make some confusion and has 2 application.properties on the
structure. Thanks for the tip.
 
> Best regards
> Patrice
> 
> ----- Original Message -----
> From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 27, 2002 12:44 PM
> Subject: Re: perform() or execute()? (Mistery)
> 
> >
> > I check that an all is ok.
> > On the truth, the method is executed and the variables checked, the
> > errors "listed" on the original form , but they is empty strings
> > (?!?!?!?!) I just dont understand....
> >
> > Patrice wrote:
> > >
> > > Perhaps I miss something, but I don't see any problem in your code.
> > > Check that form implement ActionForm (and not ValidatorForm) to execute
> > > correctly the validate() method.
> > > Check also that you don't forget the <html:errors/> tag on your JSP.
> > >
> > > Hope it helps
> > > Patrice
> > >
> > > ----- Original Message -----
> > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Tuesday, November 26, 2002 9:40 PM
> > > Subject: Re: perform() or execute()?
> > >
> > > >
> > > > I try it again, from the beginning and now this works. I don know what
> > > > I do before but I am happy now. Thanks for David and Patrice to help
> me.
> > > > Now I have a new (and diferent) problem. I construct the follow
> > > > validate() in a ActionForm class:
> > > >
> > > >
> > > > CODE BEGIN-----------------------------------
> > > >
> > > > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > > > request) {
> > > >
> > > > ActionErrors errors = new ActionErrors();
> > > >
> > > > if ((username == null) || (username.length() < 1))
> > > > errors.add("username", new ActionError("errors.nousername"));
> > > >
> > > > if ((password == null) || (username.length() < 1))
> > > >                 errors.add("password", new
> > > > ActionError("errors.nopassword"));
> > > >
> > > >         if ( !password.equals(again))
> > > >                 errors.add("passwordagain",new
> > > > ActionError("errors.passwordnotmatch"));
> > > >
> > > > return errors;
> > > > }
> > > >
> > > > CODE
> END----------------------------------------------------------------
> > > >
> > > > ...and I have the follow entrys on my message resource file:
> > > >
> > > > FILE BEGIN
> > > > (application.properties)------------------------------------------
> > > >
> > > > # -- standard errors --
> > > > errors.nousername=O campo username deve ser preenchido
> > > > errors.nopassword=O campo senha deve ser preenchido
> > > > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > > > errors.header=<UL>
> > > > errors.prefix=<LI>
> > > > errors.suffix=</LI>
> > > > errors.footer=</UL>
> > > > # -- validator --
> > > > errors.invalid={0} is invalid.
> > > > errors.maxlength={0} can not be greater than {1} characters.
> > > > errors.minlength={0} can not be less than {1} characters.
> > > > ------------------------------------------------------------------
> > > >
> > > > .... The behavior on form looks like OK, but the messages (inside the
> > > > <li> and </li>) are empty. No errors, behavior ok but empty Strings.
> > > > Please, can someone help to me again? Thanks a lot.
> > > >
> > > >
> > > >
> > > > Patrice wrote:
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > > To: <st...@jakarta.apache.org>
> > > > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > > > Subject: perform() or execute()?
> > > > >
> > > > > > Hi, people!
> > > > > >
> > > > > > I am trying to develop a little system in struts for 3 weeks now
> and I
> > > > > > can't solve some (very basic) problems. I try read the
> documentations,
> > > > > > but some I can resolve anyway. Please, I need some help!
> > > > > > My questions:
> > > > > >
> > > > > > 1. When I try to use the execute() in a Action, the method is nota
> > > > > > called. When I try with perform() works fine, but I known this is
> > > > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same
> result).
> > > > >
> > > > > The  method has been deprecated since struts 1.1: so it can't work
> in
> > > struts
> > > > > 1.0.2
> > > > >
> > > > > > 2. I try to prepopulate a form (request scope) and does not works.
> I
> > > > > > try to set: request.setAttribute("myfield","myvalue"), and
> nothing.
> > > > >
> > > > > To populate a form from an action, you need to cast the ActionForm
> > > passed as
> > > > > parameter to the perform (or execute) method of your action and
> then,
> > > set
> > > > > the different properties to the appropriate values:
> > > > > for example:
> > > > >
> > > > > MyForm myForm = (MyForm) form;
> > > > > myForm.setMyField("myValue");
> > > > >
> > > > > > 3. To prepopulate a Form, I must to call a Action, prepopulate a
> bean
> > > > > > and then call a Form? That right?
> > > > >
> > > > > I don't know what you mean with "call a Form".
> > > > > You just need to set the properties of the form with the values you
> want
> > > > > Then, the taglib will display the values in the field of the form,
> on
> > > your
> > > > > JSP.
> > > > >
> > > > > >
> > > > > > Please, I need some help. Thanks to all.
> > > > > >
> > > > >
> > > > > Hope it helps
> > > > > Patrice
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > > > --
> > > >         CUL8R,[]s
> > > >     Jim Bruno Goldberg
> > > > http://www.prosites.com.br
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> >         CUL8R,[]s
> >     Jim Bruno Goldberg
> > http://www.prosites.com.br
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
        CUL8R,[]s
    Jim Bruno Goldberg
http://www.prosites.com.br

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: perform() or execute()? (Mistery)

Posted by Patrice <pp...@nerim.net>.
I don't see anything wrong...
All I know is that empty String is returned when the key on an ActionError
is not present in the default application resource files (defined in
web.xml).

Best regards
Patrice

----- Original Message -----
From: "Jim Bruno Goldberg" <go...@prosites.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 27, 2002 12:44 PM
Subject: Re: perform() or execute()? (Mistery)


>
> I check that an all is ok.
> On the truth, the method is executed and the variables checked, the
> errors "listed" on the original form , but they is empty strings
> (?!?!?!?!) I just dont understand....
>
> Patrice wrote:
> >
> > Perhaps I miss something, but I don't see any problem in your code.
> > Check that form implement ActionForm (and not ValidatorForm) to execute
> > correctly the validate() method.
> > Check also that you don't forget the <html:errors/> tag on your JSP.
> >
> > Hope it helps
> > Patrice
> >
> > ----- Original Message -----
> > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Tuesday, November 26, 2002 9:40 PM
> > Subject: Re: perform() or execute()?
> >
> > >
> > > I try it again, from the beginning and now this works. I don know what
> > > I do before but I am happy now. Thanks for David and Patrice to help
me.
> > > Now I have a new (and diferent) problem. I construct the follow
> > > validate() in a ActionForm class:
> > >
> > >
> > > CODE BEGIN-----------------------------------
> > >
> > > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > > request) {
> > >
> > > ActionErrors errors = new ActionErrors();
> > >
> > > if ((username == null) || (username.length() < 1))
> > > errors.add("username", new ActionError("errors.nousername"));
> > >
> > > if ((password == null) || (username.length() < 1))
> > >                 errors.add("password", new
> > > ActionError("errors.nopassword"));
> > >
> > >         if ( !password.equals(again))
> > >                 errors.add("passwordagain",new
> > > ActionError("errors.passwordnotmatch"));
> > >
> > > return errors;
> > > }
> > >
> > > CODE
END----------------------------------------------------------------
> > >
> > > ...and I have the follow entrys on my message resource file:
> > >
> > > FILE BEGIN
> > > (application.properties)------------------------------------------
> > >
> > > # -- standard errors --
> > > errors.nousername=O campo username deve ser preenchido
> > > errors.nopassword=O campo senha deve ser preenchido
> > > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > > errors.header=<UL>
> > > errors.prefix=<LI>
> > > errors.suffix=</LI>
> > > errors.footer=</UL>
> > > # -- validator --
> > > errors.invalid={0} is invalid.
> > > errors.maxlength={0} can not be greater than {1} characters.
> > > errors.minlength={0} can not be less than {1} characters.
> > > ------------------------------------------------------------------
> > >
> > > .... The behavior on form looks like OK, but the messages (inside the
> > > <li> and </li>) are empty. No errors, behavior ok but empty Strings.
> > > Please, can someone help to me again? Thanks a lot.
> > >
> > >
> > >
> > > Patrice wrote:
> > > >
> > > > ----- Original Message -----
> > > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > > To: <st...@jakarta.apache.org>
> > > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > > Subject: perform() or execute()?
> > > >
> > > > > Hi, people!
> > > > >
> > > > > I am trying to develop a little system in struts for 3 weeks now
and I
> > > > > can't solve some (very basic) problems. I try read the
documentations,
> > > > > but some I can resolve anyway. Please, I need some help!
> > > > > My questions:
> > > > >
> > > > > 1. When I try to use the execute() in a Action, the method is nota
> > > > > called. When I try with perform() works fine, but I known this is
> > > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same
result).
> > > >
> > > > The  method has been deprecated since struts 1.1: so it can't work
in
> > struts
> > > > 1.0.2
> > > >
> > > > > 2. I try to prepopulate a form (request scope) and does not works.
I
> > > > > try to set: request.setAttribute("myfield","myvalue"), and
nothing.
> > > >
> > > > To populate a form from an action, you need to cast the ActionForm
> > passed as
> > > > parameter to the perform (or execute) method of your action and
then,
> > set
> > > > the different properties to the appropriate values:
> > > > for example:
> > > >
> > > > MyForm myForm = (MyForm) form;
> > > > myForm.setMyField("myValue");
> > > >
> > > > > 3. To prepopulate a Form, I must to call a Action, prepopulate a
bean
> > > > > and then call a Form? That right?
> > > >
> > > > I don't know what you mean with "call a Form".
> > > > You just need to set the properties of the form with the values you
want
> > > > Then, the taglib will display the values in the field of the form,
on
> > your
> > > > JSP.
> > > >
> > > > >
> > > > > Please, I need some help. Thanks to all.
> > > > >
> > > >
> > > > Hope it helps
> > > > Patrice
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > > --
> > >         CUL8R,[]s
> > >     Jim Bruno Goldberg
> > > http://www.prosites.com.br
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
>         CUL8R,[]s
>     Jim Bruno Goldberg
> http://www.prosites.com.br
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: perform() or execute()? (Mistery)

Posted by Jim Bruno Goldberg <go...@prosites.com.br>.
	I check that an all is ok.
	On the truth, the method is executed and the variables checked, the
errors "listed" on the original form , but they is empty strings
(?!?!?!?!) I just dont understand....

Patrice wrote:
> 
> Perhaps I miss something, but I don't see any problem in your code.
> Check that form implement ActionForm (and not ValidatorForm) to execute
> correctly the validate() method.
> Check also that you don't forget the <html:errors/> tag on your JSP.
> 
> Hope it helps
> Patrice
> 
> ----- Original Message -----
> From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, November 26, 2002 9:40 PM
> Subject: Re: perform() or execute()?
> 
> >
> > I try it again, from the beginning and now this works. I don know what
> > I do before but I am happy now. Thanks for David and Patrice to help me.
> > Now I have a new (and diferent) problem. I construct the follow
> > validate() in a ActionForm class:
> >
> >
> > CODE BEGIN-----------------------------------
> >
> > public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > request) {
> >
> > ActionErrors errors = new ActionErrors();
> >
> > if ((username == null) || (username.length() < 1))
> > errors.add("username", new ActionError("errors.nousername"));
> >
> > if ((password == null) || (username.length() < 1))
> >                 errors.add("password", new
> > ActionError("errors.nopassword"));
> >
> >         if ( !password.equals(again))
> >                 errors.add("passwordagain",new
> > ActionError("errors.passwordnotmatch"));
> >
> > return errors;
> > }
> >
> > CODE END----------------------------------------------------------------
> >
> > ...and I have the follow entrys on my message resource file:
> >
> > FILE BEGIN
> > (application.properties)------------------------------------------
> >
> > # -- standard errors --
> > errors.nousername=O campo username deve ser preenchido
> > errors.nopassword=O campo senha deve ser preenchido
> > errors.passwordnotmatch=As senhas digitadas devem ser iguais
> > errors.header=<UL>
> > errors.prefix=<LI>
> > errors.suffix=</LI>
> > errors.footer=</UL>
> > # -- validator --
> > errors.invalid={0} is invalid.
> > errors.maxlength={0} can not be greater than {1} characters.
> > errors.minlength={0} can not be less than {1} characters.
> > ------------------------------------------------------------------
> >
> > .... The behavior on form looks like OK, but the messages (inside the
> > <li> and </li>) are empty. No errors, behavior ok but empty Strings.
> > Please, can someone help to me again? Thanks a lot.
> >
> >
> >
> > Patrice wrote:
> > >
> > > ----- Original Message -----
> > > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > > To: <st...@jakarta.apache.org>
> > > Sent: Tuesday, November 26, 2002 6:27 PM
> > > Subject: perform() or execute()?
> > >
> > > > Hi, people!
> > > >
> > > > I am trying to develop a little system in struts for 3 weeks now and I
> > > > can't solve some (very basic) problems. I try read the documentations,
> > > > but some I can resolve anyway. Please, I need some help!
> > > > My questions:
> > > >
> > > > 1. When I try to use the execute() in a Action, the method is nota
> > > > called. When I try with perform() works fine, but I known this is
> > > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same result).
> > >
> > > The  method has been deprecated since struts 1.1: so it can't work in
> struts
> > > 1.0.2
> > >
> > > > 2. I try to prepopulate a form (request scope) and does not works. I
> > > > try to set: request.setAttribute("myfield","myvalue"), and nothing.
> > >
> > > To populate a form from an action, you need to cast the ActionForm
> passed as
> > > parameter to the perform (or execute) method of your action and then,
> set
> > > the different properties to the appropriate values:
> > > for example:
> > >
> > > MyForm myForm = (MyForm) form;
> > > myForm.setMyField("myValue");
> > >
> > > > 3. To prepopulate a Form, I must to call a Action, prepopulate a bean
> > > > and then call a Form? That right?
> > >
> > > I don't know what you mean with "call a Form".
> > > You just need to set the properties of the form with the values you want
> > > Then, the taglib will display the values in the field of the form, on
> your
> > > JSP.
> > >
> > > >
> > > > Please, I need some help. Thanks to all.
> > > >
> > >
> > > Hope it helps
> > > Patrice
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> >         CUL8R,[]s
> >     Jim Bruno Goldberg
> > http://www.prosites.com.br
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
        CUL8R,[]s
    Jim Bruno Goldberg
http://www.prosites.com.br

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: perform() or execute()?

Posted by Patrice <pp...@nerim.net>.
Perhaps I miss something, but I don't see any problem in your code.
Check that form implement ActionForm (and not ValidatorForm) to execute
correctly the validate() method.
Check also that you don't forget the <html:errors/> tag on your JSP.

Hope it helps
Patrice

----- Original Message -----
From: "Jim Bruno Goldberg" <go...@prosites.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, November 26, 2002 9:40 PM
Subject: Re: perform() or execute()?


>
> I try it again, from the beginning and now this works. I don know what
> I do before but I am happy now. Thanks for David and Patrice to help me.
> Now I have a new (and diferent) problem. I construct the follow
> validate() in a ActionForm class:
>
>
> CODE BEGIN-----------------------------------
>
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request) {
>
> ActionErrors errors = new ActionErrors();
>
> if ((username == null) || (username.length() < 1))
> errors.add("username", new ActionError("errors.nousername"));
>
> if ((password == null) || (username.length() < 1))
>                 errors.add("password", new
> ActionError("errors.nopassword"));
>
>         if ( !password.equals(again))
>                 errors.add("passwordagain",new
> ActionError("errors.passwordnotmatch"));
>
> return errors;
> }
>
> CODE END----------------------------------------------------------------
>
> ...and I have the follow entrys on my message resource file:
>
> FILE BEGIN
> (application.properties)------------------------------------------
>
> # -- standard errors --
> errors.nousername=O campo username deve ser preenchido
> errors.nopassword=O campo senha deve ser preenchido
> errors.passwordnotmatch=As senhas digitadas devem ser iguais
> errors.header=<UL>
> errors.prefix=<LI>
> errors.suffix=</LI>
> errors.footer=</UL>
> # -- validator --
> errors.invalid={0} is invalid.
> errors.maxlength={0} can not be greater than {1} characters.
> errors.minlength={0} can not be less than {1} characters.
> ------------------------------------------------------------------
>
> .... The behavior on form looks like OK, but the messages (inside the
> <li> and </li>) are empty. No errors, behavior ok but empty Strings.
> Please, can someone help to me again? Thanks a lot.
>
>
>
> Patrice wrote:
> >
> > ----- Original Message -----
> > From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, November 26, 2002 6:27 PM
> > Subject: perform() or execute()?
> >
> > > Hi, people!
> > >
> > > I am trying to develop a little system in struts for 3 weeks now and I
> > > can't solve some (very basic) problems. I try read the documentations,
> > > but some I can resolve anyway. Please, I need some help!
> > > My questions:
> > >
> > > 1. When I try to use the execute() in a Action, the method is nota
> > > called. When I try with perform() works fine, but I known this is
> > > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same result).
> >
> > The  method has been deprecated since struts 1.1: so it can't work in
struts
> > 1.0.2
> >
> > > 2. I try to prepopulate a form (request scope) and does not works. I
> > > try to set: request.setAttribute("myfield","myvalue"), and nothing.
> >
> > To populate a form from an action, you need to cast the ActionForm
passed as
> > parameter to the perform (or execute) method of your action and then,
set
> > the different properties to the appropriate values:
> > for example:
> >
> > MyForm myForm = (MyForm) form;
> > myForm.setMyField("myValue");
> >
> > > 3. To prepopulate a Form, I must to call a Action, prepopulate a bean
> > > and then call a Form? That right?
> >
> > I don't know what you mean with "call a Form".
> > You just need to set the properties of the form with the values you want
> > Then, the taglib will display the values in the field of the form, on
your
> > JSP.
> >
> > >
> > > Please, I need some help. Thanks to all.
> > >
> >
> > Hope it helps
> > Patrice
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
>         CUL8R,[]s
>     Jim Bruno Goldberg
> http://www.prosites.com.br
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: perform() or execute()?

Posted by Jim Bruno Goldberg <go...@prosites.com.br>.
	I try it again, from the beginning and now this works. I don know what
I do before but I am happy now. Thanks for David and Patrice to help me.
	Now I have a new (and diferent) problem. I construct the follow
validate() in a ActionForm class:


CODE BEGIN-----------------------------------

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {

	ActionErrors errors = new ActionErrors();

	if ((username == null) || (username.length() < 1))
		errors.add("username", new ActionError("errors.nousername"));

	if ((password == null) || (username.length() < 1))
                errors.add("password", new
ActionError("errors.nopassword"));

        if ( !password.equals(again))
                errors.add("passwordagain",new
ActionError("errors.passwordnotmatch"));

	return errors;
}

CODE END----------------------------------------------------------------

...and I have the follow entrys on my message resource file:

FILE BEGIN
(application.properties)------------------------------------------

# -- standard errors --
errors.nousername=O campo username deve ser preenchido
errors.nopassword=O campo senha deve ser preenchido
errors.passwordnotmatch=As senhas digitadas devem ser iguais
errors.header=<UL>
errors.prefix=<LI>
errors.suffix=</LI>
errors.footer=</UL>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
------------------------------------------------------------------

.... The behavior on form looks like OK, but the messages (inside the
<li> and </li>) are empty. No errors, behavior ok but empty Strings.
Please, can someone help to me again? Thanks a lot.



Patrice wrote:
> 
> ----- Original Message -----
> From: "Jim Bruno Goldberg" <go...@prosites.com.br>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, November 26, 2002 6:27 PM
> Subject: perform() or execute()?
> 
> > Hi, people!
> >
> > I am trying to develop a little system in struts for 3 weeks now and I
> > can't solve some (very basic) problems. I try read the documentations,
> > but some I can resolve anyway. Please, I need some help!
> > My questions:
> >
> > 1. When I try to use the execute() in a Action, the method is nota
> > called. When I try with perform() works fine, but I known this is
> > deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same result).
> 
> The  method has been deprecated since struts 1.1: so it can't work in struts
> 1.0.2
> 
> > 2. I try to prepopulate a form (request scope) and does not works. I
> > try to set: request.setAttribute("myfield","myvalue"), and nothing.
> 
> To populate a form from an action, you need to cast the ActionForm passed as
> parameter to the perform (or execute) method of your action and then, set
> the different properties to the appropriate values:
> for example:
> 
> MyForm myForm = (MyForm) form;
> myForm.setMyField("myValue");
> 
> > 3. To prepopulate a Form, I must to call a Action, prepopulate a bean
> > and then call a Form? That right?
> 
> I don't know what you mean with "call a Form".
> You just need to set the properties of the form with the values you want
> Then, the taglib will display the values in the field of the form, on your
> JSP.
> 
> >
> > Please, I need some help. Thanks to all.
> >
> 
> Hope it helps
> Patrice
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
        CUL8R,[]s
    Jim Bruno Goldberg
http://www.prosites.com.br

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: perform() or execute()?

Posted by Patrice <pp...@nerim.net>.
----- Original Message -----
From: "Jim Bruno Goldberg" <go...@prosites.com.br>
To: <st...@jakarta.apache.org>
Sent: Tuesday, November 26, 2002 6:27 PM
Subject: perform() or execute()?


> Hi, people!
>
> I am trying to develop a little system in struts for 3 weeks now and I
> can't solve some (very basic) problems. I try read the documentations,
> but some I can resolve anyway. Please, I need some help!
> My questions:
>
> 1. When I try to use the execute() in a Action, the method is nota
> called. When I try with perform() works fine, but I known this is
> deprecaced..... (I try struts 1.0.2 and now struts 1.1 - same result).

The  method has been deprecated since struts 1.1: so it can't work in struts
1.0.2

> 2. I try to prepopulate a form (request scope) and does not works. I
> try to set: request.setAttribute("myfield","myvalue"), and nothing.

To populate a form from an action, you need to cast the ActionForm passed as
parameter to the perform (or execute) method of your action and then, set
the different properties to the appropriate values:
for example:

MyForm myForm = (MyForm) form;
myForm.setMyField("myValue");

> 3. To prepopulate a Form, I must to call a Action, prepopulate a bean
> and then call a Form? That right?

I don't know what you mean with "call a Form".
You just need to set the properties of the form with the values you want
Then, the taglib will display the values in the field of the form, on your
JSP.

>
> Please, I need some help. Thanks to all.
>

Hope it helps
Patrice


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>