tags:

views:

433

answers:

2

Is it mandatory in struts2 to use struts-tags. I mean can't we use following:

<td bgcolor="DEDBC6"><div align="left"><font color="#000000"><strong> Employee Name * :</strong></font></div></td> <td><input name="empname" type="text" id="empname" size="32"></td>

instead of following:

<s:textfield label="Employee Salary " name="empsal" required="true"/>

I had tried both but when i used 1st i didn't get validation message i.e "empname is required" that i wrote in action-validation.xml although validation is working well. please comment ?

A: 

No, it is not mandatory. In fact a lot of struts2 users are sufficiently dissatisfied with OGNL and choose to use regular HTML instead.

But using the standard HTML tags has the drawback of loosing some functionality, after all that's why the custom tags are there in the first place. It is possible to get validation through validate methods on the controller class even with standard HTML.

If you are just starting out with the framework I suggest you learn the struts tags properly before going off the beaten path.

krosenvold
+1  A: 

Is it mandatory in struts2 to use struts-tags.

No, but if you aren't using tags at all then you're not really getting very much out of Struts as a framework. Might as well do it yourself.

i didn't get validation message

If you're using your own markup you'll have to tell it to display the error message. eg.:

<s:fielderror><s:param>empcode</s:param></s:fielderror>

please comment ?

Please stop asking the same questions over and over again.

bobince