1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.component;
21
22 import org.apache.myfaces.tobago.util.FacesVersion;
23
24 import javax.faces.component.UIComponentBase;
25 import javax.faces.component.UIViewRoot;
26 import javax.faces.context.FacesContext;
27 import javax.faces.event.ComponentSystemEvent;
28 import javax.faces.event.ListenerFor;
29 import javax.faces.event.PostAddToViewEvent;
30 import javax.faces.event.PreRenderViewEvent;
31
32 @ListenerFor(systemEventClass = PostAddToViewEvent.class)
33 public abstract class AbstractUIMetaLink extends UIComponentBase {
34
35 @Override
36 public void processEvent(final ComponentSystemEvent event) {
37
38 super.processEvent(event);
39
40 if (event instanceof PreRenderViewEvent) {
41 addComponentResource();
42 } else if (event instanceof PostAddToViewEvent) {
43 if (FacesVersion.supports21() || !FacesVersion.isMyfaces()) {
44
45
46
47
48
49 getFacesContext().getViewRoot().subscribeToEvent(PreRenderViewEvent.class, this);
50 } else {
51 addComponentResource();
52 }
53 }
54 }
55
56 private void addComponentResource() {
57 final FacesContext facesContext = getFacesContext();
58 final UIViewRoot root = facesContext.getViewRoot();
59 root.addComponentResource(facesContext, this);
60 }
61
62 public abstract String getCharset();
63
64 public abstract String getRev();
65
66 public abstract String getHref();
67
68 public abstract String getHreflang();
69
70 public abstract String getRel();
71
72 public abstract String getMedia();
73
74 public abstract String getType();
75 }