Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.application;
 
 import java.net.URL;
 import java.util.Map;
 import java.util.List;

NavigationCase represents a <navigation-case> in the navigation rule base, as well as the <from-view-id> inside which this <navigation-case> is nested.

Since:
2.0
 
 public class NavigationCase {
 
     private final String fromViewId;
     private final String fromAction;
     private final String fromOutcome;
     private final String condition;
     private final String toViewId;
     private final Map<String,List<String>> parameters;
     private final boolean redirect;
     private final boolean includeViewParams;
 
     private ValueExpression toViewIdExpr;
     private ValueExpression conditionExpr;
     private String toString;
     private int hashCode;
 
 
     // ------------------------------------------------------------ Constructors
 

    

Construct a new NavigationCase based on the provided arguments. See section JSF.7.4.2 for how a NavigationCase is used by the standard ConfigurableNavigationHandler

Parameters:
fromViewId return from getFromViewId()
fromAction return from getFromAction()
fromOutcome return from getFromOutcome()
condition A string to be interpreted as a ValueExpression by a call to getCondition(javax.faces.context.FacesContext)
toViewId return from getToViewId(javax.faces.context.FacesContext)
parameters return from getParameters()
redirect return from isRedirect()
includeViewParams return isIncludeViewParams()
 
     public NavigationCase(String fromViewId,
                           String fromAction,
                           String fromOutcome,
                           String condition,
                          String toViewId,
                          Map<String,List<String>> parameters,
                          boolean redirect,
                          boolean includeViewParams) {
        this. = fromViewId;
        this. = fromAction;
        this. = fromOutcome;
        this. = condition;
        this. = toViewId;
        this. = parameters;
        this. = redirect;
        this. = includeViewParams;
    }
    // ---------------------------------------------------------- Public Methods


    

Construct an absolute URL to this NavigationCase instance using ViewHandler.getActionURL(javax.faces.context.FacesContext,java.lang.String) on the path portion of the url.

Parameters:
context the javax.faces.context.FacesContext for the current request
Throws:
java.net.MalformedURLException if the process of constructing the URL causes this exception to be thrown.
    public URL getActionURL(FacesContext contextthrows MalformedURLException {
        ExternalContext extContext = context.getExternalContext();
        return new URL(extContext.getRequestScheme(),
                extContext.getRequestServerName(),
                extContext.getRequestServerPort(),
                context.getApplication().getViewHandler().getActionURL(contextgetToViewId(context)));
        
    }


    

Construct an absolute URL to this NavigationCase instance using ViewHandler.getResourceURL(javax.faces.context.FacesContext,java.lang.String) on the path portion of the url.

Parameters:
context the javax.faces.context.FacesContext for the current request
Throws:
java.net.MalformedURLException if the process of constructing the URL causes this exception to be thrown.
    public URL getResourceURL(FacesContext contextthrows MalformedURLException {
        
        ExternalContext extContext = context.getExternalContext();
        return new URL(extContext.getRequestScheme(),
                extContext.getRequestServerName(),
                extContext.getRequestServerPort(),
                context.getApplication().getViewHandler().getResourceURL(contextgetToViewId(context)));
    }


    

Construct an absolute URL suitable for a "redirect" to this NavigationCase instance using ViewHandler.getRedirectURL(javax.faces.context.FacesContext,java.lang.String,java.util.Map,boolean) on the path portion of the url.

Parameters:
context the javax.faces.context.FacesContext for the current request
Throws:
java.net.MalformedURLException if the process of constructing the URL causes this exception to be thrown.
    public URL getRedirectURL(FacesContext contextthrows MalformedURLException {
        ExternalContext extContext = context.getExternalContext();
        return new URL(extContext.getRequestScheme(),
                extContext.getRequestServerName(),
                extContext.getRequestServerPort(),
                context.getApplication().getViewHandler().getRedirectURL(context,
                                                                         getToViewId(context),
                                                                         SharedUtils.evaluateExpressions(contextgetParameters()),
                                                                         isIncludeViewParams()));
    }


    

Construct an absolute URL suitable for a bookmarkable link to this NavigationCase instance using ViewHandler.getBookmarkableURL(javax.faces.context.FacesContext,java.lang.String,java.util.Map,boolean) on the path portion of the url. This URL may include view parameters specified as metadata within the view.

Parameters:
context the javax.faces.context.FacesContext for the current request
Throws:
java.net.MalformedURLException if the process of constructing the URL causes this exception to be thrown.
    public URL getBookmarkableURL(FacesContext contextthrows MalformedURLException {
        ExternalContext extContext = context.getExternalContext();
        return new URL(extContext.getRequestScheme(),
                extContext.getRequestServerName(),
                extContext.getRequestServerPort(),
                context.getApplication().getViewHandler().getBookmarkableURL(context,
                                                                             getToViewId(context),
                                                                             getParameters(),
                                                                             isIncludeViewParams()));
    }

    
    

Return the <from-view-id> of the <navigation-rule> inside which this <navigation-case> is nested.

    public String getFromViewId() {
        return ;
    }


    

Return the <from-action> for this <navigation-case>

    public String getFromAction() {
        return ;
    }


    

Return the <from-outcome> for this <navigation-case>

    public String getFromOutcome() {
        return ;
    }


    

Evaluates the <to-view-id> for this <navigation-case>

Parameters:
context the javax.faces.context.FacesContext for the current request
Returns:
the view ID that should be navigated to
    public String getToViewId(FacesContext context) {
        if ( == null) {
            ExpressionFactory factory =
                  context.getApplication().getExpressionFactory();
             = factory.createValueExpression(context.getELContext(),
                                                         ,
                                                         String.class);
        }
        String toViewId = (String.getValue(context.getELContext());
        if (toViewId.charAt(0) != '/') {
            toViewId = '/' + toViewId;
        }
        return toViewId;
    }


    

Test if this navigation case has an associated <if> element.

Returns:
true if there's an <if> element associated with this <navigation-case>, otherwise false
    public boolean hasCondition() {
        return ( != null);
    }


    

Evaluates the <if> for this <navigation-case>, if any. The expression to be evaluated is passed into the constructor as a string. When the expression is evaluated, its value must be coerced into a boolean per the normail EL coercion rules.

Parameters:
context the javax.faces.context.FacesContext for the current request
Returns:
null if there is no <if> element associated with this <navigation-case>, otherwise return the evaluation result of the condition
Throws:
any exceptions encountered during the process of evaluating the expression or obtaining its value.
    public Boolean getCondition(FacesContext context) {
        if ( == null &&  != null) {
            ExpressionFactory factory =
                  context.getApplication().getExpressionFactory();
             = factory.createValueExpression(context.getELContext(),
                                                          ,
                                                          Boolean.class);
        }
        return (( != null)
                ? (Boolean.getValue(context.getELContext())
                : null);
    }


    

Return the parameters to be included for navigation cases requiring a redirect. If no parameters are defined, null will be returned. The keys in the Map are parameter names. For each key, the corresponding value is a List of unconverted values.

    public Map<StringList<String>> getParameters() {
        return ;
    }


    

Return the <redirect> value for this <navigation-case>. This will be true if the new view should be navigated to via a javax.faces.context.ExternalContext.redirect(java.lang.String)

    public boolean isRedirect() {
        return ;
    }


    

Return the <redirect> value for this <navigation-case>. This will be true if the view parametets should be encoded into the redirect URL (only applies to redirect case)

    public boolean isIncludeViewParams() {
        return ;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        NavigationCase that = (NavigationCaseo;
        return ( == that.redirect
               && !( != null
                    ? !.equals(that.fromAction)
                    : that.fromAction != null)
               && !( != null
                    ? !.equals(that.fromOutcome)
                    : that.fromOutcome != null)
               && !( != null
                    ? !.equals(that.condition)
                    : that.condition != null)
               && !( != null
                    ? !.equals(that.fromViewId)
                    : that.fromViewId != null)
               && !( != null
                    ? !.equals(that.toViewId)
                    : that.toViewId != null)
               && !( != null
                    ? !.equals(that.parameters)
                    : that.parameters != null));
    }
    
    @Override
    public int hashCode() {
        if ( == 0) {
            int result =  != null ? .hashCode() : 0;
            result = 31 * result + ( != null
                                    ? .hashCode()
                                    : 0);
            result = 31 * result + ( != null
                                    ? .hashCode()
                                    : 0);
            result = 31 * result + ( != null
                                    ? .hashCode()
                                    : 0);
            result = 31 * result + ( != null ? .hashCode() : 0);
            result = 31 * result + ( ? 1 : 0);
            result = 31 * result + ( != null ? .hashCode() : 0);
             = result;
        }
        return ;
    }
    @Override
    public String toString() {
        if ( == null) {
            StringBuilder sb = new StringBuilder(64);
            sb.append("NavigationCase{");
            sb.append("fromViewId='").append().append('\'');
            sb.append(", fromAction='").append().append('\'');
            sb.append(", fromOutcome='").append().append('\'');
            sb.append(", if='").append().append('\'');
            sb.append(", toViewId='").append().append('\'');
            sb.append(", faces-redirect=").append();
            sb.append(", includeViewParams=").append().append('\'');
            sb.append(", parameters=").append((( != null) ? .toString() : ""));
            sb.append('}');
             = sb.toString();
        }
        return ;
    }
 
New to GrepCode? Check out our FAQ X