<?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>Learning by Experience &#187; WebFlow</title> <atom:link href="http://www.inze.be/andries/category/webflow/feed/" rel="self" type="application/rss+xml" /><link>http://www.inze.be/andries</link> <description>Java, Project Management, Life and anything else.</description> <lastBuildDate>Mon, 09 Jan 2012 21:38:00 +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>Experiencing Spring WebFlow, part 3</title><link>http://www.inze.be/andries/2007/06/07/experiencing-spring-webflow-part-3/</link> <comments>http://www.inze.be/andries/2007/06/07/experiencing-spring-webflow-part-3/#comments</comments> <pubDate>Thu, 07 Jun 2007 20:10:07 +0000</pubDate> <dc:creator>Andries Inzé</dc:creator> <category><![CDATA[Spring]]></category> <category><![CDATA[WebFlow]]></category> <guid
isPermaLink="false">http://www.inze.be/andries/?p=10</guid> <description><![CDATA[In my third part of this learning path, I&#8217;d like to discuss the way I handle my reference data. Reference data is extra data that is needed by a form. Typically this is stuff like the options in a select, things that are not provided by the form backing bean. 3. ReferenceDataActions In order to [...]]]></description> <content:encoded><![CDATA[<p>In my third part of this learning path, I&#8217;d like to discuss the way I handle my reference data.</p><p>Reference data is extra data that is needed by a form. Typically this is stuff like the options in a select, things that are not provided by the form backing bean.</p><p><strong>3. ReferenceDataActions</strong></p><p>In order to create a maintable, centralised pool of reference data, I recommend to use the following guidelines:</p><ul><li> Create a MultiAction called <em>ReferenceDataActions</em>.</li><li>Create for each backing bean (or each class of backing bean) an initXXX, where XXX is the class of the backing bean.</li><li>Create for each type of reference data a private method, that returns void. In the private method you put only 1 list or object onto the context. Call the methods something like putYYY, where YYY is the name of the class of reference data you are putting on.</li><li>In the initXXX methods, you delegate to the private methods the types you need.</li></ul><p>Take a look at following example:<br
/> <code><br
/> public Event initCustomer(RequestContext context) {<br
/> putCustomerTypes(context);<br
/> putCountries(context);<br
/> return success();<br
/> }<br
/> public void putCountries(RequestContext context) {<br
/> context.getRequestScope().put(//INSERT CODE HERE<br
/> }</code></p><p>This way of defining the actions will give you an enormous amount of flexibility and maintainability.<br
/> When designing your application, you will need to ask yourself: <em>What if something changes?</em></p><p>What if I need to put something new onto the context as referenceData? You just add the method to the initXXX method.<br
/> What if I need to change to source of a referenceData? You can just change the putYYY method.</p><p>Keeping referenceData out of your real Action classes, is great to keep those classes as small as possible.<br
/> The ReferenceDataActions class can grow quite big, but thats ok! Since the implementation inside the class is kept to a bare minimum (referenceData hardly ever needs logic), the class is not overcomplicated. Exposing only the init methods forces you to utilise only the methods you have control over, which you can alter without changing the API.</p><p>But as always, I&#8217;m open to discussion!</p> ]]></content:encoded> <wfw:commentRss>http://www.inze.be/andries/2007/06/07/experiencing-spring-webflow-part-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Experiencing Spring WebFlow, part 2</title><link>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-2/</link> <comments>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-2/#comments</comments> <pubDate>Sun, 03 Jun 2007 12:38:14 +0000</pubDate> <dc:creator>Andries Inzé</dc:creator> <category><![CDATA[Spring]]></category> <category><![CDATA[WebFlow]]></category> <guid
isPermaLink="false">http://www.inze.be/andries/?p=9</guid> <description><![CDATA[One of the most cumbersome work when developing an application is to debug when errors have occurred. Creating fail-fast applications helps us keep debugging to a bear minimum. This takes us to the second part of my Experiencing Spring WebFlow course. 2. Go For Fail-Fast Spring WebFlow makes use of ParameterMap to represent the state [...]]]></description> <content:encoded><![CDATA[<p>One of the most cumbersome work when developing an application is to debug when errors have occurred. Creating fail-fast applications helps us keep debugging to a bear minimum. This takes us to the second part of my <em>Experiencing Spring WebFlow course</em>.</p><p><strong>2. Go For Fail-Fast</strong></p><p>Spring WebFlow makes use of <a
href="http://static.springframework.org/spring-webflow/docs/1.0.x/api/org/springframework/webflow/core/collection/ParameterMap.html" title="ParameterMap" target="_blank">ParameterMap</a> to represent the state of the scope&#8217;s. They could easily just exposed a Map interface.</p><p>ParameterMap&#8217;s gives us neat getRequiredXXX methods that let&#8217;s us implement Fail-Fast easily. If you rely on a certain object to be in the scope, you should use these methods instead of the normal ones. The getRequiredXXX will throw <code>IllegalArgumentException</code> when the object was not found. This is a far better representation of the error, then a NPE a couple of lines down. Sometimes you don&#8217;t really act on the object, but pass it on to let&#8217;s say your DAO layer where the exception could be a lot more obscure.</p><p>Fail-Fast is a design method that could be incorporated in nearly any method/class. An excellent read about this can be found <a
href="http://www.martinfowler.com/ieeeSoftware/failFast.pdf" title="Fail-Fast document">here.</a></p> ]]></content:encoded> <wfw:commentRss>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Experiencing Spring WebFlow, part I</title><link>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-i/</link> <comments>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-i/#comments</comments> <pubDate>Sun, 03 Jun 2007 12:15:43 +0000</pubDate> <dc:creator>Andries Inzé</dc:creator> <category><![CDATA[Spring]]></category> <category><![CDATA[WebFlow]]></category> <guid
isPermaLink="false">http://www.inze.be/andries/?p=8</guid> <description><![CDATA[Howdy! Last couple of months I have been developing in Spring Webflow intensively. During this time, I&#8217;ve made some newbie mistakes that I believe are happening quite frequently. So in my brand new blog, I&#8217;m addressing some of the common bad practices I have encountered. Let&#8217;s dive into the first one, the others will follow [...]]]></description> <content:encoded><![CDATA[<p>Howdy!</p><p>Last couple of months I have been developing in Spring Webflow intensively. During this time, I&#8217;ve made some <em>newbie</em> mistakes that I believe are happening quite frequently. So in my brand new blog, I&#8217;m addressing some of the common bad practices I have encountered.</p><p>Let&#8217;s dive into the first one, the others will follow shortly!</p><p><strong>1. Prefer RequestScope</strong></p><p>First some background:<br
/> As you need to know, Spring WebFlow 1.0 has 4 scopes.</p><ul><li>ConversationScope: objects are kept for the duration of the flow, including any subflows.</li><li>FlowScope: objects are kept for the duration of the flow, excluding subflows.</li><li>FlashScope: objects are kept for the duration request. When haven redirects enabled (standard behavior on webflow), the objects are keps for the duration of the redirect as well.</li><li>And finally RequestScope: objects are placed for the duration of the request (not surviving the redirect if any).</li></ul><p>Since the duration of the first 3 scopes is undetermined, WebFlow serializes the objects that are saved on the scope. Serialisation is a relative expensive process of saving the object to an ObjectOutputStream. On accessing the scope, the object needs to be deserialised.</p><p>FlashScoped objects can in many cases be placed in a RequestScope, which provides much better performance.</p><p><strong>When to use FlashScope</strong></p><p>In fact, FlashScope should only be used when you want to pass objects into the view layer of the next viewState. This is the only time the object needs to <em>survive</em> the redirect.</p><p>FlashScope is often abused by using it in the entry-action of a viewState. Any objects that were placed as FlashScoped objects could be placed without much fuzz on the RequestScope. The action that invoked the code, should then be placed in the render action. Et Voila, the code has been optimised.</p><p><strong>Conclusion: </strong>Always use RequestScope if possible.</p> ]]></content:encoded> <wfw:commentRss>http://www.inze.be/andries/2007/06/03/experiencing-spring-webflow-part-i/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
