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" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> 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" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > 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" <[EMAIL PROTECTED]>
> > > > > To: <[EMAIL PROTECTED]>
> > > > > 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:
> > > <mailto:[EMAIL PROTECTED]>
> > > > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > >
> > > > --
> > > >         CUL8R,[]s
> > > >     Jim Bruno Goldberg
> > > > http://www.prosites.com.br
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> > --
> >         CUL8R,[]s
> >     Jim Bruno Goldberg
> > http://www.prosites.com.br
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to