View Javadoc

1   package org.rcfaces.core.internal.taglib;
2   
3   import javax.faces.application.Application;
4   import javax.faces.component.UIComponent;
5   import org.rcfaces.core.internal.component.Properties;
6   import org.rcfaces.core.component.ProgressBarComponent;
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 ProgressBarTag extends AbstractInputTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(ProgressBarTag.class);
20  
21  	private ValueExpression minimum;
22  	private ValueExpression maximum;
23  	private ValueExpression indeterminate;
24  	public String getComponentType() {
25  		return ProgressBarComponent.COMPONENT_TYPE;
26  	}
27  
28  	public final void setMinimum(ValueExpression minimum) {
29  		this.minimum = minimum;
30  	}
31  
32  	public final void setMaximum(ValueExpression maximum) {
33  		this.maximum = maximum;
34  	}
35  
36  	public final void setIndeterminate(ValueExpression indeterminate) {
37  		this.indeterminate = indeterminate;
38  	}
39  
40  	protected void setProperties(UIComponent uiComponent) {
41  		if (LOG.isDebugEnabled()) {
42  			if (ProgressBarComponent.COMPONENT_TYPE==getComponentType()) {
43  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
44  			}
45  			LOG.debug("  minimum='"+minimum+"'");
46  			LOG.debug("  maximum='"+maximum+"'");
47  			LOG.debug("  indeterminate='"+indeterminate+"'");
48  		}
49  		if ((uiComponent instanceof ProgressBarComponent)==false) {
50  			if (uiComponent instanceof UIViewRoot) {
51  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
52  			}
53  			throw new IllegalStateException("Component specified by tag is not instanceof of 'ProgressBarComponent'.");
54  		}
55  
56  		super.setProperties(uiComponent);
57  
58  		ProgressBarComponent component = (ProgressBarComponent) uiComponent;
59  		FacesContext facesContext = getFacesContext();
60  
61  		if (minimum != null) {
62  			if (minimum.isLiteralText()==false) {
63  				component.setValueExpression(Properties.MINIMUM, minimum);
64  
65  			} else {
66  				component.setMinimum(getDouble(minimum.getExpressionString()));
67  			}
68  		}
69  
70  		if (maximum != null) {
71  			if (maximum.isLiteralText()==false) {
72  				component.setValueExpression(Properties.MAXIMUM, maximum);
73  
74  			} else {
75  				component.setMaximum(getDouble(maximum.getExpressionString()));
76  			}
77  		}
78  
79  		if (indeterminate != null) {
80  			if (indeterminate.isLiteralText()==false) {
81  				component.setValueExpression(Properties.INDETERMINATE, indeterminate);
82  
83  			} else {
84  				component.setIndeterminate(getBool(indeterminate.getExpressionString()));
85  			}
86  		}
87  	}
88  
89  	public void release() {
90  		minimum = null;
91  		maximum = null;
92  		indeterminate = null;
93  
94  		super.release();
95  	}
96  
97  }