If you give validate=true then you need to give input parameter in the
struts-config as well. One more thing - in your JSP try using the following
code:

<logic:messagesPresent>
  <html:messages id="errorMess">
      <bean:write name="errorMess"/>
  </html:messages id="errorMess">
</logic:messagesPresent>

If you have HTML tags as part of the messages in
ApplicationResources.properties then you will have to add - "filter = false"
to the bean:write tag. This will allow the HTML to be rendered properly, ie
it will not escape those HTML characters.

~madhav

On 6/21/06, Medicherla Lakshmi <[EMAIL PROTECTED]> wrote:

Yes, i have validate="true" set in my struts-config.xml.  Here's my code.

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
        ActionErrors errors = new ActionErrors();
        if (getUsername() == null || getUsername().length() < 1) {
            errors.add("username", new ActionMessage("error.name.required
"));
        }
        if(getPassword() == null || getPassword().length() <1){
            errors.add("password", new ActionMessage("
error.password.required"));
        }
        return errors;
    }

  This is in ActionForm and the corresponding struts-config.xml is
  <action input="/Login.jsp" type="com.myapp.struts.LookupAction"
scope="request" path="/login" name="LookupForm" validate="true">
            <forward name="success" path="/menuitems.jsp"/>
            <forward name="failure" path="/Login.jsp"/>
  </action>

  In the jsp i specified as <html:errors/> before </html:form>.
  Please tel me if there is any error in my code.

David Friedman <[EMAIL PROTECTED]> wrote:
  Can you post a code snipper for your ActionForm? Do you invoked the
form's
validate() method directly in your Action or do you have the mapping set
with validate="true" ?

Regards,
David

-----Original Message-----
From: Medicherla Lakshmi [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 21, 2006 12:19 AM
To: Struts Users Mailing List
Subject: Re: ActionErrors not being displayed in jsp


Hi,

Am not using validator.xml for validation. But just the Actionform
validate method to validate the username and password submitted without
values. I tried to use even ActionMessage in place of ActionError, but, my
jsp is not showing the error message.
Please Help.

Thank and Regards,
MSV Lakshmi.

Pankaj Gupta
wrote:
Use ActionMessages in place of ActionErrors.
See:
http://wiki.apache.org/struts/StrutsUpgradeNotes11to124

regards,
Pankaj

[EMAIL PROTECTED] wrote:
> Hi,
>
> public ActionErrors validate(ActionMapping actionMapping,
> HttpServletRequest httpServletRequest) {
>
> ActionErrors errors = new ActionErrors();
>
>
> if ((username == null) || (username.length() == 0)) {
> errors.add("username", new
>
> org.apache.struts.action.ActionError("error.login.username"));
> }
>
> if ((password == null) || (password.length() == 0)) {
> errors.add("password", new
>
> org.apache.struts.action.ActionError("error.login.password"));
> }
>
>
> return errors;
> }
>
> Add this code in your formbean. Ur formbean should extend ValidatorForm.
>
> In Jsp. Add this code in the jsp. It will be validation
> will be displayed.
>
>
> regards,
>
> Mansoor
>
>
>
>
>
>
> -----Original Message-----
> From: Medicherla Lakshmi [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 20, 2006 6:16 PM
> To: Struts Users Mailing List
> Subject: ActionErrors not being displayed in jsp
>
>
>
> HI,
>
> Can anyone please explain me how to validate a login page using
> validate method of actionform. Am not able to display the errors in my
> jsp page though i wrote in my jsp. Please give any
> example of using ActionErrors.
>
> Thanks and Regards,
> MSV Lakshmi.
>
>
> ---------------------------------
> Yahoo! India Answers: Share what you know. Learn something new Click
> here
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger
> Download now
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

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




---------------------------------
Yahoo! India Answers: Share what you know. Learn something new Click here
Send free SMS to your Friends on Mobile from your Yahoo! Messenger
Download
now


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




---------------------------------
  Yahoo! India Answers: Share what you know. Learn something new Click
here
Send free SMS to your Friends on Mobile from your Yahoo! Messenger
Download now




--
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do

Reply via email to