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.component.TabbedPaneComponent;
13  import org.rcfaces.core.internal.tools.ListenersTools;
14  import javax.faces.context.FacesContext;
15  
16  public class TabbedPaneTag extends CardBoxTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(TabbedPaneTag.class);
20  
21  	private ValueExpression closeListeners;
22  	private ValueExpression closable;
23  	private ValueExpression preSelectionListeners;
24  	private ValueExpression showValue;
25  	public String getComponentType() {
26  		return TabbedPaneComponent.COMPONENT_TYPE;
27  	}
28  
29  	public final void setCloseListener(ValueExpression closeListeners) {
30  		this.closeListeners = closeListeners;
31  	}
32  
33  	public final void setClosable(ValueExpression closable) {
34  		this.closable = closable;
35  	}
36  
37  	public final void setPreSelectionListener(ValueExpression preSelectionListeners) {
38  		this.preSelectionListeners = preSelectionListeners;
39  	}
40  
41  	public final void setShowValue(ValueExpression showValue) {
42  		this.showValue = showValue;
43  	}
44  
45  	protected void setProperties(UIComponent uiComponent) {
46  		if (LOG.isDebugEnabled()) {
47  			if (TabbedPaneComponent.COMPONENT_TYPE==getComponentType()) {
48  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
49  			}
50  			LOG.debug("  closable='"+closable+"'");
51  			LOG.debug("  showValue='"+showValue+"'");
52  		}
53  		if ((uiComponent instanceof TabbedPaneComponent)==false) {
54  			if (uiComponent instanceof UIViewRoot) {
55  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
56  			}
57  			throw new IllegalStateException("Component specified by tag is not instanceof of 'TabbedPaneComponent'.");
58  		}
59  
60  		super.setProperties(uiComponent);
61  
62  		TabbedPaneComponent component = (TabbedPaneComponent) uiComponent;
63  		FacesContext facesContext = getFacesContext();
64  
65  		if (closeListeners != null) {
66  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.CLOSE_LISTENER_TYPE, closeListeners);
67  		}
68  
69  		if (closable != null) {
70  			if (closable.isLiteralText()==false) {
71  				component.setValueExpression(Properties.CLOSABLE, closable);
72  
73  			} else {
74  				component.setClosable(getBool(closable.getExpressionString()));
75  			}
76  		}
77  
78  		if (preSelectionListeners != null) {
79  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.PRE_SELECTION_LISTENER_TYPE, preSelectionListeners);
80  		}
81  
82  		if (showValue != null) {
83  			if (showValue.isLiteralText()==false) {
84  				component.setValueExpression(Properties.SHOW_VALUE, showValue);
85  
86  			} else {
87  				component.setShowValue(showValue.getExpressionString());
88  			}
89  		}
90  	}
91  
92  	public void release() {
93  		closeListeners = null;
94  		closable = null;
95  		preSelectionListeners = null;
96  		showValue = null;
97  
98  		super.release();
99  	}
100 
101 }