Package de.xima.fc.gui.listener
Class PartialRenderListener<T extends javax.faces.component.UIComponent>
java.lang.Object
de.xima.fc.gui.listener.PartialRenderListener<T>
- Type Parameters:
T- Type of the component for which the listener is registered.
- All Implemented Interfaces:
IClientIdProviding,IIdChainProviding,EventListener,javax.faces.event.FacesListener,javax.faces.event.SystemEventListener
- Direct Known Subclasses:
FlowchartRenderer.FlowchartPartialRenderListener
public abstract class PartialRenderListener<T extends javax.faces.component.UIComponent>
extends Object
implements javax.faces.event.SystemEventListener, IIdChainProviding, IClientIdProviding
Must be registered for a
PreRenderViewEvent.
Normally, during an AJAX request, a component is (re-)rendered by completely replacing a part of the DOM. This is
problematic in the case of dynamic interaction components and results in poor UI (flicking etc.). This handler hooks
into the PreRenderViewEvent, cancels the scheduled re-render and executes the appropriate JavaScript code
that updates the component without completely recreating it.
- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
Constructor Summary
ConstructorsConstructorDescriptionPartialRenderListener(javax.faces.context.FacesContext facesContext, T component) Creates a new partial renderer listener for the given component.PartialRenderListener(javax.faces.context.FacesContext facesContext, T component, boolean ignoreParentUpdates) Creates a new partial renderer listener for the given component. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidencodePartial(javax.faces.context.FacesContext context, T component) Performs the actions are necessary for the partial render of the component.String[]final booleanisListenerForSource(Object source) final voidprocessEvent(javax.faces.event.SystemEvent event) protected booleanshouldRenderPartially(javax.faces.context.FacesContext context, T component)
-
Constructor Details
-
PartialRenderListener
Creates a new partial renderer listener for the given component. This is usually called during thePostAddToViewEventof a component that wishes to use this listener.- Parameters:
facesContext- Current faces context.component- The component for which to register this listener.
-
PartialRenderListener
public PartialRenderListener(javax.faces.context.FacesContext facesContext, T component, boolean ignoreParentUpdates) Creates a new partial renderer listener for the given component. This is usually called during thePostAddToViewEventof a component that wishes to use this listener.- Parameters:
facesContext- Current faces context.component- The component for which to register this listener.ignoreParentUpdates- Iftrue, parent updates are removed.
-
-
Method Details
-
getClientId
- Specified by:
getClientIdin interfaceIClientIdProviding
-
getIdChain
- Specified by:
getIdChainin interfaceIIdChainProviding
-
getIdChainString
- Specified by:
getIdChainStringin interfaceIIdChainProviding
-
isListenerForSource
- Specified by:
isListenerForSourcein interfacejavax.faces.event.SystemEventListener
-
processEvent
public final void processEvent(javax.faces.event.SystemEvent event) throws javax.faces.event.AbortProcessingException - Specified by:
processEventin interfacejavax.faces.event.SystemEventListener- Throws:
javax.faces.event.AbortProcessingException
-
encodePartial
protected abstract void encodePartial(javax.faces.context.FacesContext context, T component) throws Exception Performs the actions are necessary for the partial render of the component. Usually this consists of scheduling JavaScript code to be executed on the client (viaPrimeFaces.executeInitScript(String).- Parameters:
context- The current faces context to use.component- The component for which this listener was registered.- Throws:
Exception- When the data could not be encoded.
-
shouldRenderPartially
- Parameters:
context- The current faces context.component- The component for which this listener was registered.- Returns:
trueif the component should render partially. The default implementation checks pre-requisites for a partial render to be possible without major issues. Subclasses are encouraged to call this super method, and unconditionally returnfalseif this method returned false.
-