1
2
3
4 package org.rcfaces.core.internal.facelets;
5
6 import javax.faces.component.UIComponent;
7
8 import org.rcfaces.core.internal.manager.IServerDataManager;
9
10 import com.sun.facelets.FaceletContext;
11 import com.sun.facelets.tag.TagAttribute;
12 import com.sun.facelets.tag.TagConfig;
13 import com.sun.facelets.tag.TagException;
14 import com.sun.facelets.tag.TagHandler;
15 import com.sun.facelets.tag.jsf.ComponentSupport;
16
17
18
19
20
21
22 public class ServerDataHandler extends TagHandler {
23 private static final String REVISION = "$Revision: 1.1 $";
24
25 private final TagAttribute name;
26
27 private final TagAttribute value;
28
29 public ServerDataHandler(TagConfig config) {
30 super(config);
31 this.name = this.getRequiredAttribute("name");
32 this.value = this.getRequiredAttribute("value");
33 }
34
35 public void apply(FaceletContext ctx, UIComponent parent) {
36 if (parent == null) {
37 throw new TagException(this.tag, "Parent UIComponent was null");
38 }
39
40
41 if (ComponentSupport.isNew(parent) == false) {
42 return;
43 }
44
45 IServerDataManager serverDataCapability = (IServerDataManager) parent;
46
47 String nameValue = name.getValue(ctx);
48 if (value.isLiteral()) {
49 serverDataCapability.setServerData(nameValue, value.getValue());
50 return;
51 }
52
53 serverDataCapability.setServerData(nameValue, value.getValueExpression(
54 ctx, Object.class));
55 }
56 }