KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > compiler > UILiteralTextHandler


1 /**
2  * Licensed under the Common Development and Distribution License,
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.sun.com/cddl/
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11  * implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */

14
15 package com.sun.facelets.compiler;
16
17 import javax.faces.component.UIComponent;
18
19 import java.io.IOException JavaDoc;
20
21 import javax.el.ELException;
22 import javax.faces.FacesException;
23
24 import com.sun.facelets.FaceletContext;
25 import com.sun.facelets.FaceletException;
26 import com.sun.facelets.FaceletHandler;
27 import com.sun.facelets.tag.TextHandler;
28 import com.sun.facelets.tag.jsf.ComponentSupport;
29
30 final class UILiteralTextHandler implements FaceletHandler, TextHandler {
31     
32     protected final String JavaDoc txtString;
33     
34     public UILiteralTextHandler(String JavaDoc txtString) {
35         this.txtString = txtString;
36     }
37
38     public void apply(FaceletContext ctx, UIComponent parent)
39             throws IOException JavaDoc, FacesException, FaceletException, ELException {
40         if (parent != null) {
41             UIComponent c = new UILiteralText(this.txtString);
42             c.setId(ComponentSupport.getViewRoot(ctx, parent).createUniqueId());
43             parent.getChildren().add(c);
44         }
45     }
46
47     public String JavaDoc getText() {
48         return this.txtString;
49     }
50
51     public String JavaDoc getText(FaceletContext ctx) {
52         return this.txtString;
53     }
54 }
55
Popular Tags