-
1. Re: programmatically apply a template to UIDecorate?
pmuir May 10, 2007 4:46 PM (in response to ccrouch)Look at org.jboss.seam.ui.tag.DecorateHandler
-
2. Re: programmatically apply a template to UIDecorate?
ccrouch May 10, 2007 5:03 PM (in response to ccrouch)"petemuir" wrote:
Look at org.jboss.seam.ui.tag.DecorateHandler
Okay, what am I looking for? Pardon my JSF ignorance but I presume you are implying that what I was hoping to do is not possible?
Thanks -
3. Re: programmatically apply a template to UIDecorate?
pmuir May 10, 2007 5:43 PM (in response to ccrouch)Sorry, I meant, thats where the magic is happening... You would need to build a similar handler to do this programmatically. I did a similar thing for Christian for the wiki a while back. I did blog about the general ideas, rather than the impl:
http://pmuir.bleepbleep.org.uk/2007/04/building-plugin-system-in-facelets.html
So, it all depends on how you are adding the UIDecorate to the tree at the moment...
Post some code :p -
4. Re: programmatically apply a template to UIDecorate?
ccrouch May 10, 2007 7:22 PM (in response to ccrouch)"petemuir" wrote:
I did a similar thing for Christian for the wiki a while back.
Cool, Christian and I briefly spoke on this topic when he was doing the wiki stuff. I think we had approximately similar requirements.
Can you point me at the code you did?"petemuir" wrote:
So, it all depends on how you are adding the UIDecorate to the tree at the moment...
Post some code :p
So its pretty simple stuff right now. We're creating a HtmlPanelGrid then for each form element (textbox, textarea etc) we want to render we create a UIDecorateUIDecorate component = (UIDecorate) getApplication().createComponent(UIDecorate.COMPONENT_TYPE); component.setId(getUniqueId());
then add all the components relevant to that element as children of the UIDecoratedecorator.getChildren().add(getUnescapedOutputText("<br/>")); decorator.getChildren().add(getTextAreaInputWidget()); etc
Then add the decorator back into the gridpanelGrid.getChildren().add(decorator);
Finally we outject the panelGrid and display it in a facelets page.<h:panelGrid binding="#{dynamicPanelGridTest}" />
Hope this helps
Cheers -
5. Re: programmatically apply a template to UIDecorate?
christian.bauer May 11, 2007 12:29 AM (in response to ccrouch)Check examples/wiki/ and the source in the .ui package.
-
6. Re: programmatically apply a template to UIDecorate?
pmuir May 11, 2007 4:29 AM (in response to ccrouch)I would suggest not doing this via binding, but via a facelets component handler - it's harder to understand, but plays with the JSF lifecycle much better afaics. The work is done by faceletContext.includeFacelet("/path/to/facelet.xhtml") , but facelets is quite fragile as to how use this call (without components getting pruned from the tree).
-
7. Re: programmatically apply a template to UIDecorate?
ccrouch May 11, 2007 2:02 PM (in response to ccrouch)Ok, so let me just try and repeat back what I understand your sugestion to be:
Instead of using binding:
<h:panelGrid binding="#{dynamicPanelGridTest}" />
I would create my own tag handler, extending MetaTagHandler it looks like, and that in the page would go:
<myTag:renderForm formDefinition="#{myFormSchema}"/>
This tag handler implementation would then get the reference to the myFormSchema which lists what form elements should be included on the form. It would then iterate over this list calling ctx.includeFacelet(parent, faceletURL) appropriately for each form element, e.g. pseudo code...
ctx.includeFacelet(parent, /include/formTextComponent.xhtml);
ctx.includeFacelet(parent, /include/formRadioComponent.xhtml);
ctx.includeFacelet(parent, /include/formTextComponent.xhtml);
So how would I tell it each time I include a facelets page to use a different set of param's? e.g. duplicating this...<ui:include src="/include/formTextComponent.xhtml"> <ui:param name="label" value="#{label1}"/> <ui:param name="beanValue" value="#{value1}"/> </ui:include> <ui:include src="/include/formRadioComponent.xhtml"> <ui:param name="label" value="#{label2}"/> <ui:param name="beanValue" value="#{value2}"/> <ui:param name="itemValues" value="#{listValues}"/> </ui:include> <ui:include src="/include/formTextComponent.xhtml"> <ui:param name="label" value="#{label3}"/> <ui:param name="beanValue" value="#{value3}"/> </ui:include>
Thanks