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.MenuBarComponent;
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 MenuBarTag extends AbstractMenuTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(MenuBarTag.class);
20  
21  	private ValueExpression actionListeners;
22  	private ValueExpression action;
23  	public String getComponentType() {
24  		return MenuBarComponent.COMPONENT_TYPE;
25  	}
26  
27  	public final void setAction(ValueExpression action) {
28  		this.action=action;
29  	}
30  
31  	public final void setActionListener(ValueExpression listeners) {
32  		this.actionListeners = listeners;
33  	}
34  
35  	protected void setProperties(UIComponent uiComponent) {
36  		if (LOG.isDebugEnabled()) {
37  			if (MenuBarComponent.COMPONENT_TYPE==getComponentType()) {
38  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
39  			}
40  			LOG.debug("  action='"+action+"'");
41  			LOG.debug("  actionListeners='"+actionListeners+"'");
42  		}
43  		if ((uiComponent instanceof MenuBarComponent)==false) {
44  			if (uiComponent instanceof UIViewRoot) {
45  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
46  			}
47  			throw new IllegalStateException("Component specified by tag is not instanceof of 'MenuBarComponent'.");
48  		}
49  
50  		super.setProperties(uiComponent);
51  
52  		MenuBarComponent component = (MenuBarComponent) uiComponent;
53  		FacesContext facesContext = getFacesContext();
54  
55  		if (action != null) {
56  			ListenersTools1_2.parseAction(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, action);
57  		}
58  
59  		if (actionListeners != null) {
60  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, actionListeners, true);
61  		}
62  	}
63  
64  	public void release() {
65  		action = null;
66  		actionListeners = null;
67  
68  		super.release();
69  	}
70  
71  }