0

I know it is possible in MyFaces to programmatically add a xhtml fragment to the component tree, instead of using ui:include.

The snipplet I am talking about is as (in the original form):

ViewDeclarationLanguage vdl = facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(facesContext, facesContext.getViewRoot().getViewId());

Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("src", "/fragmentToInclude.xhtml");
UIComponent component = vdl.createComponent(facesContext, "http://java.sun.com/jsf/facelets", "include", attributes);


The problem I am facing is I am not able to pass in parameters, that would normally be passed in via <ui:param .../> tag.

What I tried, of course, was to add params into attributes map:

attributes.put("testingParam1", "Yeah, it worked!");

But this seems not to help. Content of my testing fragment is quite simple:

 <ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
     <div class="testingDiv">#{empty testingParam1 ? 'testingParam1 IS EMPTY' : testingParam1}</div>
 </ui:composition>

The fragment is properly loaded, but I only get that 'is empty' message.

I have walked through multiple resources but haven't found answer there:

Please, do you know, is this even possible? Or am I missing something? Thanks for any hints.

Community
  • 1
  • 1
jan b
  • 67
  • 1
  • 5
  • Did you try using `c:if` in xhtml page? If so why didn't it meet your needs? – Geinmachi Feb 03 '16 at 14:07
  • @Geinmachi well I'm talking about manipulation in java code, so that the component can be added dynamically, e.g. when an ajax action is triggered (in my case, its inside ActionListener registered in tag handler). – jan b Feb 03 '16 at 17:58
  • Created issue for this here [MYFACES-4046](https://issues.apache.org/jira/browse/MYFACES-4046). – lu4242 May 18 '16 at 21:55

0 Answers0