You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rodrigo Pereira <ro...@gmail.com> on 2008/03/29 19:45:07 UTC

Validation

Hi,
how can I position validation message on the screen? Also, when I have
a simple theme form I am getting JS error alert message "[object
Error]", does anybody know how to fix that?

form:

<s:form id="testForm" action="save" method="post" validate="true">
	<table>			
		<tr>
			<td align="right"><s:text name="label.email"/><span
class="required">*</span>:</td>
			<td><s:textfield name="user.email" value="%{user.email}" size="30"
theme="simple"/></td>
		</tr>
	</table>
</s:form>

validation.xml:

<validators>

  <field name="user.email">  	

  	<field-validator type="required">
	        <message key="errors.email.required"/>
	  </field-validator>

	<field-validator type="email">
		<message key="errors.email.notValid" />
	</field-validator>

  </field>

</validators>

Thanks,
Rodrigo Pereira

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation

Posted by Kibo <to...@gmail.com>.
Hi

I had the same problem. The simplest is use the qxhtml theme.
See:
http://www.vitarara.org/cms/struts_2_cookbook/creating_a_theme

You can download the theme and use in Struts.
You can combine it with theme simple. See the source jsp page with form.

The second possibility is extend the simple theme and create own theme. 
See:
http://struts.apache.org/2.0.9/docs/extending-themes.html

Tomas Jurman
Czech Republic
-- 
View this message in context: http://www.nabble.com/Validation-tp16373207p16386425.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation

Posted by ravi_eze <ra...@ivycomptech.com>.
hey!

you can use theme="simple". This would generate the tags as a simple text
box etc with out any trs and tds around.

positioning the errors:
<s:fielderror>
     <s:param>fieldname</s:param>
</s:fielderror>

would display the erriors related to fieldname only. I think u can do the
similar way with action errors and actino messages. Give a try ;)

Hope I answered your question.

cheers,
ravi



Rodrigo Pereira wrote:
> 
> Hi,
> the problem is that I have a lot of fields and I'd like to position 2
> fields
> in a row, but xhrml theme is not letting me do that. Also, some of the
> fields are poputated by an action based on the value of one of the fields
> in
> the form (using xhtml triggers form's action vs link's). I was wondering
> if
> there is another option.
> 
> Thanks,
> Rodrigo Pereira
> 
> ----- Original Message ----- 
> From: "Nuwan Chandrasoma" <my...@gmail.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Saturday, March 29, 2008 6:12 PM
> Subject: Re: Validation
> 
> 
>> Hi,
>>
>> Simple theme doesn't support Validation and error reporting. you may have
>> to use some other theme like xhtml theme
>>
>> http://struts.apache.org/2.x/docs/xhtml-theme.html
>>
>> Thanks,
>>
>> Nuwan
>>
>> Rodrigo Pereira wrote:
>>> Hi,
>>> how can I position validation message on the screen? Also, when I have
>>> a simple theme form I am getting JS error alert message "[object
>>> Error]", does anybody know how to fix that?
>>>
>>> form:
>>>
>>> <s:form id="testForm" action="save" method="post" validate="true">
>>> <table> <tr>
>>> <td align="right"><s:text name="label.email"/>> class="required">*:</td>
>>> <td><s:textfield name="user.email" value="%{user.email}" size="30"
>>> theme="simple"/></td>
>>> </tr>
>>> </table>
>>> </s:form>
>>>
>>> validation.xml:
>>>
>>> <validators>
>>>
>>>   <field name="user.email">
>>>   <field-validator type="required">
>>>         <message key="errors.email.required"/>
>>>   </field-validator>
>>>
>>> <field-validator type="email">
>>> <message key="errors.email.notValid" />
>>> </field-validator>
>>>
>>>   </field>
>>>
>>> </validators>
>>>
>>> Thanks,
>>> Rodrigo Pereira
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Validation-tp16373207p16396501.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation

Posted by Rodrigo Pereira <ro...@gmail.com>.
Hi,
the problem is that I have a lot of fields and I'd like to position 2 fields
in a row, but xhrml theme is not letting me do that. Also, some of the
fields are poputated by an action based on the value of one of the fields in
the form (using xhtml triggers form's action vs link's). I was wondering if
there is another option.

Thanks,
Rodrigo Pereira

----- Original Message ----- 
From: "Nuwan Chandrasoma" <my...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Saturday, March 29, 2008 6:12 PM
Subject: Re: Validation


> Hi,
>
> Simple theme doesn't support Validation and error reporting. you may have
> to use some other theme like xhtml theme
>
> http://struts.apache.org/2.x/docs/xhtml-theme.html
>
> Thanks,
>
> Nuwan
>
> Rodrigo Pereira wrote:
>> Hi,
>> how can I position validation message on the screen? Also, when I have
>> a simple theme form I am getting JS error alert message "[object
>> Error]", does anybody know how to fix that?
>>
>> form:
>>
>> <s:form id="testForm" action="save" method="post" validate="true">
>> <table> <tr>
>> <td align="right"><s:text name="label.email"/><span
>> class="required">*</span>:</td>
>> <td><s:textfield name="user.email" value="%{user.email}" size="30"
>> theme="simple"/></td>
>> </tr>
>> </table>
>> </s:form>
>>
>> validation.xml:
>>
>> <validators>
>>
>>   <field name="user.email">
>>   <field-validator type="required">
>>         <message key="errors.email.required"/>
>>   </field-validator>
>>
>> <field-validator type="email">
>> <message key="errors.email.notValid" />
>> </field-validator>
>>
>>   </field>
>>
>> </validators>
>>
>> Thanks,
>> Rodrigo Pereira
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation

Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,

Simple theme doesn't support Validation and error reporting. you may 
have to use some other theme like xhtml theme

http://struts.apache.org/2.x/docs/xhtml-theme.html

Thanks,

Nuwan

Rodrigo Pereira wrote:
> Hi,
> how can I position validation message on the screen? Also, when I have
> a simple theme form I am getting JS error alert message "[object
> Error]", does anybody know how to fix that?
>
> form:
>
> <s:form id="testForm" action="save" method="post" validate="true">
> 	<table>			
> 		<tr>
> 			<td align="right"><s:text name="label.email"/><span
> class="required">*</span>:</td>
> 			<td><s:textfield name="user.email" value="%{user.email}" size="30"
> theme="simple"/></td>
> 		</tr>
> 	</table>
> </s:form>
>
> validation.xml:
>
> <validators>
>
>   <field name="user.email">  	
>
>   	<field-validator type="required">
> 	        <message key="errors.email.required"/>
> 	  </field-validator>
>
> 	<field-validator type="email">
> 		<message key="errors.email.notValid" />
> 	</field-validator>
>
>   </field>
>
> </validators>
>
> Thanks,
> Rodrigo Pereira
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org