001 package org.apache.myfaces.tobago.taglib.extension; 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 org.apache.myfaces.tobago.apt.annotation.Tag; 021 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag; 022 import org.apache.myfaces.tobago.taglib.component.MenuCommandTag; 023 import org.apache.myfaces.tobago.taglib.component.AbstractCommandTagDeclaration; 024 import org.apache.myfaces.tobago.taglib.component.SelectOneRadioTag; 025 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered; 026 import org.apache.myfaces.tobago.taglib.decl.HasLabel; 027 import org.apache.myfaces.tobago.taglib.decl.IsDisabled; 028 import org.apache.myfaces.tobago.taglib.decl.HasValue; 029 import org.apache.myfaces.tobago.taglib.decl.HasConverter; 030 031 import javax.faces.webapp.FacetTag; 032 import javax.servlet.jsp.JspException; 033 import javax.servlet.jsp.tagext.BodyTagSupport; 034 035 /* 036 * Date: 09.05.2006 037 * Time: 17:41:39 038 */ 039 040 /** 041 * Renders a submenu with select one items (like a radio button). 042 */ 043 044 @Tag(name = "menuRadio", tagExtraInfoClassName = "org.apache.myfaces.tobago.taglib.component.CommandTagExtraInfo") 045 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.MenuRadioTag") 046 public class MenuRadioExtensionTag extends BodyTagSupport implements AbstractCommandTagDeclaration, 047 HasIdBindingAndRendered, HasLabel, IsDisabled, HasValue, HasConverter { 048 049 private String rendered; 050 private String value; 051 052 private MenuCommandTag menuCommandTag; 053 private SelectOneRadioTag selectOneRadio; 054 private FacetTag facetTag; 055 private String action; 056 private String actionListener; 057 private String onclick; 058 private String link; 059 private String disabled; 060 private String binding; 061 private String label; 062 private String immediate; 063 private String transition; 064 private String converter; 065 066 @Override 067 public int doStartTag() throws JspException { 068 069 menuCommandTag = new MenuCommandTag(); 070 menuCommandTag.setPageContext(pageContext); 071 menuCommandTag.setParent(getParent()); 072 073 if (rendered != null) { 074 menuCommandTag.setRendered(rendered); 075 } 076 if (action != null) { 077 menuCommandTag.setAction(action); 078 } 079 if (actionListener != null) { 080 menuCommandTag.setActionListener(actionListener); 081 } 082 if (onclick != null) { 083 menuCommandTag.setOnclick(onclick); 084 } 085 if (link != null) { 086 menuCommandTag.setLink(link); 087 } 088 if (disabled != null) { 089 menuCommandTag.setDisabled(disabled); 090 } 091 if (binding != null) { 092 menuCommandTag.setBinding(binding); 093 } 094 if (label != null) { 095 menuCommandTag.setLabel(label); 096 } 097 if (immediate != null) { 098 menuCommandTag.setImmediate(immediate); 099 } 100 if (transition != null) { 101 menuCommandTag.setTransition(transition); 102 } 103 menuCommandTag.doStartTag(); 104 105 facetTag = new FacetTag(); 106 facetTag.setPageContext(pageContext); 107 facetTag.setParent(menuCommandTag); 108 facetTag.setName(org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS); 109 110 facetTag.doStartTag(); 111 selectOneRadio = new SelectOneRadioTag(); 112 selectOneRadio.setPageContext(pageContext); 113 selectOneRadio.setParent(facetTag); 114 if (converter != null) { 115 selectOneRadio.setConverter(converter); 116 } 117 if (value != null) { 118 selectOneRadio.setValue(value); 119 } 120 selectOneRadio.doStartTag(); 121 122 return super.doStartTag(); 123 } 124 125 @Override 126 public int doEndTag() throws JspException { 127 selectOneRadio.doEndTag(); 128 facetTag.doEndTag(); 129 menuCommandTag.doEndTag(); 130 131 return super.doEndTag(); 132 } 133 134 public void setAction(String action) { 135 this.action = action; 136 } 137 138 public void setActionListener(String actionListener) { 139 this.actionListener = actionListener; 140 } 141 142 public void setOnclick(String onclick) { 143 this.onclick = onclick; 144 } 145 146 public void setLink(String navigate) { 147 this.link = navigate; 148 } 149 150 public void setBinding(String binding) throws JspException { 151 this.binding = binding; 152 } 153 154 public void setRendered(String rendered) { 155 this.rendered = rendered; 156 } 157 158 public void setDisabled(String disabled) { 159 this.disabled = disabled; 160 } 161 162 public void setValue(String value) { 163 this.value = value; 164 } 165 166 public void setLabel(String label) { 167 this.label = label; 168 } 169 170 public void setImmediate(String immediate) { 171 this.immediate = immediate; 172 } 173 174 public void setTransition(String transition) { 175 this.transition = transition; 176 } 177 178 public void setConverter(String converter) { 179 this.converter = converter; 180 } 181 182 public void release() { 183 super.release(); 184 rendered = null; 185 value = null; 186 action = null; 187 actionListener = null; 188 onclick = null; 189 link = null; 190 disabled = null; 191 binding = null; 192 label = null; 193 immediate = null; 194 transition = null; 195 converter = null; 196 menuCommandTag = null; 197 facetTag = null; 198 selectOneRadio = null; 199 } 200 201 }