1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.tag.composite; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.util.logging.Level; |
23 | |
import java.util.logging.Logger; |
24 | |
|
25 | |
import javax.faces.component.UIComponent; |
26 | |
import javax.faces.view.facelets.FaceletContext; |
27 | |
import javax.faces.view.facelets.TagConfig; |
28 | |
import javax.faces.view.facelets.TagHandler; |
29 | |
|
30 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag; |
31 | |
import org.apache.myfaces.view.facelets.AbstractFaceletContext; |
32 | |
import org.apache.myfaces.view.facelets.FaceletCompositionContext; |
33 | |
import org.apache.myfaces.view.facelets.tag.ComponentContainerHandler; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
@JSFFaceletTag(name="composite:insertChildren") |
40 | |
public class InsertChildrenHandler extends TagHandler implements ComponentContainerHandler |
41 | |
{ |
42 | |
public static final String INSERT_CHILDREN_USED = "org.apache.myfaces.INSERT_CHILDREN_USED"; |
43 | |
|
44 | 0 | private static final Logger log = Logger.getLogger(InsertChildrenHandler.class.getName()); |
45 | |
|
46 | |
public InsertChildrenHandler(TagConfig config) |
47 | |
{ |
48 | 0 | super(config); |
49 | 0 | } |
50 | |
|
51 | |
public void apply(FaceletContext ctx, UIComponent parent) |
52 | |
throws IOException |
53 | |
{ |
54 | 0 | UIComponent parentCompositeComponent |
55 | |
= FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack(); |
56 | |
|
57 | 0 | AbstractFaceletContext actx = (AbstractFaceletContext) ctx; |
58 | |
|
59 | 0 | if (actx.isBuildingCompositeComponentMetadata()) |
60 | |
{ |
61 | 0 | CompositeComponentBeanInfo beanInfo = |
62 | |
(CompositeComponentBeanInfo) parentCompositeComponent.getAttributes() |
63 | |
.get(UIComponent.BEANINFO_KEY); |
64 | |
|
65 | 0 | if (beanInfo == null) |
66 | |
{ |
67 | 0 | if (log.isLoggable(Level.SEVERE)) |
68 | |
{ |
69 | 0 | log.severe("Cannot find composite bean descriptor UIComponent.BEANINFO_KEY "); |
70 | |
} |
71 | 0 | return; |
72 | |
} |
73 | |
|
74 | 0 | beanInfo.getBeanDescriptor().setValue(INSERT_CHILDREN_USED, Boolean.TRUE); |
75 | 0 | } |
76 | |
else |
77 | |
{ |
78 | 0 | actx.includeCompositeComponentDefinition(parent, null); |
79 | |
} |
80 | 0 | } |
81 | |
|
82 | |
} |