<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JT Dev &#187; struts2</title>
	<atom:link href="http://www.jtict.com/blog/tag/struts2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jtict.com/blog</link>
	<description>About programming stuff</description>
	<lastBuildDate>Sun, 11 Jul 2010 14:23:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Struts2 table annoyance</title>
		<link>http://www.jtict.com/blog/struts2-table-annoyance/</link>
		<comments>http://www.jtict.com/blog/struts2-table-annoyance/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 12:24:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.jtict.com/blog/?p=11</guid>
		<description><![CDATA[I was trying out a bit of Struts 2 just to test it out. An annoyance that quickly came up is that the HTML layout of forms are all table based. For example, if you want an input field for your name, then a column-based HTML table will be created automatically for that. The first [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying out a bit of Struts 2 just to test it out. An annoyance that quickly came up is that the HTML layout of forms are all table based. For example, if you want an input field for your name, then a column-based HTML table will be created automatically for that. The first column contains a HTML label, and the second the input field.</p>
<p>For example, the following Struts2 code:</p>
<pre class="brush: xml">&lt;s:form action=&quot;HelloWorld&quot;&gt;
    		&lt;s:textfield name=&quot;name&quot; label=&quot;Your name&quot;/&gt;
    		&lt;s:submit/&gt;
		&lt;/s:form&gt;</pre>
<p>will yield this HTML code:</p>
<pre class="brush: xml">&lt;form id=&quot;HelloWorld&quot; name=&quot;HelloWorld&quot; onsubmit=&quot;return true;&quot; action=&quot;/StrutsInAction/chapterTwo/HelloWorld.action&quot; method=&quot;post&quot;&gt;
	&lt;table class=&quot;wwFormTable&quot;&gt;
		&lt;tr&gt;
			&lt;td class=&quot;tdLabel&quot;&gt;&lt;label for=&quot;HelloWorld_name&quot; class=&quot;label&quot;&gt;Your name:&lt;/label&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;&quot; id=&quot;HelloWorld_name&quot;/&gt;&lt;/td&gt;
		&lt;/tr&gt;
   		&lt;tr&gt;
			&lt;td colspan=&quot;2&quot;&gt;&lt;div align=&quot;right&quot;&gt;&lt;input type=&quot;submit&quot; id=&quot;HelloWorld_0&quot; value=&quot;Submit&quot;/&gt;&lt;/div&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
&lt;/form&gt;
</pre>
<p>What if you want to work without HTML tables? Or what if you want to put a label on the first row and its input field on the second row, instead of using two columns? You can by using the &#8220;<em>simple</em>&#8221; theme instead of the default &#8220;<em>xhtml</em>&#8221; theme. Set it using:</p>
<pre class="brush: xml">&lt;s:form action=&quot;HelloWorld&quot; theme=&quot;simple&quot;&gt;</pre>
<p>The generated HTML code will now be:</p>
<pre class="brush: xml">&lt;form id=&quot;HelloWorld&quot; name=&quot;HelloWorld&quot; onsubmit=&quot;return true;&quot; action=&quot;/StrutsInAction/chapterTwo/HelloWorld.action&quot; method=&quot;post&quot;&gt;
	&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;&quot; id=&quot;HelloWorld_name&quot;/&gt;
	&lt;input type=&quot;submit&quot; id=&quot;HelloWorld_0&quot; value=&quot;Submit&quot;/&gt;
&lt;/form&gt;</pre>
<p>But&#8230;. using the simple theme, will drop validation, error reporting, ajax etc&#8230;&#8230;</p>
<p>So if you don&#8217;t want those column based HTML tables but do want the default framework functionality (validation etc), you will have to make your own themes&#8230;&#8230;</p>
<p>JSF doesn&#8217;t have this problem, there you could just write something like:</p>
<pre class="brush: xml">&lt;h:form&gt;
	&lt;h:outputLabel for=&quot;name&quot;&gt;Your name:&lt;/h:outputLabel&gt;
	&lt;h:inputText value=&quot;#{formAction.name}&quot;/&gt;
</pre>
<p>This is a bit more coding then using Struts 2, but it gives you the flexibility to place the outputLabel wherever you want, instead of being locked to two HTML columns.</p>
<p>More info:<br />
<a href="http://struts.apache.org/2.x/docs/themes-and-templates.html">http://struts.apache.org/2.x/docs/themes-and-templates.html</a><br />
<a href="http://www.vitarara.org/cms/struts_2_cookbook/creating_a_theme">http://www.vitarara.org/cms/struts_2_cookbook/creating_a_theme</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jtict.com/blog/struts2-table-annoyance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
