📄 abstracthtmlactionsourcecomponenttag.java
字号:
/* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package de.mindmatters.faces.taglib.jsp;import javax.faces.component.ActionSource;import javax.faces.component.UIComponent;import javax.faces.el.MethodBinding;import javax.faces.event.ActionEvent;import de.mindmatters.faces.el.ConstantMethodBinding;/** * <strong>AbstractHtmlActionSourceComponentTag</strong> is a convenience base * class that implements attributes needed for any concrete HTML action source * jsp tag. * * @author Andreas Kuhrwahl * */public abstract class AbstractHtmlActionSourceComponentTag extends AbstractHtmlEventHandlerComponentTag { /** The action attribute. */ private String action; /** The immediate attribute. */ private String immediate; /** The actionListener attribute. */ private String actionListener; /** * {@inheritDoc} */ public void release() { super.release(); this.action = null; this.immediate = null; this.actionListener = null; } /** * {@inheritDoc} */ protected void setProperties(final UIComponent component) { super.setProperties(component); setActionProperty(component); setActionListenerProperty(component); setImmediateProperty(component); } /** * Sets the action property on the associated UIComponent component. * * @param component * The associated UIComponent */ protected void setActionProperty(final UIComponent component) { if (this.action != null) { if (!(component instanceof ActionSource)) { throw new IllegalArgumentException("Component " + component.getClientId(getFacesContext()) + " is no ActionSource"); } MethodBinding mb; if (isValueReference(this.action)) { mb = getFacesContext().getApplication().createMethodBinding( this.action, null); } else { mb = new ConstantMethodBinding(this.action); } ((ActionSource) component).setAction(mb); } } /** * Sets the actionListener property on the associated UIComponent component. * * @param component * The associated UIComponent */ protected void setActionListenerProperty(final UIComponent component) { if (this.actionListener != null) { if (!(component instanceof ActionSource)) { throw new IllegalArgumentException("Component " + component.getClientId(getFacesContext()) + " is no ActionSource"); } if (isValueReference(this.actionListener)) { MethodBinding mb = getFacesContext().getApplication() .createMethodBinding(this.actionListener, new Class[] { ActionEvent.class }); ((ActionSource) component).setActionListener(mb); } else { throw new IllegalArgumentException("Component " + component.getClientId(getFacesContext()) + " has invalid actionListener value: " + actionListener); } } } /** * Sets the boolean immediate property on the associated UIComponent * component. * * @param component * The associated UIComponent */ protected void setImmediateProperty(final UIComponent component) { setBooleanProperty(component, "immediate", this.immediate); } /** * Returns the action value. * * @return The action value */ public final String getAction() { return action; } /** * Sets the action attribute. * * @param action * The action value. */ public final void setAction(final String action) { this.action = action; } /** * Returns the actionListener value. * * @return The actionListener value */ public final String getActionListener() { return actionListener; } /** * Sets the actionListener attribute. * * @param actionListener * The actionListener value. */ public final void setActionListener(final String actionListener) { this.actionListener = actionListener; } /** * Returns the immediate value. * * @return The immediate value */ public final String getImmediate() { return immediate; } /** * Sets the immediate attribute. * * @param immediate * The immediate value. */ public final void setImmediate(final String immediate) { this.immediate = immediate; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -