001 // ---------- Attention: Generated code, please do not modify! ----------- 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 package org.apache.myfaces.tobago.component; 021 022 import javax.faces.context.FacesContext; 023 import org.apache.commons.lang.ArrayUtils; 024 import org.apache.commons.lang.StringUtils; 025 import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression; 026 import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding; 027 import org.apache.myfaces.tobago.internal.util.Deprecation; 028 import org.apache.myfaces.tobago.renderkit.MarginValues; 029 import org.apache.myfaces.tobago.renderkit.SpacingValues; 030 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer; 031 import javax.el.ELException; 032 import javax.faces.FacesException; 033 import java.util.ArrayList; 034 import java.util.List; 035 import javax.el.MethodExpression; 036 import javax.el.ValueExpression; 037 038 /** 039 Renders a menu item. 040 * UIComponent class, generated from template {@code component1.2.stg} with class 041 * {@link org.apache.myfaces.tobago.internal.taglib.component.MenuCommandTagDeclaration}. 042 */ 043 public class UIMenuCommand 044 extends UICommand { 045 046 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.MenuCommand"; 047 048 private java.lang.Character accessKey; 049 private java.lang.String labelWithAccessKey; 050 private java.lang.String image; 051 private java.lang.String label; 052 053 054 /** 055 Deprecated! Has not longer any function. 056 057 @deprecated*/ 058 @Deprecated 059 public java.lang.Character getAccessKey() { 060 if (accessKey != null) { 061 return accessKey; 062 } 063 ValueExpression ve = getValueExpression("accessKey"); 064 if (ve != null) { 065 try { 066 return (java.lang.Character) ve.getValue(getFacesContext().getELContext()); 067 } catch (ELException e) { 068 throw new FacesException(e); 069 } 070 } 071 return null; 072 } 073 074 @Deprecated 075 public void setAccessKey(java.lang.Character accessKey) { 076 this.accessKey = accessKey; 077 } 078 079 /** 080 Deprecated! Use 'label' instead. 081 Text value to display as label. 082 If text contains an underscore the next character overwrites 'accesskey'. 083 084 @deprecated*/ 085 @Deprecated 086 public java.lang.String getLabelWithAccessKey() { 087 if (labelWithAccessKey != null) { 088 return labelWithAccessKey; 089 } 090 ValueExpression ve = getValueExpression("labelWithAccessKey"); 091 if (ve != null) { 092 try { 093 return (java.lang.String) ve.getValue(getFacesContext().getELContext()); 094 } catch (ELException e) { 095 throw new FacesException(e); 096 } 097 } 098 return null; 099 } 100 101 @Deprecated 102 public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) { 103 this.labelWithAccessKey = labelWithAccessKey; 104 } 105 106 /** 107 Url to an image to display. 108 109 */ 110 public java.lang.String getImage() { 111 if (image != null) { 112 return image; 113 } 114 ValueExpression ve = getValueExpression("image"); 115 if (ve != null) { 116 try { 117 return (java.lang.String) ve.getValue(getFacesContext().getELContext()); 118 } catch (ELException e) { 119 throw new FacesException(e); 120 } 121 } 122 return null; 123 } 124 125 public void setImage(java.lang.String image) { 126 this.image = image; 127 } 128 129 /** 130 Text value to display as label. 131 If text contains an underscore the next character is used as accesskey. 132 133 */ 134 public java.lang.String getLabel() { 135 if (label != null) { 136 return label; 137 } 138 ValueExpression ve = getValueExpression("label"); 139 if (ve != null) { 140 try { 141 return (java.lang.String) ve.getValue(getFacesContext().getELContext()); 142 } catch (ELException e) { 143 throw new FacesException(e); 144 } 145 } 146 return null; 147 } 148 149 public void setLabel(java.lang.String label) { 150 this.label = label; 151 } 152 153 public void restoreState(FacesContext context, Object componentState) { 154 Object[] values = (Object[]) componentState; 155 super.restoreState(context, values[0]); 156 accessKey = (java.lang.Character) values[1]; 157 labelWithAccessKey = (java.lang.String) values[2]; 158 image = (java.lang.String) values[3]; 159 label = (java.lang.String) values[4]; 160 } 161 162 public Object saveState(FacesContext context) { 163 Object[] values = new Object[5]; 164 values[0] = super.saveState(context); 165 values[1] = accessKey; 166 values[2] = labelWithAccessKey; 167 values[3] = image; 168 values[4] = label; 169 return values; 170 } 171 172 173 }