You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Priya Jotwani <Pr...@infosys.com> on 2004/10/05 19:27:30 UTC
Validation in Struts for Required fields
Hi ,
I have a JSP Page where I have two dropdowns displaying default values.
Before submitting that page, the user should select something from these
two dropdowns and if he doesn't selects, there should be an error
message displayed on the top saying "This field is required".
This is what I am doing but it doesn't gives me an error message and am
able to proceed to the next page. Any idea as to what could be possibly
wrong/missing ?
In my validator.xml , I have
<form name="ClientReportingForm">
<!-- Struts validation -->
<field property="reportType"
depends="required">
<arg0
key="prompt.reportType"/>
</field>
<field property="productLine"
depends="required">
<arg0 key="prompt.productLine"/>
</field>
</form>
In my ApplicationResources.properties I have
<prompt.reportType value= "Report Type"/>
<prompt.productLine value= "Product Line"/>
And in my JSP Page I have
<logic:messagesPresent message="error" >
<bean:message key="errors.header" />
<ul>
<font color="red"><b> <html:messages id="error">
<li><bean:write name="error" filter="false"
/></li>
</html:messages> </b> </font>
</ul>
<bean:message key="errors.footer" />
</logic:messagesPresent>
Thanks,
Priya
Re: Validation in Struts for Required fields
Posted by Erik Weber <er...@mindspring.com>.
In your JSP, where are your selects? Are you using html:select tags to
produce them?
Erik
Priya Jotwani wrote:
>Hi ,
>
>
>
>I have a JSP Page where I have two dropdowns displaying default values.
>Before submitting that page, the user should select something from these
>two dropdowns and if he doesn't selects, there should be an error
>message displayed on the top saying "This field is required".
>
>This is what I am doing but it doesn't gives me an error message and am
>able to proceed to the next page. Any idea as to what could be possibly
>wrong/missing ?
>
>
>
>In my validator.xml , I have
>
>
>
> <form name="ClientReportingForm">
>
> <!-- Struts validation -->
>
> <field property="reportType"
>depends="required">
>
> <arg0
>key="prompt.reportType"/>
>
> </field>
>
>
>
> <field property="productLine"
>depends="required">
>
> <arg0 key="prompt.productLine"/>
>
> </field>
>
>
>
> </form>
>
>
>
>In my ApplicationResources.properties I have
>
>
>
> <prompt.reportType value= "Report Type"/>
>
> <prompt.productLine value= "Product Line"/>
>
>
>
>And in my JSP Page I have
>
>
>
> <logic:messagesPresent message="error" >
>
> <bean:message key="errors.header" />
>
> <ul>
>
> <font color="red"><b> <html:messages id="error">
>
> <li><bean:write name="error" filter="false"
>/></li>
>
> </html:messages> </b> </font>
>
> </ul>
>
> <bean:message key="errors.footer" />
>
></logic:messagesPresent>
>
>
>
>
>
>Thanks,
>
>Priya
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org