2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.taglib;
19  
20  import javax.faces.component.UIComponent;
21  import javax.faces.context.FacesContext;
22  import javax.faces.el.ValueBinding;
23  import javax.faces.webapp.UIComponentTag;
24  
25  import org.apache.shale.component.Token;
26  
27  /***
28   * <p>JSP custom tag for the {@link Token} component.</p>
29   *
30   * $Id: TokenTag.java 464373 2006-10-16 04:21:54Z rahul $
31   */
32  public class TokenTag extends UIComponentTag {
33  
34  
35      /***
36       * <p>Pushs the tag attributes to the {@link Token}'s
37       * component properties.</p>
38       *
39       * @param component Component for which to set properties
40       */
41      protected void setProperties(UIComponent component) {
42          super.setProperties(component);
43  
44          FacesContext context = getFacesContext();
45  
46          if (messageSummary != null) {
47              if (this.isValueReference(messageSummary)) { // needs to be non-static
48                  ValueBinding vb = context.getApplication().createValueBinding(messageSummary);
49                  component.setValueBinding("messageSummary", vb);
50              } else {
51                  component.getAttributes().put("messageSummary", messageSummary);
52              }
53          }
54  
55          if (messageDetail != null) {
56              if (this.isValueReference(messageDetail)) { // needs to be non-static
57                  ValueBinding vb = context.getApplication().createValueBinding(messageDetail);
58                  component.setValueBinding("messageDetail", vb);
59              } else {
60                  component.getAttributes().put("messageDetail", messageDetail);
61              }
62          }
63  
64      }
65  
66  
67      /***
68       * <p>Return the required component type.</p>
69       */
70      public String getComponentType() {
71          return "org.apache.shale.Token";
72      }
73  
74  
75      /***
76       * <p>Return the required renderer type.</p>
77       */
78      public String getRendererType() {
79          return "org.apache.shale.Token";
80      }
81  
82      /***
83       * <p>A validation messageSummary override that can be used to change the default
84       * validation messageSummary when the token verification fails.</p>
85       */
86      private String messageSummary = null;
87  
88      /***
89       * <p>Sets a <code>messageSummary</code> override used when reporting
90       * a {@link org.apache.shale.component.Token} verification failure.</p>
91       *
92       * @param message The new message summary
93       */
94      public void setMessageSummary(String message) {
95         this.messageSummary = message;
96      }
97  
98      /***
99       * <p>Returns a <code>messageSummary</code> override used when reporting
100      * a {@link org.apache.shale.component.Token} verification failure.</p>
101      */
102     public String getMessageSummary() {
103        return messageSummary;
104     }
105 
106 
107     /***
108      * <p>A validation messageDetail override that can be used to change the default
109      * validation messageDetail when the token verification fails.</p>
110      */
111     private String messageDetail = null;
112 
113     /***
114      * <p>Sets a <code>messageDetail</code> override used when reporting
115      * a {@link org.apache.shale.component.Token} verification failure.</p>
116      *
117      * @param message The new message detail
118      */
119     public void setMessageDetail(String message) {
120        this.messageDetail = message;
121     }
122 
123     /***
124      * <p>Returns a <code>messageDetail</code> override used when reporting
125      * a {@link org.apache.shale.component.Token} verification failure.</p>
126      */
127     public String getMessageDetail() {
128        return messageDetail;
129     }
130 
131 
132 }