Class XsltTransformerBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.markup.transformer.AbstractTransformerBehavior
-
- org.apache.wicket.markup.transformer.XsltTransformerBehavior
-
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IComponentAwareHeaderContributor
,ITransformer
,IClusterable
public class XsltTransformerBehavior extends AbstractTransformerBehavior
An IBehavior which can be added to any component except ListView. It allows to post-process (XSLT) the markup generated by the component. The *.xsl resource must be located in the same path as the nearest parent with an associated markup and must have a filename equal to the component's id.The containers tag will be the root element of the xml data applied for transformation to ensure the xml data are well formed (single root element). In addition the attribute
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd
is added to the root element to allow the XSL processor to handle the wicket namespace.The reason why the transformer can not be used to XSLT the ListViews output is because of the ListViews markup being reused for each ListItem. Please use a XsltOutputTransformerContainer instead. Note: if the ListView is used to print a list of <tr> tags, than the transformer container must enclose the <table> tag as well to be HTML compliant.
- Author:
- Juergen Donnerstag
- See Also:
AbstractOutputTransformerContainer
,XsltOutputTransformerContainer
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description XsltTransformerBehavior()
Construct.XsltTransformerBehavior(String xslFilePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(Component component)
Bind this handler to the given component.void
onComponentTag(Component component, ComponentTag tag)
Called any time a component that has this behavior registered is rendering the component tag.CharSequence
transform(Component component, CharSequence output)
Will be invoked after all child components have been processed to allow for transforming the markup generated.-
Methods inherited from class org.apache.wicket.markup.transformer.AbstractTransformerBehavior
afterRender, beforeRender, detach, newResponse
-
Methods inherited from class org.apache.wicket.behavior.Behavior
canCallListener, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag, renderHead, unbind
-
-
-
-
Constructor Detail
-
XsltTransformerBehavior
public XsltTransformerBehavior()
Construct.
-
XsltTransformerBehavior
public XsltTransformerBehavior(String xslFilePath)
- Parameters:
xslFilePath
-- See Also:
XsltTransformer(String)
-
-
Method Detail
-
onComponentTag
public void onComponentTag(Component component, ComponentTag tag)
Description copied from class:Behavior
Called any time a component that has this behavior registered is rendering the component tag.- Overrides:
onComponentTag
in classBehavior
- Parameters:
component
- the component that renders this tag currentlytag
- the tag that is rendered
-
transform
public CharSequence transform(Component component, CharSequence output) throws Exception
Description copied from interface:ITransformer
Will be invoked after all child components have been processed to allow for transforming the markup generated.- Specified by:
transform
in interfaceITransformer
- Specified by:
transform
in classAbstractTransformerBehavior
- Parameters:
component
- The associated Wicket componentoutput
- The markup generated by the child components- Returns:
- The output which will be appended to the original response
- Throws:
Exception
-
bind
public void bind(Component component)
Description copied from class:Behavior
Bind this handler to the given component. This method is called by the host component immediately after this behavior is added to it. This method is useful if you need to do initialization based on the component it is attached and you can't wait to do it at render time. Keep in mind that if you decide to keep a reference to the host component, it is not thread safe anymore, and should thus only be used in situations where you do not reuse the behavior for multiple components.
-
-