1

I have a panelGroup with a binding

<h:panelGroup binding="#{myBean.content}"/>

The bean MyBean has a method getContent which returns an HtmlPanelGroup.

Now I would like to load the content of an xhtml-facelet into this HtmlPanelGroup object. Is this possible? Perhaps with a method like

return htmlPanelGroup.add(JSFUtils.load("my/div/content.xhtml"));
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Rokko_11
  • 837
  • 2
  • 10
  • 24

1 Answers1

0

This doesn't make sense. Just use <ui:include> to include Facelets.

<ui:include src="#{myBean.content}" />

return "/my/div/content.xhtml";

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • And how can I include two xhtml-facelets in this ui:include? Like return htmlPanelGroup.add(JSFUtils.load("my/div/content.xhtml").add(JSFUtils.load("my/div/another-content.xhtml")); – Rokko_11 Mar 24 '16 at 14:30
  • Just use `` on a `List` or `String[]`. Whatever you attempt, keep in mind there's **nothing** which is impossible in XHTML and only possible in Java. And, with XHTML you end up with so much more natural and readable/maintainable code. See also that first "See also" link. – BalusC Mar 24 '16 at 14:31
  • Thank you, but this is not exactly what I'm looking for, because there is a difference: In your solution the xhtml knows exactly that a list of xhtmls is getting rendered. In my example the xhtml does not know what happens to the content of the panelGroup - it only knows that the bean decides about the content. The bean for example could throw an event with the PanelGroup and some listener (of another module) can add his content and/or can modify existing content. That would be precious e.g. for building a modular system. – Rokko_11 Mar 24 '16 at 14:48
  • If there's only 1 item just wrap in one-item array/list. Try to think pragmatic. – BalusC Mar 24 '16 at 14:50
  • I would be very interested in whether there is a valid answer to this question. No work around! I generate a very complex, deeply nested UI programmatically. I wonder whether I can, at least, write the leafs (the innermost parts) as facelets, and then insert them in my dynamically created `UICompoment`. – ziggystar Aug 09 '18 at 13:01