Dynamic Loads and Attributes of Composite Java Components

I am currently trying to implement webpart technology with JavaServer Faces 2.0 with Facelets view technology for educational purposes. I created facelet templates, custom facelet components, and created several facelet "template" clients. But in one I am stuck. I cannot dynamically load controls and place them cc:attributes.

If I have a page, for example, with static text, or associate it with a ManagedBean, the property ui:includeall works well.

<ui:define name="right-column">
    right-column asd
    <h:link outcome="asdf" value="link_get">
        <f:param name="aa" value="123" />
        <f:param name="a" value="123 dd + 20" />
    </h:link>
    <h:commandLink action="asdf?faces-redirect=true" value="asdf">
        <f:param name="aa" value="123" />
    </h:commandLink><br />
    <ui:include src="./resources/Controls/CategoryTree.xhtml"/><br />
    This works even if I put src with MenageBean property.
    <ui:include src="#{browseProducts.incudePath}"/>
</ui:define>

Here is my uterine control (data binding is inside this control inside #{TreeBean.root}:

<!-- NO INTERFACE -->
<cc:interface>
</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>
<!--    This is a very simply scaffolding for Category Three Control.
    -->
    <p:tree value="#{TreeBean.root}" var="node"
            expandAnim="FADE_IN" collapseAnim="FADE_OUT">
        <p:treeNode>
            <h:outputText value="#{node}" />
        </p:treeNode>
    </p:tree>

</cc:implementation>

, ui:include cc:attribute. , bean "".

, :

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./resources/layout/Template.xhtml"
                xmlns:sc="http://java.sun.com/jsf/composite/Controls">

    <ui:define name="right-column">
        <sc:dummy ItemCount="10" />
        <ui:include src="./resources/Controls/dummy.xhtml" />
    </ui:define>
</ui:composition>

:

<cc:interface>
        <cc:attribute name="ItemCount" required="true"
                      shortDescription="This attribute is meaningful "  />
    </cc:interface>
    <!-- IMPLEMENTATION -->
    <cc:implementation>
    <!-- How to pass ItemCount to my dummy bean to create so many items in
    list as ItemCount value -->
        <ui:repeat value="#{dummy.dummyList}" var="dummyItem">
            <h:outputText value="#{dummyItem}" />
        </ui:repeat>
    </cc:implementation>

bean :

public ArrayList<String> getDummyList() {
    //Here I try to get dummy list work.
    dummyList = new ArrayList<String>(getDummyCount());
    for (int i=0;i< getDummyCount();i++){
        dummyList.add(i + "" + i);
    }
    return dummyList;
}

?

+3
1

, :

1., jsf 2, , ( ):

        <ui:repeat value="#{dummy.getDummyList(cc.attrs.dummyCode)}" var="dummyItem">
            <h:outputText value="#{dummyItem}" />
        </ui:repeat>

, -, . , java , . , , . bean -. , , .

2. ui: param. Google : http://www.jsfcentral.com/articles/facelets_3.html

0

Source: https://habr.com/ru/post/1788789/


All Articles