View Javadoc

1   package org.rcfaces.core.internal.taglib;
2   
3   import org.rcfaces.core.component.ListComponent;
4   import javax.faces.application.Application;
5   import javax.faces.component.UIComponent;
6   import org.rcfaces.core.internal.component.Properties;
7   import javax.el.ValueExpression;
8   import javax.faces.component.UIViewRoot;
9   import org.apache.commons.logging.Log;
10  import javax.servlet.jsp.tagext.Tag;
11  import org.apache.commons.logging.LogFactory;
12  import org.rcfaces.core.internal.tools.ListenersTools1_2;
13  import org.rcfaces.core.internal.tools.ListenersTools;
14  import javax.faces.context.FacesContext;
15  
16  public class ListTag extends ComboTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(ListTag.class);
20  
21  	private ValueExpression multipleSelect;
22  	private ValueExpression doubleClickListeners;
23  	private ValueExpression rowNumber;
24  	public String getComponentType() {
25  		return ListComponent.COMPONENT_TYPE;
26  	}
27  
28  	public final void setMultipleSelect(ValueExpression multipleSelect) {
29  		this.multipleSelect = multipleSelect;
30  	}
31  
32  	public final void setDoubleClickListener(ValueExpression doubleClickListeners) {
33  		this.doubleClickListeners = doubleClickListeners;
34  	}
35  
36  	public final void setRowNumber(ValueExpression rowNumber) {
37  		this.rowNumber = rowNumber;
38  	}
39  
40  	protected void setProperties(UIComponent uiComponent) {
41  		if (LOG.isDebugEnabled()) {
42  			if (ListComponent.COMPONENT_TYPE==getComponentType()) {
43  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
44  			}
45  			LOG.debug("  multipleSelect='"+multipleSelect+"'");
46  			LOG.debug("  rowNumber='"+rowNumber+"'");
47  		}
48  		if ((uiComponent instanceof ListComponent)==false) {
49  			if (uiComponent instanceof UIViewRoot) {
50  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
51  			}
52  			throw new IllegalStateException("Component specified by tag is not instanceof of 'ListComponent'.");
53  		}
54  
55  		super.setProperties(uiComponent);
56  
57  		ListComponent component = (ListComponent) uiComponent;
58  		FacesContext facesContext = getFacesContext();
59  
60  		if (multipleSelect != null) {
61  			if (multipleSelect.isLiteralText()==false) {
62  				component.setValueExpression(Properties.MULTIPLE_SELECT, multipleSelect);
63  
64  			} else {
65  				component.setMultipleSelect(getBool(multipleSelect.getExpressionString()));
66  			}
67  		}
68  
69  		if (doubleClickListeners != null) {
70  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.DOUBLE_CLICK_LISTENER_TYPE, doubleClickListeners);
71  		}
72  
73  		if (rowNumber != null) {
74  			if (rowNumber.isLiteralText()==false) {
75  				component.setValueExpression(Properties.ROW_NUMBER, rowNumber);
76  
77  			} else {
78  				component.setRowNumber(getInt(rowNumber.getExpressionString()));
79  			}
80  		}
81  	}
82  
83  	public void release() {
84  		multipleSelect = null;
85  		doubleClickListeners = null;
86  		rowNumber = null;
87  
88  		super.release();
89  	}
90  
91  }