/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * $Header:$ */ package org.apache.beehive.netui.tags.html; import org.apache.beehive.netui.util.internal.InternalStringBuilder; import org.apache.beehive.netui.core.urls.URLRewriterService; import org.apache.beehive.netui.pageflow.PageFlowUtils; import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; import org.apache.beehive.netui.tags.HtmlUtils; import org.apache.beehive.netui.tags.IHtmlAccessable; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.rendering.*; import org.apache.beehive.netui.util.Bundle; import org.apache.beehive.netui.util.ParamHelper; import org.apache.beehive.netui.util.logging.Logger; import org.apache.struts.taglib.html.Constants; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspException; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; /** * Generates a button on the page with the specified attributes. The * <netui:button> tag must be enclosed in <netui:form...> ... * </netui:form> tags. You can specify the action that the form will * raise on the <netui:form> tag. * @jsptagref.tagdescription Renders an <input type="button"> tag with the specified attributes. * To submit data or invoke a method on the Controller file, the * <netui:button> tag must have a parent {@link Form} tag. * *

The action attribute on the <netui:button> is for the purpose * of overriding the action attribute on the enclosing <netui:form> tag. * If no action attribute is specified on the <netui:button> tag, * the action attribute on the <netui:form> tag will determine which * action method is invoked. *

* *

This tag can also render a <button> control to allow richer * rendering possibilities. When the renderAsButton * attribute is set to true, we render the markup with * an HTML <button> tag, using the value attribute, and placing * the evaluated body content as the content between the begin and * end HTML button tags. *

* *

Please note that using the action override and rendering the * markup with a <button> control will not work in Internet Explorer. * Internet Explorer includes the name and value of every <button> * control in the HTML form as parameters in the request query, * regardless of whether the button has been clicked or not. The * action override attribute renders a name attribute on the HTML tag. * This name is used to identified by the NetUI request processor to * determine if an action method other than the one on the * <netui:form> tag should be invoked. With IE, the name attribute * of the <button> control will always be included in the parameters * or the request query and NetUI will assume an action override button * was clicked, leading to incorrect behavior. *

* @example In this sample, the <netui:button> submits data to * the Controller file's processData action method (specified on the <netui:form>'s action * attribute). *
 *     <netui:form action="processData">
 *        <!--
 *        input elements here
 *        -->
 *        <netui:button value="Submit" type="submit"/>
 *     </netui:form>
* @netui:tag name="button" description="Create a button on your JSP page." */ public class Button extends HtmlFocusBaseTag implements IUrlParams, IHtmlAccessable, IHasPopupSupport { private static final Logger logger = Logger.getInstance(Button.class); public static final String ACTION_OVERRIDE = "actionOverride:"; private InputSubmitTag.State _state = new ButtonTag.State(); private String _action; // The action which will override the action on the form private String _value; // The text of the button (this will override any body text). private String _text; // The body content of this tag (if any). private Map _params; // Any parameters to the submit private String _targetScope; // Target page flow scope; see comments on setTargetScope() private PopupSupport _popupSupport = null; // popup support, if the popup attribute is set to true private boolean _disableSecondClick = false; // When clicked, this button will disable itself before submitting. private boolean _renderAsButton = false; // Write the HTML markup using the