1 /* 2 * $Id: 3 */ 4 5 /* 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 7 * 8 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. 9 * 10 * The contents of this file are subject to the terms of either the GNU 11 * General Public License Version 2 only ("GPL") or the Common Development 12 * and Distribution License("CDDL") (collectively, the "License"). You 13 * may not use this file except in compliance with the License. You can obtain 14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html 15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific 16 * language governing permissions and limitations under the License. 17 * 18 * When distributing the software, include this License Header Notice in each 19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. 20 * Sun designates this particular file as subject to the "Classpath" exception 21 * as provided by Sun in the GPL Version 2 section of the License file that 22 * accompanied this code. If applicable, add the following below the License 23 * Header, with the fields enclosed by brackets [] replaced by your own 24 * identifying information: "Portions Copyrighted [year] 25 * [name of copyright owner]" 26 * 27 * Contributor(s): 28 * 29 * If you wish your version of this file to be governed by only the CDDL or 30 * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 * elects to include this software in this distribution under the [CDDL or GPL 32 * Version 2] license." If you don't indicate a single choice of license, a 33 * recipient has the option to distribute your version of this file under 34 * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 * its licensees as provided above. However, if you add GPL Version 2 code 36 * and therefore, elected the GPL Version 2 license, then the option applies 37 * only if the new code is made subject to such option by the copyright 38 * holder. 39 */ 40 41 package javax.faces.component; 42 43 import javax.el.ELException; 44 import javax.el.ValueExpression; 45 import javax.faces.FacesException; 46 import javax.faces.context.FacesContext; 47 48 49 /** 50 * <p class="changed_added_2_0">This component is paired with the 51 * <code>javax.faces.Button</code> or <code>javax.faces.Link</code> 52 * renderers and encapsulates properties relating to the rendering of 53 * outcomes directly to the response. This enables bookmarkability in 54 * JSF applications.</p> 55 * 56 * @since 2.0 57 */ 58 public class UIOutcomeTarget extends UIOutput { 59 60 61 // ------------------------------------------------------ Manifest Constants 62 63 64 /** 65 * <p>The standard component type for this component.</p> 66 */ 67 public static final String COMPONENT_TYPE = "javax.faces.OutcomeTarget"; 68 69 70 /** 71 * <p>The standard component family for this component.</p> 72 */ 73 public static final String COMPONENT_FAMILY = "javax.faces.OutcomeTarget"; 74 75 76 enum PropertyKeys { 77 includeViewParams, 78 outcome 79 } 80 81 82 // ------------------------------------------------------------ Constructors 83 84 85 /** 86 * <p>Create a new {@link UIOutcomeTarget} instance with default property 87 * values.</p> 88 */ 89 public UIOutcomeTarget() { 90 super(); 91 setRendererType("javax.faces.Link"); 92 93 } 94 95 96 // -------------------------------------------------------------- Properties 97 98 99 @Override 100 public String getFamily() { 101 return COMPONENT_FAMILY; 102 } 103 104 105 /** 106 * <p class="changed_added_2_0">Return whether or not the view 107 * parameters should be encoded into the target url.</p> 108 * 109 * @since 2.0 110 */ 111 public boolean isIncludeViewParams() { 112 113 return (Boolean) getStateHelper().eval(PropertyKeys.includeViewParams, false); 114 115 } 116 117 /** 118 * <p class="changed_added_2_0">Set whether or not the page 119 * parameters should be encoded into the target url.</p> 120 * 121 * @param includeViewParams The state of the switch for encoding 122 * page parameters 123 * 124 * @since 2.0 125 */ 126 public void setIncludeViewParams(boolean includeViewParams) { 127 128 getStateHelper().put(PropertyKeys.includeViewParams, includeViewParams); 129 130 } 131 132 133 /** 134 * <p class="changed_added_2_0">Returns the <code>outcome</code> 135 * property of the <code>UIOutcomeTarget</code>. This value is 136 * passed to the {@link javax.faces.application.NavigationHandler} 137 * when resolving the target url of this component.</p> 138 * 139 * @since 2.0 140 */ 141 public String getOutcome() { 142 143 return (String) getStateHelper().eval(PropertyKeys.outcome); 144 145 } 146 147 /** 148 * <p class="changed_added_2_0">Sets the <code>outcome</code> 149 * property of the <code>UIOutcomeTarget</code>. This value is 150 * passed to the NavigationHandler when resolving the target url of 151 * this component.</p> 152 * 153 * @since 2.0 154 * 155 * @param outcome the navigation outcome 156 */ 157 public void setOutcome(String outcome) { 158 159 getStateHelper().put(PropertyKeys.outcome, outcome); 160 161 } 162 163 164 }