All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.faces.context.PartialViewContext Maven / Gradle / Ivy

There is a newer version: 11.0.0-M4
Show newest version
/*
 * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package jakarta.faces.context;

import java.util.Collection;
import java.util.List;

import jakarta.faces.application.ResourceHandler;
import jakarta.faces.application.StateManager;
import jakarta.faces.component.UIComponent;
import jakarta.faces.component.UINamingContainer;
import jakarta.faces.component.UIViewRoot;
import jakarta.faces.event.PhaseId;

/**
 * 

* PartialViewContext contains * methods and properties that pertain to partial request processing and partial response rendering on a view. *

* *

* The {@link PartialViewContext} instance is used to determine if the current request indicates the requirement to * perform partial processing and/or partial rendering. Partial processing is the processing * of selected components through the execute portion of the request processing lifecycle. Partial * rendering is the rendering of specified components in the Render Response Phase of the request * processing lifecycle. *

* */ public abstract class PartialViewContext { /** *

* The request parameter name whose request parameter value identifies the type of partial event. *

* * @since 2.3 */ public static final String PARTIAL_EVENT_PARAM_NAME = "jakarta.faces.partial.event"; /** *

* The request parameter name whose request parameter value is a Collection of client identifiers * identifying the components that must be processed during the Render Response phase of the request processing * lifecycle. *

* * @since 2.0 */ public static final String PARTIAL_RENDER_PARAM_NAME = "jakarta.faces.partial.render"; /** *

* The request parameter name whose request parameter value is a Collection of client identifiers * identifying the components that must be processed during the Apply Request Values, Process * Validations, and Update Model Values phases of the request processing lifecycle. *

* * @since 2.0 */ public static final String PARTIAL_EXECUTE_PARAM_NAME = "jakarta.faces.partial.execute"; /** *

* If the request parameter named by the value of this constant has a parameter value of true, the * implementation must return true from {@link #isResetValues}. *

* * @since 2.2 */ public static final String RESET_VALUES_PARAM_NAME = "jakarta.faces.partial.resetValues"; /** *

* The value that when used with {@link #PARTIAL_EXECUTE_PARAM_NAME} or {@link #PARTIAL_RENDER_PARAM_NAME} indicates * these phases must be skipped. *

* * @since 2.0 */ public static final String ALL_PARTIAL_PHASE_CLIENT_IDS = "@all"; // -------------------------------------------------------------- Properties /** *

* Return a Collection of client identifiers from the current request with the request parameter name * {@link #PARTIAL_EXECUTE_PARAM_NAME}. If there is no such request parameter, return an empty Collection. * These client identifiers are used to identify components that will be processed during the execute phase * of the request processing lifecycle. The returned Collection is mutable. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return the ids for the execute portion of the lifecycle */ public abstract Collection getExecuteIds(); /** *

* Return a Collection of client identifiers from the current request with the request parameter name * {@link #PARTIAL_RENDER_PARAM_NAME}. If there is no such request parameter, return an empty Collection. * These client identifiers are used to identify components that will be processed during the render phase * of the request processing lifecycle. The returned Collection is mutable. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return the ids for the render portion of the lifecycle */ public abstract Collection getRenderIds(); /** *

* Returns a mutable List of scripts to be evaluated in client side on complete of ajax request. *

* * @return A mutable List of scripts to be evaluated in client side on complete of ajax request. * @throws IllegalStateException If this method is called after this instance has been released. * @since 2.3 */ public abstract List getEvalScripts(); /** *

* Return the {@link ResponseWriter} to which components should direct their output for partial view rendering. Within a * given response, components can use either the ResponseStream or the ResponseWriter, but not both. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return the {@code ResponseWriter} for output */ public abstract PartialResponseWriter getPartialResponseWriter(); /** *

* Return true if the request header Faces-Request is present with the value * partial/ajax. Otherwise, return false. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return whether or not this is an ajax request */ public abstract boolean isAjaxRequest(); /** *

* Return true {@link #isAjaxRequest} returns true or if the request header * Faces-Request is present with the value partial/process. Otherwise, return * false. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return whether or not this request is partial */ public abstract boolean isPartialRequest(); /** *

* Return true if {@link #isAjaxRequest} returns true and {@link #PARTIAL_EXECUTE_PARAM_NAME} * is present in the current request with the value {@link #ALL_PARTIAL_PHASE_CLIENT_IDS}. Otherwise, return * false. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return whether or not this is an execute all request */ public abstract boolean isExecuteAll(); /** *

* Return true if {@link #isAjaxRequest} returns true and {@link #PARTIAL_RENDER_PARAM_NAME} * is present in the current request with the value {@link #ALL_PARTIAL_PHASE_CLIENT_IDS}. Otherwise, return * false. *

* * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 * * @return whether or not this is a render all request */ public abstract boolean isRenderAll(); /** *

* Return true if the incoming request has a parameter named by the value of * {@link #RESET_VALUES_PARAM_NAME} and that value is true. To preserve backward compatibility with custom * implementations that may have extended from an earlier version of this class, an implementation is provided that * returns false. A compliant implementation must override this method to take the specified action. *

* * @since 2.2 * * @return whether or not this is a reset values request */ public boolean isResetValues() { return false; } /** *

* Indicate the entire view must be rendered if renderAll is true. *

* * @param renderAll the value true indicates the entire view must be rendered. * * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 */ public abstract void setRenderAll(boolean renderAll); /** *

* Dynamically indicate that this is a partial request. *

* * @param isPartialRequest the value true indicates this is a partial request. * * @throws IllegalStateException if this method is called after this instance has been released * * @since 2.0 */ public abstract void setPartialRequest(boolean isPartialRequest); /** *

* Release any resources associated with this PartialViewContext * instance. *

* * @throws IllegalStateException if this method is called after this instance has been released */ public abstract void release(); /** *

* Perform lifecycle processing on components during the indicated phaseId. Only those components with * identifiers existing in the Collection returned from {@link #getExecuteIds} and {@link #getRenderIds} * will be processed. *

* *
*

* When the indicated phaseId equals {@link PhaseId#RENDER_RESPONSE}, then perform the following tasks in * sequence: *

    *
  1. If {@link #isResetValues()} returns true, then call * {@link UIViewRoot#resetValues(FacesContext, Collection)}, passing {@link #getRenderIds()}.
  2. *
  3. If {@link #isRenderAll()} returns false, then render any component resource of {@link UIViewRoot} * whose {@link ResourceHandler#getRendererTypeForResourceName(String)} does not return null, and whose * {@link UIComponent#getChildCount()} is zero, and whose * {@link ResourceHandler#isResourceRendered(FacesContext, String, String)} returns false, in an * update element with an identifier of jakarta.faces.Resource.
  4. *
  5. Process the components.
  6. *
  7. Obtain the state by calling {@link StateManager#getViewState} and write it out as an update element * with an identifier of <VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>jakarta.faces.ViewState where * <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return from * {@link UIViewRoot#getContainerClientId(FacesContext)} on the view from whence this state originated, and * <SEP> is the currently configured {@link UINamingContainer#getSeparatorChar(FacesContext)}.
  8. *
  9. If {@link #isRenderAll()} returns false, then write out each script of {@link #getEvalScripts()} as * an eval element.
  10. *
*
* * @param phaseId the {@link jakarta.faces.event.PhaseId} that indicates the lifecycle phase the components will be * processed in. */ public abstract void processPartial(PhaseId phaseId); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy