dev@jsftemplating.java.net

Re: jsfTemplating: dynamically including page fragments

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Wed, 28 May 2008 13:59:30 -0700

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&
> <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
>
>
>