001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.component;
021
022 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_LINK;
023 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_ONCLICK;
024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMMEDIATE;
026 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_JSF_RESOURCE;
027 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_RESOURCE;
028 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TRANSITION;
029 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TYPE;
030 import org.apache.myfaces.tobago.component.ComponentUtil;
031 import org.apache.myfaces.tobago.component.UICommand;
032
033 import javax.faces.component.UIComponent;
034
035 public abstract class AbstractCommandTag extends TobagoTag implements AbstractCommandTagDeclaration {
036
037 private String disabled;
038 private String action;
039 private String actionListener;
040 private String type;
041 private String immediate;
042 private String onclick;
043 private String link;
044 private String resource;
045 private String jsfResource;
046 private String transition;
047
048 public String getComponentType() {
049 return UICommand.COMPONENT_TYPE;
050 }
051
052 protected void setProperties(UIComponent component) {
053 super.setProperties(component);
054 UICommand command = (UICommand) component;
055 ComponentUtil.setBooleanProperty(component, ATTR_DISABLED, disabled);
056 ComponentUtil.setStringProperty(component, ATTR_TYPE, type);
057 // ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
058 ComponentUtil.setBooleanProperty(component, ATTR_IMMEDIATE, immediate);
059 if (component instanceof UICommand) {
060 ComponentUtil.setAction((UICommand) component, type, action);
061 }
062 ComponentUtil.setStringProperty(component, ATTR_ACTION_LINK, link);
063 ComponentUtil.setStringProperty(component, ATTR_RESOURCE, resource);
064 ComponentUtil.setBooleanProperty(component, ATTR_JSF_RESOURCE, jsfResource);
065 ComponentUtil.setStringProperty(component, ATTR_ACTION_ONCLICK, onclick);
066 ComponentUtil.setActionListener(command, actionListener);
067 ComponentUtil.setBooleanProperty(component, ATTR_TRANSITION, transition);
068 }
069
070 public void release() {
071 super.release();
072 action = null;
073 actionListener = null;
074 type = null;
075 disabled = null;
076 immediate = null;
077 onclick = null;
078 link = null;
079 resource = null;
080 jsfResource = null;
081 transition = null;
082 }
083
084 public String getAction() {
085 return action;
086 }
087
088 public void setAction(String action) {
089 this.action = action;
090 }
091
092 public void setOnclick(String onclick) {
093 this.onclick = onclick;
094 }
095
096 public void setLink(String link) {
097 this.link = link;
098 }
099
100 public void setResource(String resource) {
101 this.resource = resource;
102 }
103
104 public void setJsfResource(String jsfResource) {
105 this.jsfResource = jsfResource;
106 }
107
108 public String getActionListener() {
109 return actionListener;
110 }
111
112 public void setActionListener(String actionListener) {
113 this.actionListener = actionListener;
114 }
115
116 public String getType() {
117 return type;
118 }
119
120 public void setType(String type) {
121 this.type = type;
122 }
123
124 public String getImmediate() {
125 return immediate;
126 }
127
128 public void setImmediate(String immediate) {
129 this.immediate = immediate;
130 }
131
132 public void setDisabled(String disabled) {
133 this.disabled = disabled;
134 }
135
136 public void setTransition(String transition) {
137 this.transition = transition;
138 }
139 }