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