A. Lotfi wrote:
Hi,
I am trying to learn Struts validator, in the validator-rules.xml :
The validator-rules.xml specifies what validators are available to you.
You typically want to leave this alone. All your validation happens in
the validation.xml file. You specify rules in this file (such as
required, email, etc.), but rarely do you ever edit validator-rules.xml,
unless you download other special validators from somewhere, or write
your own.
in validation.xml :
........
<field property="email"
depends="email">
<arg0 key="prompt.email" />
</field>
<field property="url"
depends="email">
<arg0 key="prompt.url" />
</field>
If you intended to use the "required" validator (which ensures a field
is entered), you'll want to add it to your list of "depends":
<field property="email" depends="required,email">
<arg0 key="prompt.email" />
</field>
<field property="url" depends="required">
<arg0 key="prompt.url" />
</field>
I suspect you didn't want to use the "email" validator on the "url", as
urls are not e-mail addresses.
when I submit the form with correct data it does not submit I stay in the
same jsp page with a black dot in the top left of the page.
Could you please help me.
thank you.
Your form needs to submit to an action,
<html:form action="/submitMyForm">
...
<html:submit>Submit</html:submit>
</html:form>
and you need to have this action mapped in your struts-config.xml,
with a form bean:
<form-bean name="myForm" type="mypkg.MyForm" />
and an action class:
<action path="/submitMyForm" type="mypkg.MyFormAction" name="myForm"
scope="request" validate="true" input="myform.jsp">
<forward name="success" path="myform_success.jsp" />
<forward name="failure" path="myform.jsp" />
</action>
HTH,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]