View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import javax.el.ValueExpression;
5   import org.apache.commons.logging.Log;
6   import java.util.HashSet;
7   import org.apache.commons.logging.LogFactory;
8   import java.util.Arrays;
9   import java.util.Set;
10  import org.rcfaces.core.component.ComboComponent;
11  import org.rcfaces.core.component.capability.IDoubleClickEventCapability;
12  import org.rcfaces.core.component.capability.IMultipleSelectCapability;
13  
14  /**
15   * <p>The list Component is based on the standard HTML tag &lt;SELECT&gt;.</p>
16   * <p>The list Component has the following capabilities :
17   * <ul>
18   * <li>IMultipleSelectCapability</li>
19   * <li>IDoubleClickEventCapability</li>
20   * </ul>
21   * </p>
22   * 
23   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ListComponent.html">list</a> renderer is linked to the <a href="/jsdocs/index.html?f_list.html" target="_blank">f_list</a> javascript class. f_list extends f_abstractList, fa_selectionProvider<String[]></p>
24   * 
25   * <p> Table of component style classes: </p>
26   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
27   * <tbody>
28   * 
29   * <tr style="text-align:left">
30   * <th  width="33%">Style Name</th>
31   * <th width="50%">Description</th>
32   * </tr>
33   * 
34   * <tr  style="text-align:left">
35   * <td width="33%">f_list</td>
36   * <td width="50%">Defines styles for the wrapper SELECT element</td>
37   * </tr>
38   * 
39   * </tbody>
40   * </table>
41   */
42  public class ListComponent extends ComboComponent implements 
43  	IMultipleSelectCapability,
44  	IDoubleClickEventCapability {
45  
46  	private static final Log LOG = LogFactory.getLog(ListComponent.class);
47  
48  	public static final String COMPONENT_TYPE="org.rcfaces.core.list";
49  
50  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(ComboComponent.CAMELIA_ATTRIBUTES);
51  	static {
52  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"multipleSelect","doubleClickListener","rowNumber"}));
53  	}
54  
55  	public ListComponent() {
56  		setRendererType(COMPONENT_TYPE);
57  	}
58  
59  	public ListComponent(String componentId) {
60  		this();
61  		setId(componentId);
62  	}
63  
64  	public boolean isMultipleSelect() {
65  		return isMultipleSelect(null);
66  	}
67  
68  	/**
69  	 * See {@link #isMultipleSelect() isMultipleSelect()} for more details
70  	 */
71  	public boolean isMultipleSelect(javax.faces.context.FacesContext facesContext) {
72  		return engine.getBoolProperty(Properties.MULTIPLE_SELECT, false, facesContext);
73  	}
74  
75  	/**
76  	 * Returns <code>true</code> if the attribute "multipleSelect" is set.
77  	 * @return <code>true</code> if the attribute is set.
78  	 */
79  	public final boolean isMultipleSelectSetted() {
80  		return engine.isPropertySetted(Properties.MULTIPLE_SELECT);
81  	}
82  
83  	public void setMultipleSelect(boolean multipleSelect) {
84  		engine.setProperty(Properties.MULTIPLE_SELECT, multipleSelect);
85  	}
86  
87  	public final void addDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
88  		addFacesListener(listener);
89  	}
90  
91  	public final void removeDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
92  		removeFacesListener(listener);
93  	}
94  
95  	public final javax.faces.event.FacesListener [] listDoubleClickListeners() {
96  		return getFacesListeners(org.rcfaces.core.event.IDoubleClickListener.class);
97  	}
98  
99  	/**
100 	 * Returns an int value specifying the number of rows to be displayed.
101 	 * @return number of rows
102 	 */
103 	public int getRowNumber() {
104 		return getRowNumber(null);
105 	}
106 
107 	/**
108 	 * Returns an int value specifying the number of rows to be displayed.
109 	 * @return number of rows
110 	 */
111 	public int getRowNumber(javax.faces.context.FacesContext facesContext) {
112 		return engine.getIntProperty(Properties.ROW_NUMBER, 0, facesContext);
113 	}
114 
115 	/**
116 	 * Sets an int value specifying the number of rows to be displayed.
117 	 * @param rowNumber number of rows
118 	 */
119 	public void setRowNumber(int rowNumber) {
120 		engine.setProperty(Properties.ROW_NUMBER, rowNumber);
121 	}
122 
123 	/**
124 	 * Sets an int value specifying the number of rows to be displayed.
125 	 * @param rowNumber number of rows
126 	 */
127 	/**
128 	 * Returns <code>true</code> if the attribute "rowNumber" is set.
129 	 * @return <code>true</code> if the attribute is set.
130 	 */
131 	public boolean isRowNumberSetted() {
132 		return engine.isPropertySetted(Properties.ROW_NUMBER);
133 	}
134 
135 	protected Set getCameliaFields() {
136 		return CAMELIA_ATTRIBUTES;
137 	}
138 }