View Javadoc

1   package org.rcfaces.core.internal.taglib;
2   
3   import javax.faces.application.Application;
4   import org.rcfaces.core.component.AbstractConverterCommandComponent;
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 abstract class AbstractConverterCommandTag extends AbstractCommandTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(AbstractConverterCommandTag.class);
20  
21  	private ValueExpression converter;
22  	public final void setConverter(ValueExpression converter) {
23  		this.converter = converter;
24  	}
25  
26  	protected void setProperties(UIComponent uiComponent) {
27  		if (LOG.isDebugEnabled()) {
28  			LOG.debug("  converter='"+converter+"'");
29  		}
30  		if ((uiComponent instanceof AbstractConverterCommandComponent)==false) {
31  			if (uiComponent instanceof UIViewRoot) {
32  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
33  			}
34  			throw new IllegalStateException("Component specified by tag is not instanceof of 'AbstractConverterCommandComponent'.");
35  		}
36  
37  		super.setProperties(uiComponent);
38  
39  		AbstractConverterCommandComponent component = (AbstractConverterCommandComponent) uiComponent;
40  		FacesContext facesContext = getFacesContext();
41  
42  		if (converter != null) {
43  			if (converter.isLiteralText()==false) {
44  				component.setValueExpression(Properties.CONVERTER, converter);
45  
46  			} else {
47  				component.setConverter(converter.getExpressionString());
48  			}
49  		}
50  	}
51  
52  	public void release() {
53  		converter = null;
54  
55  		super.release();
56  	}
57  
58  }