<?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>dominikdorn.com &#187; Flash-Scope</title>
	<atom:link href="http://dominikdorn.com/tag/flash-scope/feed/" rel="self" type="application/rss+xml" />
	<link>http://dominikdorn.com</link>
	<description>shit happens ;)</description>
	<lastBuildDate>Tue, 03 Jan 2012 19:47:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>RoR Flash Scope in JSF-2</title>
		<link>http://dominikdorn.com/2009/10/ror-flash-scope-in-jsf-2/</link>
		<comments>http://dominikdorn.com/2009/10/ror-flash-scope-in-jsf-2/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 18:01:30 +0000</pubDate>
		<dc:creator>Dominik Dorn</dc:creator>
				<category><![CDATA[JSF]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash-Scope]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://dominikdorn.com/?p=103</guid>
		<description><![CDATA[While browsing through the Mojarra Sourcecode, I&#8217;ve found a interesting set of classes, all bundled around the keyword &#8220;Flash&#8221;: ./jsf-ri/systest/src/com/sun/faces/systest/FlashViewParamTestCase.java ./jsf-ri/systest/src/com/sun/faces/systest/FlashReaperTestCase.java ./jsf-ri/systest/src/com/sun/faces/systest/FlashReaperBean.java ./jsf-ri/systest/web/flash01.xhtml ./jsf-ri/systest/web/flash02.xhtml ./jsf-ri/systest/web/flashReaper.xhtml ./jsf-ri/src/com/sun/faces/context/flash ./jsf-ri/src/com/sun/faces/context/flash/FlashELResolver.java ./jsf-ri/src/com/sun/faces/context/flash/ELFlash.java ./jsf-ri/systest-per-webapp/flash/src/java/com/sun/faces/systest/FlashTestCase.java ./jsf-ri/systest-per-webapp/flash/web/flash7.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash8.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash2.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash5.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash4.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash3.xhtml ./jsf-ri/systest-per-webapp/flash/web/flash6.xhtml ./jsf-api/src/main/java/javax/faces/context/Flash.java When looking through the files, I found out, that the famous Flash-Scope of Ruby on Rails (my friend [...]]]></description>
			<content:encoded><![CDATA[<p>While browsing through the Mojarra Sourcecode, I&#8217;ve found a interesting set of classes, all bundled around the keyword &#8220;Flash&#8221;:</p>
<p><code>./jsf-ri/systest/src/com/sun/faces/systest/FlashViewParamTestCase.java<br />
./jsf-ri/systest/src/com/sun/faces/systest/FlashReaperTestCase.java<br />
./jsf-ri/systest/src/com/sun/faces/systest/FlashReaperBean.java<br />
./jsf-ri/systest/web/flash01.xhtml<br />
./jsf-ri/systest/web/flash02.xhtml<br />
./jsf-ri/systest/web/flashReaper.xhtml<br />
./jsf-ri/src/com/sun/faces/context/flash<br />
./jsf-ri/src/com/sun/faces/context/flash/FlashELResolver.java<br />
./jsf-ri/src/com/sun/faces/context/flash/ELFlash.java<br />
./jsf-ri/systest-per-webapp/flash/src/java/com/sun/faces/systest/FlashTestCase.java<br />
./jsf-ri/systest-per-webapp/flash/web/flash7.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash8.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash2.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash5.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash4.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash3.xhtml<br />
./jsf-ri/systest-per-webapp/flash/web/flash6.xhtml<br />
./jsf-api/src/main/java/javax/faces/context/Flash.java</code></p>
<p>When looking through the files, I found out, that the famous <a href="http://api.rubyonrails.org/classes/ActionController/Flash.html" target="_blank">Flash-Scope</a> of <a href="http://rubyonrails.org/" target="_blank">Ruby on Rails </a> (my friend <a href="http://petersteinberger.com" target="_blank">Peter</a> told me about that scope in RoR about a year ago when we where <a href="http://tuwis.tuwien.ac.at/lva/188394/2009S" target="_blank">doing stuff with JSF 1.2</a>) got ported to JSF-2.</p>
<p>So, what you now basically can do, is to put an object into flash-scope in one request, e.g.:<br />
<code><br />
&lt;h:form id="nextForm" prependId="false"&gt;<br />
&lt;c:set target="#{flash}" property="foo" value="bar" /&gt;<br />
....<br />
&lt;/h:form&gt;<br />
</code><br />
(Taken from ./jsf-ri/systest/web/flash01.xhtml)</p>
<p>and retrieve it in the next request (but not the request after that one) simply by accessing it through EL<br />
<code><br />
foo = ${flash.foo}<br />
</code> (Taken from ./jsf-ri/systest/web/flash02.xhtml)</p>
<p>Also you can put objects into the flash scope in your controllers:<br />
<code><br />
ELFlash.getFlash().put("key","value");<br />
</code><br />
I know that looks quite dirty because one is polluting the controller with a Singleton, but when done right, you can still make your code perfectly testable <img src='http://dominikdorn.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The files you need to take a look at are:</p>
<ul>
<li><strong>The Interface:</strong> ./jsf-api/src/main/java/javax/faces/context/Flash.java</li>
<li><strong>The Implementation:</strong> ./jsf-ri/src/com/sun/faces/context/flash/ELFlash.java</li>
<li><strong>The Test-Case:</strong> ./jsf-ri/systest-per-webapp/flash/src/java/com/sun/faces/systest/FlashTestCase.java(Although the test code use some cleanup!)</li>
</ul>
<p>Update: I found a blog post from <a href="http://www.java.net/blogs/edburns/" target="_blank">Ed Burns</a> about <a href="http://weblogs.java.net/blog/edburns/archive/2006/03/repost_bringing.html" target="_blank">using the Flash Scope</a>, although its still JSP based, it should also give a good introduction!</p>
]]></content:encoded>
			<wfw:commentRss>http://dominikdorn.com/2009/10/ror-flash-scope-in-jsf-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

