View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package javax.faces.component;
20  
21  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
22  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
23  
24  /**
25   * 
26   * @since 2.0
27   */
28  @JSFComponent
29  public class UIOutcomeTarget extends UIOutput
30  {
31      public static final String COMPONENT_TYPE = "javax.faces.OutcomeTarget";
32      public static final String COMPONENT_FAMILY = "javax.faces.OutcomeTarget";
33      
34      private static final boolean DEFAULT_INCLUDEVIEWPARAMS = false;
35      private static final boolean DEFAULT_DISABLE_CLIENT_WINDOW = false;
36      
37      public UIOutcomeTarget()
38      {
39          super();
40          setRendererType("javax.faces.Link");
41      }
42      
43      public String getFamily()
44      {
45          return COMPONENT_FAMILY;
46      }
47  
48      @JSFProperty
49      public String getOutcome()
50      {
51          String outcome = (String) getStateHelper().eval(PropertyKeys.outcome);
52          
53          if(outcome == null && isInView())  //default to the view id
54          {
55              return getFacesContext().getViewRoot().getViewId();
56          }
57          
58          return outcome;
59      }
60  
61      public void setOutcome(String outcome)
62      {
63          getStateHelper().put(PropertyKeys.outcome, outcome);
64      }
65  
66      @JSFProperty(defaultValue="false")
67      public boolean isIncludeViewParams()
68      {        
69          return (Boolean) getStateHelper().eval(PropertyKeys.includeViewParams, DEFAULT_INCLUDEVIEWPARAMS);
70      }
71  
72      public void setIncludeViewParams(boolean includeViewParams)
73      {
74          getStateHelper().put(PropertyKeys.includeViewParams, includeViewParams);
75      }
76  
77      /**
78       * @since 2.2
79       * @return 
80       */
81      @JSFProperty(defaultValue="false")
82      public boolean isDisableClientWindow()
83      {        
84          return (Boolean) getStateHelper().eval(PropertyKeys.disableClientWindow, DEFAULT_DISABLE_CLIENT_WINDOW);
85      }
86  
87      /**
88       * @since 2.2
89       * @param disableClientWindow 
90       */
91      public void setDisableClientWindow(boolean disableClientWindow)
92      {
93          getStateHelper().put(PropertyKeys.disableClientWindow, disableClientWindow);
94      }
95  
96      enum PropertyKeys
97      {
98          includeViewParams,
99          outcome,
100         disableClientWindow,
101     }
102 }