<?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>Eric Martin &#187; Java</title>
	<atom:link href="http://www.ericmmartin.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ericmmartin.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Apr 2010 15:28:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Struts 2 ParametersInterceptor</title>
		<link>http://www.ericmmartin.com/struts-2-parametersinterceptor/</link>
		<comments>http://www.ericmmartin.com/struts-2-parametersinterceptor/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 15:47:28 +0000</pubDate>
		<dc:creator>Eric Martin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ericmmartin.com/?p=39</guid>
		<description><![CDATA[Are your logs being filled up with errors like: ERROR - ParametersInterceptor.setParameters(204) &#124; ParametersInterceptor - [setParameters]: Unexpected Exception caught setting '_' on 'class com.company.web.MyAction: Error setting expression '_' with value '[Ljava.lang.String;@1491ddc' If so, it's because Struts 2 is parsing the query string/post data and trying to "set" a value for each parameter it finds. I'm [...]]]></description>
			<content:encoded><![CDATA[<p>Are your logs being filled up with errors like: </p>
<pre><code>ERROR - ParametersInterceptor.setParameters(204) | ParametersInterceptor - [setParameters]: Unexpected Exception caught setting '_' on 'class com.company.web.MyAction: Error setting expression '_' with value '[Ljava.lang.String;@1491ddc'</code></pre>
<p>If so, it's because <a href="http://struts.apache.org/">Struts 2</a> is parsing the query string/post data and trying to "set" a value for each parameter it finds. </p>
<p>I'm working on an Struts 2 application utilizing the <a href="http://jquery.com/">jQuery JavaScript library</a> for the UI and the <a href="http://displaytag.sourceforge.net/">Displaytag tag library</a> for displaying tables.</p>
<p>With jQuery, I'm using the "no-cache" option (<code>cache: false</code>) on all Ajax calls, which adds "<code>_=timestamp</code>" to each request. Since I don't have a property called "<code>_</code>" in my Action class, I get an error (mentioned above) in my logs for each request.</p>
<p>Same with Displaytag, except the parameters causing errors are in the form of "<code>d-#-X</code>", where "<code>#</code>" is a unique id (usually 4 or 5 digits) and "<code>X</code>" is either <code>p</code>, <code>s</code> or <code>o</code>. They are used to determine the page (<code>p</code>) and/or the table sort order (<code>o</code> for asc/desc and <code>s </code>for which column).</p>
<p>The solution: configure Struts (struts.xml) to ignore these parameters:</p>
<pre><code>&lt;interceptors&gt;
   &lt;interceptor-stack name="defaultStack"&gt;
      &lt;interceptor-ref name="params"&gt;
         &lt;!--
            Excludes the jQuery no-cache _ parameter and
            the Displaytag d-#-X parameter(s)
         --&gt;
         &lt;param name="excludeParams"&gt;
            _,d-\d+?-[sop]
         &lt;/param&gt;
      &lt;/interceptor-ref&gt;
   &lt;/interceptor-stack&gt;
&lt;/interceptors&gt;</code></pre>
<p>If you have a different parameters that are causing problems, just put them in the <code>excludeParams</code> node, comma separating multiple parameters.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericmmartin.com/struts-2-parametersinterceptor/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Struts 2 bug &#8211; s:submit tag type=button rendering</title>
		<link>http://www.ericmmartin.com/struts-2-bug-submit-button-tag-rendering/</link>
		<comments>http://www.ericmmartin.com/struts-2-bug-submit-button-tag-rendering/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 04:29:30 +0000</pubDate>
		<dc:creator>Eric Martin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ericmmartin.com/struts-2-bug-ssubmit-tag-typebutton-does-not-render-properly/</guid>
		<description><![CDATA[In Struts 2.0.11, the s:submit tag with type=button does not render properly. While working on a project using Struts 2, I was attempting to create a HTML button that looked something like: &#60;button type=&#34;button&#34; class=&#34;button positive save&#34;&#62; &#60;img src=&#34;/images/tick.png&#34; alt=&#34;Save&#34;&#62; Save &#60;/button&#62; I followed the Struts 2 Tag Reference for the submit tag and tried [...]]]></description>
			<content:encoded><![CDATA[<p>In Struts 2.0.11, the <code>s:submit</code> tag with <code>type=button</code> does not render properly.</p>
<p>While working on a project using Struts 2, I was attempting to create a HTML button that looked something like:</p>
<pre><code>&lt;button type=&quot;button&quot; class=&quot;button positive save&quot;&gt;
    &lt;img src=&quot;/images/tick.png&quot; alt=&quot;Save&quot;&gt; Save
&lt;/button&gt;</code></pre>
<p>I followed the Struts 2 Tag Reference for the <a href="http://struts.apache.org/2.x/docs/submit.html">submit tag</a> and tried the following:</p>
<pre><code>&lt;s:submit type=&quot;button&quot; cssClass=&quot;button positive save&quot;&gt;
    &lt;img src=&quot;/images/tick.png&quot; alt=&quot;Save&quot;&gt; Save
&lt;/s:submit&gt;</code></pre>
<p>Instead of rendering like my example above, it looks like:</p>
<pre><code>&lt;img src=&quot;/images/tick.png&quot; alt=&quot;Save&quot;&gt; Save
&lt;button type=&quot;submit&quot; id=&quot;test_0&quot; value=&quot;Submit&quot; class=&quot;button positive save&quot;&gt;Submit&lt;/button&gt;</code></pre>
<p>Not exactly what I had in mind... ;)</p>
<p><span id="more-23"></span><br />
At first I thought that I was just doing something wrong, so I <a href="http://www.nabble.com/-S2--Complex-submit-button-issue-tf4889527.html">posed a question</a> on the mailing list. Then after searching the list some more, I found that this was, in fact, a bug and that it had been previously <a href="https://issues.apache.org/struts/browse/WW-1677">reported</a> and supposedly fixed.</p>
<p>I checked out the Struts 2 core project and started looking around in the code. I <a href="http://www.nabble.com/Re%3A-WW-1677-not-working-%28was-Re%3A-WW-167-%29-t4895694.html">posted</a> some of my thoughts and ended up creating a patch that added a new <code>s:button</code> tag.</p>
<p>Struts tries to render the <code>button</code> tag using the same code that is used to render the <code>input</code> tag. The two tags share a lot in common, however, there are some important differences between them. Mainly, the <code>input</code> tag does not have a body and uses its value attribute for its label, whereas the <code>button</code> tag must have a body, which is what is used as its label. Unless you required name/value information to be sent for the button, there is no need to include either of those attributes on the button tag.</p>
<p>It will be interesting to see if my patch is used...either way, it was fun to dig into the Struts code and it was a good learning experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericmmartin.com/struts-2-bug-submit-button-tag-rendering/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
