Min Naing Oo
Min Naing Oo

Reputation: 1095

Using HTML <form> tag instead of Struts 2 <s:form> tag

I want to use

<form action="someClass">
<s:textarea name="name" label="Name"/>
<s:checkboxlist list="{'Male','Female'}" name="gender" label="Gender"/>
</form>

instead of

<s:form action="someClass">
<s:textarea name="name" label="Name"/>
<s:checkboxlist list="{'Male','Female'}" name="gender" label="Gender"/>
</s:form>

Because <s:form> tag's default theme "xhtml" is not ok with my CSS and theme "simple" can't show validation errors by itself without the use of <s:fielderror> tag.

So is it valid to use it?

I'm ok by using like that till now. Is there any error that I will face for using like that in the future?

Upvotes: 3

Views: 2242

Answers (2)

Roman C
Roman C

Reputation: 1

You can use <form> tag to do with forms but it's not <s:form tag and you have to maintain it's attributes manually. <s:form renders <form> tag with the nice preset of attributes that exactly communicate with the framework. Omitting it lacks some features supplied by the framework that leads to incorrect usages and bugs.

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160191

Of course you can use plain HTML tags.

Please remember that all JSP custom tags do, in the end, is render HTML.[1]

As Roman states, you'll lose things like the automatic filling of values, the retrieval of labels via the attribute name or key, the display of error messages and styling, and so on.

Your best course of action may be to create your own theme and use your own templates and CSS, or use the "css_xhtml" theme, and supply your own styles. Which is better to do depends on a fair amount of information we don't have, but the CSS HTML version is fairly flexible other than having to define the <br/> tag as being inline because it's currently used in the theme where it shouldn't be.

[1] Yes, it could do other stuff on the server side before sending over HTML, like the SQL custom tags. In general, though, the purpose of custom tags is to emit HTML.

Upvotes: 4

Related Questions