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