<?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>JSF Blog &#187; Web</title>
	<atom:link href="http://www.jsfblog.info/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jsfblog.info</link>
	<description>Discussion on all things Java and JSF</description>
	<lastBuildDate>Fri, 03 Feb 2012 20:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JSF, Iterating with tomahawk radio buttons, t:datalist, a4j:repeat</title>
		<link>http://www.jsfblog.info/2010/05/jsf-iterating-with-tomahawk-radio-buttons-tdatalist-a4jrepeat/</link>
		<comments>http://www.jsfblog.info/2010/05/jsf-iterating-with-tomahawk-radio-buttons-tdatalist-a4jrepeat/#comments</comments>
		<pubDate>Fri, 14 May 2010 18:22:48 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[tomahawk]]></category>

		<guid isPermaLink="false">http://www.jsfblog.info/?p=224</guid>
		<description><![CDATA[The standard JSF radio buttons h:selectOneRadio render a load of old school html (i.e. they use table tags to do layout, (all a bit 1996)). e.g. JSF h:selectOneRadio tag Code for #{radioOptions} Note: I&#8217;m using jboss seam in the example above, but you could easily remove the seam annotations and define the bean in using [...]]]></description>
			<content:encoded><![CDATA[<p>The standard JSF radio buttons <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/h/selectOneRadio.html">h:selectOneRadio</a> render a load of old school html (i.e. they use table tags to do layout, (all a bit 1996)).</p>
<p>e.g. JSF h:selectOneRadio tag</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h:selectOneRadio id=&quot;aRadio&quot;&gt;
	&lt;f:selectItems value=&quot;#{radioOptions.items}&quot; /&gt;
&lt;/h:selectOneRadio&gt;
</pre>
<p>Code for #{radioOptions}</p>
<pre class="brush: java; title: ; notranslate">
import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Name(&quot;radioOptions&quot;)
@Scope(ScopeType.APPLICATION)
public class RadioOptions
{
	public List&lt;SelectItem&gt; items = new ArrayList&lt;SelectItem&gt;();

	public RadioOptions()
	{
		items.add(new SelectItem(&quot;1&quot;, &quot;label 1&quot;));
		items.add(new SelectItem(&quot;2&quot;, &quot;label 2&quot;));
		items.add(new SelectItem(&quot;3&quot;, &quot;label 3&quot;));
	}

	public List&lt;SelectItem&gt; getItems()
	{
		return items;
	}

	public void setItems(List&lt;SelectItem&gt; items)
	{
		this.items = items;
	}
}
</pre>
<p>Note: I&#8217;m using jboss seam in the example above, but you could easily remove the seam annotations and define the bean in using jsf managed beans or faces config etc. Also the examples here are a bit mickey mouse and could be better.</p>
<p>Under JSF 1.2 will be rendered as</p>
<pre class="brush: xml; title: ; notranslate">
&lt;table id=&quot;myForm:aRadio&quot;&gt;
	&lt;tr&gt;
		&lt;td&gt;
			&lt;input type=&quot;radio&quot; name=&quot;myForm:aRadio&quot; id=&quot;myForm:aRadio:0&quot; value=&quot;1&quot; /&gt;
			&lt;label for=&quot;myForm:aRadio:0&quot;&gt;Label 1&lt;/label&gt;
		&lt;/td&gt;
		&lt;td&gt;
			&lt;input type=&quot;radio&quot; name=&quot;myForm:aRadio&quot; id=&quot;myForm:aRadio:1&quot; value=&quot;2&quot; /&gt;
			&lt;label for=&quot;myForm:aRadio:1&quot;&gt;Label 2&lt;/label&gt;
		&lt;/td&gt;
		&lt;td&gt;
			&lt;input type=&quot;radio&quot; name=&quot;myForm:aRadio&quot; id=&quot;myForm:aRadio:2&quot; value=&quot;3&quot; /&gt;
			&lt;label for=&quot;myForm:aRadio:2&quot;&gt;Label 3&lt;/label&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>Anyway this limitation is well known and as a result we&#8217;ve been using the apache tomahawk <a href="http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_selectOneRadio.html">t:selectOneRadio</a> (using the layout=&#8221;spread&#8221; attribute) and <a href="http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_radio.html">t:radio</a> tags to provide more flexible layouts which can be styled by css.</p>
<p><strong>Iterating through a list of select items</strong></p>
<p>There are times when I want to render the radio buttons in a flexible fashion (offered by t:radio) using a loop tag such as <a href="http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_dataList.html">t:dataList</a> or <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/a4j/repeat.html">a4j:repeat</a> e.g.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot; xmlns:f=&quot;http://java.sun.com/jsf/core&quot; xmlns:fn=&quot;http://java.sun.com/jsp/jstl/functions&quot; xmlns:c=&quot;http://java.sun.com/jstl/core&quot; xmlns:t=&quot;http://myfaces.apache.org/tomahawk&quot; xmlns:a4j=&quot;https://ajax4jsf.dev.java.net/ajax&quot;&gt;
&lt;f:view&gt;
&lt;h:form id=&quot;myForm&quot;&gt;
	&lt;!-- radio button, layout spread  --&gt;
	&lt;t:selectOneRadio id=&quot;myRadio&quot; forceId=&quot;true&quot; layout=&quot;spread&quot;&gt;
		&lt;f:selectItems value=&quot;#{radioOptions.items}&quot; /&gt;
	&lt;/t:selectOneRadio&gt;

	&lt;!-- data list, loops through all the radio button options --&gt;
	&lt;t:dataList var=&quot;helper&quot; value=&quot;#{radioOptions.items}&quot; rowIndexVar=&quot;idx&quot;&gt;
		&lt;!-- example html, not constrained to table layout --&gt;
		&lt;h1&gt;Heading&lt;/h1&gt;
		&lt;t:radio for=&quot;myRadio&quot; index=&quot;#{idx}&quot;/&gt;
		&lt;h1&gt;Another Heading&lt;/h1&gt;
	&lt;/t:dataList&gt;
&lt;/h:form&gt;
&lt;/f:view&gt;
&lt;/html&gt;
</pre>
<p>Unfortunately this doesn&#8217;t work and throws:</p>
<pre class="brush: plain; title: ; notranslate">
java.lang.IllegalStateException: Could not find component 'myRadio' (calling findComponent on component 'myForm:j_id3:0:j_id5')
</pre>
<p><strong>The Fix:</strong></p>
<p>I <em>almost always</em> forget this which is why im blogging about it,</p>
<pre class="brush: xml; title: ; notranslate">
&lt;t:radio for=&quot;myRadio&quot; index=&quot;#{idx}&quot;/&gt;
</pre>
<p>needs to be replaced with</p>
<pre class="brush: xml; title: ; notranslate">
&lt;t:radio for=&quot;:myForm:myRadio&quot; index=&quot;#{idx}&quot;/&gt;
</pre>
<p>The tomahawk t:radio component must have the <a href="#fullyQualified"><em>fully qualified</em></a> component name of the t:selectOneRadio name otherwise it cannot find it.</p>
<p>Since the form is defined as:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h:form id=&quot;myForm&quot;&gt;
</pre>
<p>:myForm needs to be prefixed to the for attribute of the t:radio giving :myForm:myRadio</p>
<p>I take absolutely no credit for this because its explained <a href="https://issues.apache.org/jira/browse/TOMAHAWK-26">here</a> and on the <a href="http://wiki.apache.org/myfaces/Display_Radio_Buttons_In_Columns">Myfaces wiki </a>this article is merely a note to self.</p>
<p>Btw, the above works with a4j:repeat as well as t:datalist</p>
<p><span style="text-decoration: line-through">Currently tomahawk isn&#8217;t working in JSF 2.0 which is a shame as we are looking to upgrade very soon. Hopefully a decent radio button will become part of JSF 2 at some point.</span></p>
<p>The<a href="http://myfaces.apache.org/tomahawk-project/tomahawk20/index.html"> tomahawk </a>component library now works with JSF 2.0</p>
<h5 id="fullyQualified">Update: Fully Qualified JSF Name</h5>
<p>A bit of searching around on the web took me to Lincoln Baxter&#8217;s blog  where he mentions <a href="http://ocpsoft.com/java/jsf2-java/how-to-jsf-2-0-render-components-outside-of-the-form/">rendering  components outside of the form</a> and explains that the first &#8220;:&#8221;  tells JSF to start looking from the very top of the JSF View Root. Thanks for that!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jsfblog.info/2010/05/jsf-iterating-with-tomahawk-radio-buttons-tdatalist-a4jrepeat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D Secure and the PaReq field in Google Chrome &amp; Safari Browsers</title>
		<link>http://www.jsfblog.info/2010/03/3d-secure-and-the-pareq-field-in-google-chrome-safari-browsers/</link>
		<comments>http://www.jsfblog.info/2010/03/3d-secure-and-the-pareq-field-in-google-chrome-safari-browsers/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 17:45:15 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[3D Secure]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[PaReq]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://www.jsfblog.info/?p=128</guid>
		<description><![CDATA[I recently had to implement the 3D Secure payment system. In order to do this 3 fields must be sent to the 3D Secure ACS (Access Control Server) MD Term Url PaReq (Payer authentication request) Initally everything went well until we tested our pages in Google Chrome and Safari. Under both browsers the 3D Secure [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to implement the <a href="http://en.wikipedia.org/wiki/3-D_Secure">3D Secure</a> payment system.</p>
<p>In order to do this 3 fields must be sent to the 3D Secure ACS (Access Control Server)</p>
<ul>
<li>MD</li>
<li>Term Url</li>
<li>PaReq (Payer authentication request)</li>
</ul>
<p>Initally everything went well until we tested our pages in Google Chrome and Safari. Under both browsers the 3D Secure inline frame displayed the following message</p>
<p>&#8220;Error decoding PAREQ message&#8221;</p>
<p>A <a href="https://datacash.custhelp.com/cgi-bin/datacash.cfg/php/enduser/std_adp.php?p_faqid=1025">support page</a> mentions that a PaReq contains newlines and that if <em>any</em> of these are missing the PaReq decoding will fail. The page also mentions that there are issues with Chrome and Safari but provides no solution.</p>
<h2>So what is the problem?</h2>
<p>The problem is indeed the newline.</p>
<p>In our markup we use and EL (Expression Language) to output the PaReq e.g.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;hidden&quot; name=&quot;PaReq&quot; value=&quot;#{paReq}&quot; /&gt;
</pre>
<p>If the PaReq returned a string such as</p>
<pre class="brush: xml; title: ; notranslate">
&quot;I am
The PaReq
&quot;
</pre>
<p>Note the quotes above mark the begining and end of the string. The string itself is terminated by a newline, in code it would be:</p>
<pre class="brush: java; title: ; notranslate">
String paReq = &quot;I am\nThe PaReq\n&quot;;
</pre>
<p>The browser <em>should</em> generate the following markup</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;hidden&quot; name=&quot;PaReq&quot; value=&quot;I am
The PaReq
&quot; /&gt;
</pre>
<p>However Chrome and Safari generate the following markup (as both browsers do this I assume its a <a href="http://webkit.org/">Webkit</a> thing)</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;hidden&quot; name=&quot;PaReq&quot; value=&quot;I am
The PaReq&quot; /&gt;
</pre>
<p><strong>Note, the traililng newline has disappeared</strong> and herein lies the problem, the server fails to recoginse the PaReq as the <em>trailing newline</em> has gone (currently Chrome 4.0.429.89 contains the above bug).</p>
<p>The fix? Dont use Chrome or Safari, Only kidding</p>
<p>The way we overcame this was to use a &#8220;hidden&#8221; textarea</p>
<pre class="brush: xml; title: ; notranslate">
&lt;textarea name=&quot;PaReq&quot; style=&quot;display:none&quot;&gt;#{paReq}&lt;/textarea&gt;
</pre>
<p>Which renders</p>
<pre class="brush: xml; title: ; notranslate">
&lt;textarea name=&quot;PaReq&quot; style=&quot;display:none&quot;&gt;I am
The PaReq
&lt;/textarea&gt;
</pre>
<p>In all browsers and preserves the trailing newline. The style=&#8221;display:none&#8221; hides the textarea. Although this is crude it does provide a fix for Chrome and Safari.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jsfblog.info/2010/03/3d-secure-and-the-pareq-field-in-google-chrome-safari-browsers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

