How to implement NamingContainer? All children receive the same customer ID

I am trying to write my own tree component. The node tree appears as a div containing the child components of the tree component, for example:

<my:tree id="extendedTree"
         value="#{controller.rootNode}"
         var="node">
    <h:outputText id="xxx" value="#{node.name}" />
    <h:commandLink value="Test" actionListener="#{controller.nodeSelectionActionListener}" />
</my:tree>

So far, so good - everything works as expected, but h:outputTextgets the same identifier again.
So I had a component javax.faces.NamingControllerrewriting getContainerClientId():

@Override
public String getContainerClientId(FacesContext context) {
    String clientId = super.getClientId(context);
    String containerClientId = clientId + ":" + index;
    return containerClientId;
}

indexset and updated during iteration over nodes. But it getContainerClientId()is called only once for each child (not for each iteration and for each child, as one would expect). This forces each child identifier to have a prefix with the same container identifier:

form:treeid:0:xxx

The same goes for rewriting getClientId().

?

+4
2

3.1.6 JSF 1.2:

3.1.6

...

, , , setId(), getClientId().

, getClientId() JSF, UIComponentBase#getClientId() (. nullcheck 275, Mojarra 1.2_15) UIComponentBase#setId() (. 358, Mojarra 1.2_15). reset , getClientId().

, encodeChildren() , , , :

for (UIComponent child : getChildren()) {
    child.encodeAll(context);
}

UIComponent#setId() UIComponent#getId() reset :

for (UIComponent child : getChildren()) {
    child.setId(child.getId());
    child.encodeAll(context);
}

UIData <h:dataTable> , , (. 1382, Mojarra 1.2_15). , JSF 1.x, JSF 2.x( UIRepeat Facelets <ui:repeat>).

+5

h: outputText id , . :

 <h:outputText id="xxx_#{node.id}" value="#{node.name}" />

, node id, .

-1

All Articles