This content has been marked as final.
Show 1 reply
-
1. Re: Adding a4j:param in an Handler doesn't work...
fmt Aug 1, 2011 10:42 AM (in response to fmt)Ok, JSF2 changed everything about Facelets TagHandlers, hence my code can't work as previously in JSF 1.2.
Here is a code that's working for the same behavior:
public class TrucHandler extends TagHandler { public TrucHandler(final TagConfig poConfig) { super(poConfig); } public void apply(final FaceletContext poCtx, final UIComponent poParent) { try { if (!ComponentHandler.isNew(poParent)) { return; } UICommandButton loLink = new UICommandButton(); loLink.setId("truclink"); loLink.setValue("Truc"); loLink.setRender("someId"); UIParameter loA4jParam = new UIParameter(); loA4jParam.setId("param"); loA4jParam.setValue("aValue"); loA4jParam.setValueExpression("assignTo", FacesUtil.getValueExpression("#{myBean.myProperty}", Object.class)); loLink.getChildren().add(loA4jParam); loLink.addActionListener(loA4jParam); poParent.getChildren().add(loLink); } catch (FacesException loE) { throw loE; } } }
The important idea is to define ids and to call the addActionListener which I found in the ParameterHandler class.
The ComponentHandler.isNew is needed too otherwise the component gets generated twice in the view...
It seems to work like this, the Event is created and treated by the processAction method.
If someone has a correction to add, please feel free. If somebody has a way of learning this kind of things without debugging JSF and Richfaces sources, I'd be glad to hear from him !
Florian