Hi Ken & the dev team,
We've been looking into our general problem (
http://forum.java.sun.com/thread.jspa?threadID=5299960&messageID=10271569#10271569 <
http://forum.java.sun.com/thread.jspa?threadID=5299960&messageID=10271569#10271569> ) a bit more and have come to realize that what is put in the XHTML file (tags and such) is essentially immutable, meaning for us that we cannot create <jsp:include..> tags where we want and move them to the correct location in the UIView tree at runtime. As we also can't create a <jsp:include..> tag programmatically in the backing bean, jsfTemplating is becoming a serious consideration for our group. We appreciate your help thus far and are eager to see if jsfTemplating can do what seems undoable.
We went through our test application and simplified it a little:
* dummy.jsf now consists of a single line: <sun:hyperlink text="TEST!" />
* We played around with "LayoutDefinition def = .." a little more and it looks like we are finding the file correctly.
* "def" is not null.
* The prerender method is being called and the code to include dummy.jsf is being executed.
* The main page was simplified slightly and we are ensuring that the destination component is an instance of UIComponent.
Do you feel the environment may be the problem; was jsfTemplating not intended to work in VisualWeb JSF?
Is there any documentation for programmatically emulating an 'include' in this fashion?
Thanks a lot,
Sean Connolly
________________________________
From: Ken.Paulsen_at_Sun.COM [mailto:Ken.Paulsen_at_Sun.COM]
Sent: Wednesday, May 28, 2008 2:00 PM
To: Connolly, Sean {InSi~Palo Alto}
Cc: jsftemplating
Subject: Re: jsfTemplating: dynamically including page fragments
Hi Sean,
I haven't tried using this exactly as you described (in the visual web environment), but it might work. I'll try an example later today when I have time. A couple quick comments before I run to an appointment.
* In dummy.jsf, it does not need to be a complete page... you can simply include the <sun:hyperlink .../> if you want.
* Make sure "def" in your example is not (null), if it is, then it didn't find your dummy.jsf page. Make sure you give it a path relative to the context root of your application (or it may exist in a .jar file in your web-inf/lib directory if you want).
* Make sure your prerender method is called.
* Ensure markup1 is a valid non-null UIComponent.
Feel free to cc the JSFTemplating "dev" alias. More people will see this and might be able to help. I cc'd the alias in this response.
Ken
Connolly, Sean wrote:
Hi Ken,
You recently commented on a thread I started in the JSF Sun Forums:
http://forum.java.sun.com/thread.jspa?messageID=10271569&
I appreciate your suggestion and have actually already looked into jsfTemplating a little bit. I must admit I was a little overwhelmed by it in general and do not feel I really grasp the code snippet you suggested. You said I "just need the parent UIComponent and the viewId of the content to add." Is the parent UIComponent the component I want to include the other page's content in (such as a UIDiv component) or would it refer to a component in the other page that I want to 'grab'? Also, I don't see where the viewID comes into play or what its role would be; should I get an instance of UIViewRoot and get its ID?
Playing dumb I threw together a quick 'dummy.jsf' page:
<sun:page>
<sun:html>
<sun:head id="head" />
<sun:body>
<sun:form id="form">
<sun:hyperlink text="hello world" />
</sun:form>
</sun:body>
</sun:html>
</sun:page>
And then made a VisualWeb JSF page (The platform I am working in) and added the following code to the prerender() phase:
FacesContext facesContext = getFacesContext().getCurrentInstance();
LayoutDefinition def = LayoutDefinitionManager.getLayoutDefinition(facesContext, "dummy.jsf");
LayoutViewHandler.buildUIComponentTree(facesContext, markup1, def);
Where markup1 refers to the UIComponent:
<webuijsf:markup binding="#{Page3.markup1}" id="markup1" tag="div"/>
This did nothing, and I'm sure my naïve code it a butchery of your work & suggestion. If you see what I am doing wrong I would much appreciate some direction.. perhaps I am thinking about this whole thing wrong. Also, if we were to get the above example to work such that the contents of dummy.jsf were included as children of markup1, would I then be able to port this concept to a include components from a page that uses VisualWeb JSF UIComponents (such as Woodstock's in NetBeans) or must the included components be LayoutElements?
Thank you for your time and I appreciate any assistance you may be able to offer,
Sean Connolly