|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase org.omnifaces.component.script.ScriptFamily org.omnifaces.component.script.OnloadScript
public class OnloadScript
OnloadScript is an extension to <h:outputScript>
which will be executed in the
end of the HTML body (thus when all HTML elements are initialized in the HTML DOM tree) and will re-execute its
script body on every ajax request. This is particularly useful if you want to re-execute a specific helper script
to manipulate the HTML DOM tree, such as (re-)adding fancy tooltips, performing highlights, etcetera, also after
changes in the HTML DOM tree on ajax responses.
You can put it anywhere in the view, it will always be relocated to the end of body.
<o:onloadScript>alert('OnloadScript is invoked!');</o:onloadScript>
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_TYPE
The standard component type. |
Fields inherited from class org.omnifaces.component.script.ScriptFamily |
---|
COMPONENT_FAMILY |
Fields inherited from class javax.faces.component.UIComponent |
---|
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY |
Constructor Summary | |
---|---|
OnloadScript()
|
Method Summary | |
---|---|
void |
encodeBegin(javax.faces.context.FacesContext context)
If this component is rendered and there are any children, then start the <script> element. |
void |
encodeEnd(javax.faces.context.FacesContext context)
If this component is rendered and there are any children, then end the <script> element. |
boolean |
isListenerForSource(java.lang.Object source)
Returns true if the given source is an instance of OnloadScript or UIViewRoot . |
void |
processEvent(javax.faces.event.ComponentSystemEvent event)
If the event is a PostAddToViewEvent , then relocate the component to end of body, so that we can make
sure that the script is executed after all HTML DOM elements are been created. |
void |
processEvent(javax.faces.event.SystemEvent event)
If the event is a PreRenderViewEvent and the current request is an ajax request and this component is
rendered and there are any children, then encode the children as Ajax.oncomplete(String...) . |
Methods inherited from class org.omnifaces.component.script.ScriptFamily |
---|
getFamily, getRendersChildren |
Methods inherited from class javax.faces.component.UIComponentBase |
---|
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding |
Methods inherited from class javax.faces.component.UIComponent |
---|
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTree |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_TYPE
Constructor Detail |
---|
public OnloadScript()
Method Detail |
---|
public boolean isListenerForSource(java.lang.Object source)
true
if the given source is an instance of OnloadScript
or UIViewRoot
.
isListenerForSource
in interface javax.faces.event.SystemEventListener
public void processEvent(javax.faces.event.ComponentSystemEvent event) throws javax.faces.event.AbortProcessingException
PostAddToViewEvent
, then relocate the component to end of body, so that we can make
sure that the script is executed after all HTML DOM elements are been created. Else if the event is a
PostRestoreStateEvent
and the current request is an ajax request, then subscribe to the
PreRenderViewEvent
event.
processEvent
in interface javax.faces.event.ComponentSystemEventListener
processEvent
in class javax.faces.component.UIComponent
javax.faces.event.AbortProcessingException
public void processEvent(javax.faces.event.SystemEvent event) throws javax.faces.event.AbortProcessingException
PreRenderViewEvent
and the current request is an ajax request and this component is
rendered and there are any children, then encode the children as Ajax.oncomplete(String...)
.
processEvent
in interface javax.faces.event.SystemEventListener
javax.faces.event.AbortProcessingException
public void encodeBegin(javax.faces.context.FacesContext context) throws java.io.IOException
<script>
element.
encodeBegin
in class javax.faces.component.UIComponentBase
java.io.IOException
public void encodeEnd(javax.faces.context.FacesContext context) throws java.io.IOException
<script>
element.
encodeEnd
in class javax.faces.component.UIComponentBase
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |