1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.orchestra.conversation.jsf.components;
21
22 import java.io.IOException;
23
24 import javax.faces.component.UIComponentBase;
25 import javax.faces.context.FacesContext;
26
27 import org.apache.myfaces.orchestra.conversation.ConversationRequestParameterProvider;
28 import org.apache.myfaces.shared_orchestra.renderkit.RendererUtils;
29
30 /***
31 * Embedded links will start a new conversation context.
32 * <p>
33 * Use this as the ancestor of any clickable links that should cause the new page to
34 * run within a totally new set of conversations. This really only makes sense when
35 * those links cause a new window to open. That new window then acts completely
36 * independently of the original window (as long as data is stored in conversations,
37 * not directly in the http session).
38 * <p>
39 * Normally, all urls within a view are rendered with a query parameter holding the
40 * current conversation context id, causing a later request to that url to use the
41 * same context as was used to render the original page. This tag causes this special
42 * query parameter to be omitted for all urls output by nested components. When any
43 * such url is invoked, the missing conversation context id then causes a new
44 * conversation context to be created.
45 */
46 public class UISeparateConversationContext extends UIComponentBase
47 {
48 public static final String COMPONENT_FAMILY = "javax.faces.Component";
49 public static final String COMPONENT_TYPE = "org.apache.myfaces.orchestra.SeparateConversationContext";
50
51 public void encodeBegin(FacesContext context) throws IOException
52 {
53 super.encodeBegin(context);
54
55
56
57
58 ConversationRequestParameterProvider.setInSeparationMode(true);
59 }
60
61 public void encodeChildren(FacesContext context) throws IOException
62 {
63 try
64 {
65 RendererUtils.renderChildren(context, this);
66 }
67 finally
68 {
69
70
71
72
73
74
75 ConversationRequestParameterProvider.setInSeparationMode(false);
76 }
77 }
78
79 public boolean getRendersChildren()
80 {
81 return true;
82 }
83
84 public String getFamily()
85 {
86 return COMPONENT_FAMILY;
87 }
88 }