/*
* xulfaces : bring XUL power to Java
*
* Copyright (C) 2005 Olivier SCHMITT
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.xulfaces.tag;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.xulfaces.annotation.taglib.ATTRIBUTE;
import org.xulfaces.annotation.taglib.TAG;
/**
*
* @author kito31
* @version $Id: CommandTag.java,v 1.16 2007/07/17 20:26:43 kito31 Exp $
*/
@TAG(name = "command", description = "Defines a command (see XUL command element).")
public class CommandTag extends XULComponentTag {
@ATTRIBUTE(description = "The label inherited by the menu items and keys that are attached to the command.")
private String label;
@ATTRIBUTE(description = "Action to do when the command is triggered.")
private String action;
@ATTRIBUTE(mappedType = "java.lang.Boolean", description = "If true the AJAX request is asynchronous, false otherwise.")
private String asynchronous;
@ATTRIBUTE(mappedType = "java.lang.String", description = "Set action listener.")
private String actionListener;
@ATTRIBUTE(mappedType = "java.lang.Boolean", description = "Don't wait for Invoke application phase.")
private String immediate;
@Override
public String getComponentType() {
return "xul.component.Command";
}
@Override
public String getRendererType() {
return "xul.renderer.Command";
}
public String getAction() {
return action;
}
public void setAction(String oncommand) {
this.action = oncommand;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAsynchronous() {
return asynchronous;
}
public void setAsynchronous(String asynchronous) {
this.asynchronous = asynchronous;
}
public String getActionListener() {
return actionListener;
}
public void setActionListener(String actionListener) {
this.actionListener = actionListener;
}
public String getImmediate() {
return immediate;
}
public void setImmediate(String immediate) {
this.immediate = immediate;
}
protected void setProperties(UIComponent component) {
super.setProperties(component);
FacesContext facesContext = getFacesContext();
setActionListenerProperty(facesContext, component, getActionListener());
setActionProperty(getFacesContext(), component, getAction());
setBooleanAttribute(facesContext, component, "immediate", immediate);
setBooleanAttribute(facesContext, component, "asynchronous",
asynchronous);
setStringAttribute(facesContext, component, "label", label);
}
}