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 javax.el.ValueExpression;
7   import javax.faces.component.UIViewRoot;
8   import org.apache.commons.logging.Log;
9   import javax.servlet.jsp.tagext.Tag;
10  import org.apache.commons.logging.LogFactory;
11  import org.rcfaces.core.internal.tools.ListenersTools1_2;
12  import org.rcfaces.core.internal.tools.ListenersTools;
13  import org.rcfaces.core.component.HelpButtonComponent;
14  import javax.faces.context.FacesContext;
15  
16  public class HelpButtonTag extends ImageButtonTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(HelpButtonTag.class);
20  
21  	private ValueExpression forValue;
22  	public String getComponentType() {
23  		return HelpButtonComponent.COMPONENT_TYPE;
24  	}
25  
26  	public final void setFor(ValueExpression forValue) {
27  		this.forValue = forValue;
28  	}
29  
30  	protected void setProperties(UIComponent uiComponent) {
31  		if (LOG.isDebugEnabled()) {
32  			if (HelpButtonComponent.COMPONENT_TYPE==getComponentType()) {
33  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
34  			}
35  			LOG.debug("  forValue='"+forValue+"'");
36  		}
37  		if ((uiComponent instanceof HelpButtonComponent)==false) {
38  			if (uiComponent instanceof UIViewRoot) {
39  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
40  			}
41  			throw new IllegalStateException("Component specified by tag is not instanceof of 'HelpButtonComponent'.");
42  		}
43  
44  		super.setProperties(uiComponent);
45  
46  		HelpButtonComponent component = (HelpButtonComponent) uiComponent;
47  		FacesContext facesContext = getFacesContext();
48  
49  		if (forValue != null) {
50  			if (forValue.isLiteralText()==false) {
51  				component.setValueExpression(Properties.FOR, forValue);
52  
53  			} else {
54  				component.setFor(forValue.getExpressionString());
55  			}
56  		}
57  	}
58  
59  	public void release() {
60  		forValue = null;
61  
62  		super.release();
63  	}
64  
65  }