View Javadoc

1   /*
2    * $Id: ELOptionsCollectionTagBeanInfo.java 376779 2006-02-10 18:08:58Z husted $
3    *
4    * Copyright 1999-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.strutsel.taglib.html;
19  
20  import java.beans.IntrospectionException;
21  import java.beans.PropertyDescriptor;
22  import java.beans.SimpleBeanInfo;
23  
24  import java.util.ArrayList;
25  
26  /***
27   * This is the <code>BeanInfo</code> descriptor for the
28   * <code>org.apache.strutsel.taglib.html.ELOptionsCollectionTag</code> class.
29   * It is needed to override the default mapping of custom tag attribute names
30   * to class attribute names. <p> This is because the value of the unevaluated
31   * EL expression has to be kept separately from the evaluated value, which is
32   * stored in the base class. This is related to the fact that the JSP compiler
33   * can choose to reuse different tag instances if they received the same
34   * original attribute values, and the JSP compiler can choose to not re-call
35   * the setter methods, because it can assume the same values are already set.
36   */
37  public class ELOptionsCollectionTagBeanInfo extends SimpleBeanInfo {
38      public PropertyDescriptor[] getPropertyDescriptors() {
39          ArrayList proplist = new ArrayList();
40  
41          try {
42              proplist.add(new PropertyDescriptor("filter",
43                      ELOptionsCollectionTag.class, null, "setFilterExpr"));
44          } catch (IntrospectionException ex) {
45          }
46  
47          try {
48              proplist.add(new PropertyDescriptor("label",
49                      ELOptionsCollectionTag.class, null, "setLabelExpr"));
50          } catch (IntrospectionException ex) {
51          }
52  
53          try {
54              proplist.add(new PropertyDescriptor("name",
55                      ELOptionsCollectionTag.class, null, "setNameExpr"));
56          } catch (IntrospectionException ex) {
57          }
58  
59          try {
60              proplist.add(new PropertyDescriptor("property",
61                      ELOptionsCollectionTag.class, null, "setPropertyExpr"));
62          } catch (IntrospectionException ex) {
63          }
64  
65          try {
66              proplist.add(new PropertyDescriptor("style",
67                      ELOptionsCollectionTag.class, null, "setStyleExpr"));
68          } catch (IntrospectionException ex) {
69          }
70  
71          try {
72              proplist.add(new PropertyDescriptor("styleClass",
73                      ELOptionsCollectionTag.class, null, "setStyleClassExpr"));
74          } catch (IntrospectionException ex) {
75          }
76  
77          try {
78              proplist.add(new PropertyDescriptor("value",
79                      ELOptionsCollectionTag.class, null, "setValueExpr"));
80          } catch (IntrospectionException ex) {
81          }
82  
83          PropertyDescriptor[] result = new PropertyDescriptor[proplist.size()];
84  
85          return ((PropertyDescriptor[]) proplist.toArray(result));
86      }
87  }