In order to
write and configure a TagHandlerDelegate, you have to accomplish three steps:
·
extract the TagHandlerDelegate and
override its methods
public class
CustomTagHandlerDelegate extends TagHandlerDelegate {
private TagHandlerDelegate tagHandlerDelegate;
public CustomTagHandlerDelegate() {
}
public
CustomTagHandlerDelegate(TagHandlerDelegate tagHandlerDelegate) {
this.tagHandlerDelegate = tagHandlerDelegate;
}
@Override
public MetaRuleset createMetaRuleset(Class
type) {
return
tagHandlerDelegate.createMetaRuleset(type);
}
@Override
public void apply(FaceletContext ctx,
UIComponent comp) throws IOException {
tagHandlerDelegate.apply(ctx, comp);
}
}
·
Extend the TagHandlerDelegateFactory
and point your TagHandlerDelegate
public class
CustomTagHandlerDelegateFactory extends TagHandlerDelegateFactory {
private TagHandlerDelegateFactory
tagHandlerDelegateFactory;
public CustomTagHandlerDelegateFactory() {
}
public
CustomTagHandlerDelegateFactory(TagHandlerDelegateFactory
tagHandlerDelegateFactory) {
this.tagHandlerDelegateFactory =
tagHandlerDelegateFactory;
}
@Override
public TagHandlerDelegate
createComponentHandlerDelegate(ComponentHandler owner) {
return new
CustomTagHandlerDelegate(tagHandlerDelegateFactory.createComponentHandlerDelegate(owner));
}
@Override
public TagHandlerDelegate
createValidatorHandlerDelegate(ValidatorHandler owner) {
return tagHandlerDelegateFactory.createValidatorHandlerDelegate(owner);
}
@Override
public TagHandlerDelegate
createConverterHandlerDelegate(ConverterHandler owner) {
return
tagHandlerDelegateFactory.createConverterHandlerDelegate(owner);
}
@Override
public TagHandlerDelegate
createBehaviorHandlerDelegate(BehaviorHandler owner) {
return
tagHandlerDelegateFactory.createBehaviorHandlerDelegate(owner);
}
}
·
configure the your custom TagHandlerDelegateFactory
in
faces-config.xml
<factory>
<tag-handler-delegate-factory>
your_custom_taghandlerdelegatefactory_package.CustomTagHandlerDelegateFactory
</tag-handler-delegate-factory>
</factory>
Now, most
probably, you will go in the apply() method and "play" with the
component tree, during its construction.
Niciun comentariu :
Trimiteți un comentariu