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_JSF_RESOURCE; 025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_RESOURCE; 026 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TRANSITION; 027 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TYPE; 028 import org.apache.myfaces.tobago.component.ComponentUtil; 029 import org.apache.myfaces.tobago.component.UICommand; 030 031 import javax.faces.component.UIComponent; 032 033 public abstract class AbstractCommandTag extends TobagoTag implements AbstractCommandTagDeclaration { 034 035 private String disabled; 036 private String action; 037 private String actionListener; 038 private String type; 039 private String immediate; 040 private String onclick; 041 private String link; 042 private String resource; 043 private String jsfResource; 044 private String transition; 045 046 public String getComponentType() { 047 return UICommand.COMPONENT_TYPE; 048 } 049 050 protected void setProperties(UIComponent component) { 051 super.setProperties(component); 052 UICommand command = (UICommand) component; 053 ComponentUtil.setBooleanProperty(component, ATTR_DISABLED, disabled); 054 ComponentUtil.setStringProperty(component, ATTR_TYPE, type); 055 // ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand); 056 ComponentUtil.setBooleanProperty(component, ATTR_IMMEDIATE, immediate); 057 if (component instanceof UICommand) { 058 ComponentUtil.setAction((UICommand) component, type, action); 059 } 060 ComponentUtil.setStringProperty(component, ATTR_ACTION_LINK, link); 061 ComponentUtil.setStringProperty(component, ATTR_RESOURCE, resource); 062 ComponentUtil.setBooleanProperty(component, ATTR_JSF_RESOURCE, jsfResource); 063 ComponentUtil.setStringProperty(component, ATTR_ACTION_ONCLICK, onclick); 064 ComponentUtil.setActionListener(command, actionListener); 065 ComponentUtil.setBooleanProperty(component, ATTR_TRANSITION, transition); 066 } 067 068 public void release() { 069 super.release(); 070 action = null; 071 actionListener = null; 072 type = null; 073 disabled = null; 074 immediate = null; 075 onclick = null; 076 link = null; 077 resource = null; 078 jsfResource = null; 079 transition = null; 080 } 081 082 public String getAction() { 083 return action; 084 } 085 086 public void setAction(String action) { 087 this.action = action; 088 } 089 090 public void setOnclick(String onclick) { 091 this.onclick = onclick; 092 } 093 094 public void setLink(String link) { 095 this.link = link; 096 } 097 098 public void setResource(String resource) { 099 this.resource = resource; 100 } 101 102 public void setJsfResource(String jsfResource) { 103 this.jsfResource = jsfResource; 104 } 105 106 public String getActionListener() { 107 return actionListener; 108 } 109 110 public void setActionListener(String actionListener) { 111 this.actionListener = actionListener; 112 } 113 114 public String getType() { 115 return type; 116 } 117 118 public void setType(String type) { 119 this.type = type; 120 } 121 122 public String getImmediate() { 123 return immediate; 124 } 125 126 public void setImmediate(String immediate) { 127 this.immediate = immediate; 128 } 129 130 public void setDisabled(String disabled) { 131 this.disabled = disabled; 132 } 133 134 public void setTransition(String transition) { 135 this.transition = transition; 136 } 137 }