deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r892907 - in /websites/staging/deltaspike/trunk/content: ./ jsf.html
Date Sun, 05 Jan 2014 22:21:20 GMT
Author: buildbot
Date: Sun Jan  5 22:21:19 2014
New Revision: 892907

Log:
Staging update by buildbot for deltaspike

Modified:
    websites/staging/deltaspike/trunk/content/   (props changed)
    websites/staging/deltaspike/trunk/content/jsf.html

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sun Jan  5 22:21:19 2014
@@ -1 +1 @@
-1553510
+1555640

Modified: websites/staging/deltaspike/trunk/content/jsf.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/jsf.html (original)
+++ websites/staging/deltaspike/trunk/content/jsf.html Sun Jan  5 22:21:19 2014
@@ -124,6 +124,10 @@
 <li><a href="#activation-of-custom-naming-conventions">Activation of custom naming
conventions</a></li>
 </ul>
 </li>
+<li><a href="#grouped-conversations">(Grouped-)Conversations</a><ul>
+<li><a href="#terminating-conversations">Terminating Conversations</a></li>
+</ul>
+</li>
 <li><a href="#support-of-ear-deployments">Support of EAR deployments</a></li>
 <li><a href="#hints">Hints</a></li>
 </ul>
@@ -784,6 +788,207 @@ Only annotate one <code>ViewConfig</code
 <p>DeltaSpike allows to customize the default naming convention via <code>View.DefaultBasePathBuilder</code>
and/or <code>View.DefaultFileNameBuilder</code> and/or <code>View.DefaultExtensionBuilder</code>.
 It's possible to change it for one usage via <code>View.basePathBuilder</code>
and/or <code>View.fileNameBuilder</code> and/or <code>View.extensionBuilder</code>
or globally via the config mechanism provided by DeltaSpike.
 The same is supported for folders via <code>Folder.DefaultFolderNameBuilder</code>.
