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
61 @Override
62 protected UIComponent createVerbatimComponentFromBodyContent()
63 {
64 UIOutput component = (UIOutput)super.createVerbatimComponentFromBodyContent();
65 FacesContext facesContext = FacesContext.getCurrentInstance();
66 Object response = facesContext.getExternalContext().getResponse();
67 String wrappedOutput;
68
69 if (response instanceof ServletViewResponseWrapper)
70 {
71 ServletViewResponseWrapper wrappedResponse = (ServletViewResponseWrapper)response;
72 wrappedOutput = wrappedResponse.toString();
73 if (wrappedOutput != null && wrappedOutput.length() > 0)
74 {
75 String componentvalue = null;
76 if (component != null)
77 {
78
79 componentvalue = (String)component.getValue();
80 }
81 component = super.createVerbatimComponent();
82 if (componentvalue != null)
83 {
84 component.setValue(wrappedOutput + componentvalue);
85 }
86 else
87 {
88 component.setValue(wrappedOutput);
89 }
90 wrappedResponse.reset();
91 }
92 }
93 return component;
94 }
95
96 }