Package org.apache.wicket.markup.head
Class OnEventHeaderItem
- java.lang.Object
-
- org.apache.wicket.markup.head.HeaderItem
-
- org.apache.wicket.markup.head.AbstractCspHeaderItem
-
- org.apache.wicket.markup.head.OnEventHeaderItem
-
- All Implemented Interfaces:
Serializable
,IClusterable
public class OnEventHeaderItem extends AbstractCspHeaderItem
HeaderItem
for event triggered scripts.- Author:
- papegaaij
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OnEventHeaderItem(String target, String event)
Constructor.OnEventHeaderItem(String target, String event, CharSequence javaScript)
Construct.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static OnEventHeaderItem
forComponent(Component target, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.static OnEventHeaderItem
forMarkupId(String id, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.static OnEventHeaderItem
forScript(String literalTarget, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.CharSequence
getCompleteJavaScript()
List<HeaderItem>
getDependencies()
String
getEvent()
CharSequence
getJavaScript()
Iterable<?>
getRenderTokens()
String
getTarget()
int
hashCode()
void
render(Response response)
Renders theHeaderItem
to the response.String
toString()
-
Methods inherited from class org.apache.wicket.markup.head.AbstractCspHeaderItem
getNonce, setNonce
-
Methods inherited from class org.apache.wicket.markup.head.HeaderItem
getProvidedResources
-
-
-
-
Constructor Detail
-
OnEventHeaderItem
public OnEventHeaderItem(String target, String event)
Constructor. The JavaScript should be provided by overloaded #getJavaScript- Parameters:
target
-event
-
-
OnEventHeaderItem
public OnEventHeaderItem(String target, String event, CharSequence javaScript)
Construct.- Parameters:
target
-event
-javaScript
-
-
-
Method Detail
-
forScript
public static OnEventHeaderItem forScript(String literalTarget, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.- Parameters:
literalTarget
- The target of the event handler, for example 'window' or 'document'. Note that this parameter is a literal and will be rendered unquoted.event
- The event itself, for example 'click'.javaScript
- The script to execute on the event.- Returns:
- A newly created
OnEventHeaderItem
. - See Also:
forComponent(Component, String, CharSequence)
,forMarkupId(String, String, CharSequence)
-
forComponent
public static OnEventHeaderItem forComponent(Component target, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.- Parameters:
target
- The target component of the event handler.event
- The event itself, for example 'click'.javaScript
- The script to execute on the event.- Returns:
- A newly created
OnEventHeaderItem
.
-
forMarkupId
public static OnEventHeaderItem forMarkupId(String id, String event, CharSequence javaScript)
Creates aOnEventHeaderItem
for the given parameters.- Parameters:
id
- The id of the component to bind the handler to.event
- The event itself, for example 'click'.javaScript
- The script to execute on the event.- Returns:
- A newly created
OnEventHeaderItem
.
-
getTarget
public String getTarget()
- Returns:
- The target of the event handler, for example 'window' or 'document'.
-
getJavaScript
public CharSequence getJavaScript()
- Returns:
- The script to execute on the event.
-
render
public void render(Response response)
Description copied from class:HeaderItem
Renders theHeaderItem
to the response.- Specified by:
render
in classHeaderItem
-
getCompleteJavaScript
public CharSequence getCompleteJavaScript()
- Returns:
- The JavaScript that registers the event handler.
-
getRenderTokens
public Iterable<?> getRenderTokens()
- Specified by:
getRenderTokens
in classHeaderItem
- Returns:
- The tokens this
HeaderItem
can be identified by. If any of the tokens has already been rendered, thisHeaderItem
will not be rendered.
-
getDependencies
public List<HeaderItem> getDependencies()
- Overrides:
getDependencies
in classHeaderItem
- Returns:
- The dependencies this
HeaderItem
has. Dependencies will always be rendered before the item itself.
-
-