In this case changing only one usage is possible via <code>Folder.folderNameBuilder</code>.</p>
+<h1 id="grouped-conversations">(Grouped-)Conversations</h1>
+<p>Available with all versions after 0.5.</p>
+<p>DeltaSpike conversations are based on the window-scope. Therefore, don't forget
to add the <code>ds:windowId</code> (<code>xmlns:ds="http://deltaspike.apache.org/jsf"</code>)
component in case of ClientWindowConfig#CLIENTWINDOW to your page(/template) and ensure that
the window-handling works properly (otherwise conversations won't work correctly).
+The base principle is similar to CODI-Conversations. CODI users just have to ensure that
they have to add <code>ds:windowId</code> and the names are slightly different.</p>
+<p>First of all it's important to mention that DeltaSpike starts (grouped) conversations
automatically as soon as you access conversation scoped beans. Furthermore, the invocation
of GroupedConversation#close leads to an immediate termination of the conversation.</p>
+<div class="codehilite"><pre><span class="nd">@GroupedConversationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean1</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="c1">//...</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>... leads to a conversation which contains just one bean with the group DemoBean1.</p>
+<p>Hint:
+If you would like to use the bean within your JSF pages, you have to add <code>@Named</code>
(javax.inject.Named ).</p>
+<p>(In case of CDI std. conversations there is just one big conversation which contains
all conversation scoped beans.)
+The grouped conversations provided by DeltaSpike are completely different. By default every
conversation scoped bean exists in an "isolated" conversation. That means there are several
parallel conversations within the same window.</p>
+<p>Example - Separated DeltaSpike conversations:</p>
+<div class="codehilite"><pre><span class="nd">@GroupedConversationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean2</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="c1">//...</span>
+<span class="o">}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean3</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="c1">//...</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>... leads to two independent conversations in the same window (context).
+If you close the conversation of DemoBean2, the conversation of DemoBean3 is still active.
+If you have an use-case (e.g. a wizard) which uses multiple beans which are linked together
very tightly, you can create a type-safe conversation group.</p>
+<p>Example - Grouped conversation scoped beans:</p>
+<div class="codehilite"><pre><span class="kd">interface</span> <span
class="nc">Wizard1</span> <span class="o">{}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Wizard1</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean4</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="c1">//...</span>
+<span class="o">}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Wizard1</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean5</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="c1">//...</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>You can use <code>@ConversationGroup</code> to tell DeltaSpike that
there is a logical group of beans. Technically <code>@ConversationGroup</code>
is just a CDI qualifier. Internally DeltaSpike uses this information to identify a conversation.
In the previous example both beans exist in the same conversation (group). If you terminate
the conversation group, both beans will be destroyed. If you don't use <code>@ConversationGroup</code>
explicitly, DeltaSpike uses the class of the bean as conversation group.</p>
+<p>Example - Injecting a conversation scoped bean with an explicit group:</p>
+<div class="codehilite"><pre><span class="c1">//...</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">CustomBean1</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Group1</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+    <span class="kd">private</span> <span class="n">CustomBean2</span>
<span class="n">demoBean</span><span class="o">;</span>
+
+    <span class="nd">@Inject</span>
+    <span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Group2</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+    <span class="kd">private</span> <span class="n">CustomBean2</span>
<span class="n">demoBean</span><span class="o">;</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Since <code>@ConversationGroup</code> is a std. CDI qualifier you have
to use it at the injection point. You have to do that esp. because it's possible to create
beans of the same type which exist in different groups (e.g. via producer methods).</p>
+<p>Example - Producer methods which produce conversation scoped beans with different
groups:</p>
+<div class="codehilite"><pre><span class="kd">interface</span> <span
class="nc">Group1</span> <span class="o">{}</span>
+<span class="kd">interface</span> <span class="nc">Group2</span>
<span class="o">{}</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">CustomBean2</span>
+<span class="o">{</span>
+    <span class="nd">@Produces</span>
+    <span class="nd">@GroupedConversationScoped</span>
+    <span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Group1</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+    <span class="kd">public</span> <span class="n">CustomBean2</span>
<span class="nf">createInstanceForGroup1</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">return</span> <span class="k">new</span>
<span class="nf">CustomBean2</span><span class="o">();</span>
+    <span class="o">}</span>
+
+    <span class="nd">@Produces</span>
+    <span class="nd">@GroupedConversationScoped</span>
+    <span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Group2</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+    <span class="kd">public</span> <span class="n">CustomBean2</span>
<span class="nf">createInstanceForGroup2</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">return</span> <span class="k">new</span>
<span class="nf">CustomBean2</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<h2 id="terminating-conversations">Terminating Conversations</h2>
+<p>You can inject the conversation via <code>@Inject</code> and use it
to terminate the conversation immediately or you inject the <code>GroupedConversationManager</code>
which can be used to terminate a given conversation (group). All conversations within a window
are closed autom., once <code>WindowContext#closeWindow</code> gets called for
the window.</p>
+<p>Example - Injecting and using the current conversation:</p>
+<div class="codehilite"><pre><span class="nd">@GroupedConversationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean6</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversation</span>
<span class="n">conversation</span><span class="o">;</span> <span
class="c1">//injects the conversation of DemoBean6 (!= conversation of DemoBean7)</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversation</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean7</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversation</span>
<span class="n">conversation</span><span class="o">;</span> <span
class="c1">//injects the conversation of DemoBean7 (!= conversation of DemoBean6)</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversation</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Example - Injecting and using the explicitly grouped conversation:</p>
+<div class="codehilite"><pre><span class="kd">interface</span> <span
class="nc">Wizard2</span> <span class="o">{}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Wizard2</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean8</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversation</span>
<span class="n">conversation</span><span class="o">;</span> <span
class="c1">//injects the conversation of Wizard2 (contains DemoBean8 and DemoBean9)</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversation</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+
+<span class="nd">@GroupedConversationScoped</span>
+<span class="nd">@ConversationGroup</span><span class="o">(</span><span
class="n">Wizard2</span><span class="o">.</span><span class="na">class</span><span
class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean9</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversation</span>
<span class="n">conversation</span><span class="o">;</span> <span
class="c1">//injects the conversation of Wizard2 (contains DemoBean8 and DemoBean9)</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversation</span><span class="o">.</span><span class="na">close</span><span
class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Example - Terminating a grouped conversation outside of the conversation:</p>
+<div class="codehilite"><pre><span class="c1">//...</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean10</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversationManager</span>
<span class="n">conversationManager</span><span class="o">;</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversationManager</span><span class="o">.</span><span
class="na">closeConversationGroup</span><span class="o">(</span><span
class="n">Wizard2</span><span class="o">.</span><span class="na">class</span><span
class="o">);</span>  <span class="c1">//closes the conversation of group Wizard2.class</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Example - Terminate all conversations:</p>
+<div class="codehilite"><pre><span class="c1">//...</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DemoBean11</span> <span class="kd">implements</span> <span
class="n">Serializable</span>
+<span class="o">{</span>
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">GroupedConversationManager</span>
<span class="n">conversationManager</span><span class="o">;</span>
+
+    <span class="c1">//...</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">finish</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span
class="na">conversationManager</span><span class="o">.</span><span
class="na">closeConversations</span><span class="o">();</span>  <span
class="c1">//closes all existing conversations within the current window (context)</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Hint:
+DeltaSpike conversations get closed/restarted immediately instead of keeping them until the
end of the request like std. conversations do, because the behaviour of std. conversations
breaks a lot of use-cases. However, if you really need to keep them until the end of the request,
you can close them in a @PostRenderView callback.</p>
 <h1 id="support-of-ear-deployments">Support of EAR deployments</h1>
 <p>Before using features described by this page, please ensure that you are aware of
<a href="https://issues.apache.org/jira/browse/DELTASPIKE-335">DELTASPIKE-335</a>
and the corresponding impact.</p>
 <h1 id="hints">Hints</h1>



Mime
View raw message