KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > wap > base > MessageTagBase


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.wap.base;
17
18 import javax.faces.component.UIComponent;
19 import javax.faces.component.UIMessage;
20 import javax.faces.context.FacesContext;
21 import javax.faces.el.ValueBinding;
22
23 /**
24  * Implements attributes:
25  * <ol>
26  * <li>for
27  * <li>showDetail
28  * <li>showSummary
29  * </ol>
30  *
31  * @author <a HREF="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author: matzew $)
32  * @version $Revision: 1.1 $ $Date: 2004/12/30 09:37:27 $
33  * $Log: MessageTagBase.java,v $
34  * Revision 1.1 2004/12/30 09:37:27 matzew
35  * added a new RenderKit for WML. Thanks to Jirí Žaloudek
36  *
37  */

38
39 public abstract class MessageTagBase extends ComponentTagBase {
40     
41     /* properties */
42     private String JavaDoc forComponent = null;
43     private String JavaDoc showDetail = null;
44     private String JavaDoc showSummary = null;
45     
46     /** Creates a new instance of UIComponentTagBase */
47     public MessageTagBase() {
48         super();
49     }
50     
51     public abstract String JavaDoc getRendererType();
52     
53     public void release() {
54         super.release();
55         this.forComponent = null;
56         this.showDetail = null;
57         this.showSummary= null;
58     }
59     
60     protected void setProperties(UIComponent component) {
61         super.setProperties(component);
62         
63         if (getRendererType() != null) {
64             component.setRendererType(getRendererType());
65         }
66         
67         UIMessage comp = (UIMessage)component;
68         
69         if (forComponent != null) {
70             if (isValueReference(forComponent)) {
71                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(forComponent);
72                 component.setValueBinding("for", vb);
73             } else {
74                 comp.setFor(forComponent);
75             }
76         }
77         
78         if (showDetail != null) {
79             if (isValueReference(showDetail)) {
80                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(showDetail);
81                 component.setValueBinding("showDetail", vb);
82             } else {
83                 boolean bool = Boolean.valueOf(showDetail).booleanValue();
84                 comp.setShowDetail(bool);
85             }
86         }
87         
88         if (showSummary != null) {
89             if (isValueReference(showSummary)) {
90                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(showSummary);
91                 component.setValueBinding("showSummary", vb);
92             } else {
93                 boolean bool = Boolean.valueOf(showSummary).booleanValue();
94                 comp.setShowSummary(bool);
95             }
96         }
97     }
98        
99     // ----------------------------------------------------- Getters and Setters
100
public String JavaDoc getFor() {
101         return forComponent;
102     }
103     
104     public void setFor(String JavaDoc forComponent) {
105         this.forComponent = forComponent;
106     }
107     
108     public String JavaDoc getShowDetail() {
109         return showDetail;
110     }
111     
112     public void setShowDetail(String JavaDoc showDetail) {
113         this.showDetail = showDetail;
114     }
115     
116     public String JavaDoc getShowSummary() {
117         return showSummary;
118     }
119     
120     public void setShowSummary(String JavaDoc showSummary) {
121         this.showSummary = showSummary;
122     }
123     
124 }
125
Popular Tags