Struts validation- placing error msgs

S

spb

hi,
i have a login form and i need to validate all the fields are required
as well as the email is a valid email. when i use the following code on
top it prints out the required error messages for all the fields but i
want it to print it out only once.
<logic:messagesPresent>
<div class="errorblock">
<html:errors />
</div>
</logic:messagesPresent>

i can do this by commenting out the <html:errors /> but then my global
error for email/user does not exist does not display.

please tell me how i can work around this. i am new to it and need to
get this working asap. apreciate any help.

thanks.
 
T

Tim B

spb said:
hi,
i have a login form and i need to validate all the fields are required
as well as the email is a valid email. when i use the following code on
top it prints out the required error messages for all the fields but i
want it to print it out only once.
<logic:messagesPresent>
<div class="errorblock">
<html:errors />
</div>
</logic:messagesPresent>

i can do this by commenting out the <html:errors /> but then my global
error for email/user does not exist does not display.

please tell me how i can work around this. i am new to it and need to
get this working asap. apreciate any help.

thanks.

I'm not sure exactly what you want, but I'm guessing you want to show only a
specific error message. It can be done like this:

<logic:messagesPresent>
<html:messages id="theError" property="myErrorName">
<bean:write name="theError"/>
</html:messages>
</logic:messagesPresent>

"myErrorName" is the name you save the error with, in your validation code
 
H

Hiran Chaudhuri

spb said:
i have a login form and i need to validate all the fields are required
as well as the email is a valid email. when i use the following code on
top it prints out the required error messages for all the fields but i
want it to print it out only once.

I'm not sure what you want. Do you want to see the messages generated by the
validation (i.e. the error messages) or do you not want to see them?

Taking a guess, your problem with email validation should be on the
validation side, which means either the validation framework (configured
with the struts xml configuration) or the action that validates before
calling the business logic. What you mention is just how the messages are
displayed.

Well then, that is what your subject line also says.....

Hiran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top