[ 
https://issues.apache.org/jira/browse/MYFACES-4046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15290381#comment-15290381
 ] 

Leonardo Uribe commented on MYFACES-4046:
-----------------------------------------

After looking the code and think about it, I think the best way to do it is in 
this way:

{code:java}

            Map<String, Object> attributes = new HashMap<String, Object>();
            attributes.put("src", "/addSimpleIncludeVDL_2_1.xhtml");
            Map<String, Object> paramsMap = new HashMap<String, Object>();
            paramsMap.put("param1", "value1");
            paramsMap.put("param2", 
facesContext.getApplication().getExpressionFactory().createValueExpression(
                    facesContext.getELContext(), "#{testBean.param2}" 
,String.class));
            attributes.put("params", paramsMap);
            UIComponent component = vdl.createComponent(facesContext, 
                "http://java.sun.com/jsf/facelets";, 
                "include", attributes);

{code}

The idea is add a "virtual" parameter called "params" to ui:include, 
ui:decorate and ui:composition. I mean "virtual" because this phantom param is 
not on the facelet tag class, instead is read directly by the compiler only on 
vdl.createComponent(...) case. The reason is ui:param behavior is tightly bound 
to the parent tag, in a way that you can define ui:param without be aware of 
the parent.

> Allow programmatic component with ui:include with ui:param
> ----------------------------------------------------------
>
>                 Key: MYFACES-4046
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4046
>             Project: MyFaces Core
>          Issue Type: Improvement
>            Reporter: Leonardo Uribe
>            Priority: Minor
>
> Since 2.2 it is possible to call vdl.createComponent and pass an ui:include 
> in this way:
> {code:java}
>             Map<String, Object> attributes = new HashMap<String, Object>();
>             attributes.put("src", "/addSimpleIncludeVDL_1_1.xhtml");
>             UIComponent component = vdl.createComponent(facesContext, 
>                 "http://java.sun.com/jsf/facelets";, 
>                 "include", attributes);
> {code}
> It works but there is no way to pass parameters as described in:
> http://stackoverflow.com/questions/35178151/programmatically-include-xhtml-fragment-in-myfaces
> The question is how to pass ui:param components. Maybe use 
> vdl.createComponent and pass ui:param, but note ui:param does not have an 
> underlying component, because it is a facelet tag, but a standard notation 
> for this case could be useful.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to