1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.taglib.core;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.component.UINamingContainer;
23 import javax.faces.component.UIOutput;
24 import javax.faces.context.FacesContext;
25 import javax.faces.webapp.UIComponentELTag;
26
27 import org.apache.myfaces.application.jsp.ServletViewResponseWrapper;
28
29
30
31
32
33 public class SubviewTag extends UIComponentELTag
34 {
35 public SubviewTag()
36 {
37 super();
38 }
39
40 @Override
41 public String getComponentType()
42 {
43 return UINamingContainer.COMPONENT_TYPE;
44 }
45
46 @Override
47 public String getRendererType()
48 {
49 return null;
50 }
51
52
53
54
55
56
57
58
59
60 @Override
61 protected UIComponent createVerbatimComponentFromBodyContent()
62 {
63 UIOutput component = (UIOutput)super.createVerbatimComponentFromBodyContent();
64 FacesContext facesContext = FacesContext.getCurrentInstance();
65 Object response = facesContext.getExternalContext().getResponse();
66 String wrappedOutput;
67
68 if (response instanceof ServletViewResponseWrapper)
69 {
70 ServletViewResponseWrapper wrappedResponse = (ServletViewResponseWrapper)response;
71 wrappedOutput = wrappedResponse.toString();
72 if (wrappedOutput != null && wrappedOutput.length() > 0)
73 {
74 String componentvalue = null;
75 if (component != null)
76 {
77
78 componentvalue = (String)component.getValue();
79 }
80 component = super.createVerbatimComponent();
81 if (componentvalue != null)
82 {
83 component.setValue(wrappedOutput + componentvalue);
84 }
85 else
86 {
87 component.setValue(wrappedOutput);
88 }
89 wrappedResponse.reset();
90 }
91 }
92 return component;
93 }
94
95 }