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