Ravi Kadaboina
Ravi Kadaboina

Reputation: 8574

How to update id generated from a backing bean

<p:outputPanel>
    <h:selectOneRadio value="#{myBean.favColor1}">
  <f:selectItem itemValue="Red" itemLabel="Color1 - Red" />
  <f:selectItem itemValue="Green" itemLabel="Color1 - Green" />
  <f:selectItem itemValue="Blue" itemLabel="Color1 - Blue" />
    </h:selectOneRadio>
    <p:ajax update="picker,#{myBean.clientId}"/>
</p:outputPanel>

I need to update a component whose id is generated programmatically.

Upvotes: 1

Views: 698

Answers (1)

BalusC
BalusC

Reputation: 1108632

The client ID should be prefixed with the default naming container separator character : so that it will be resolved absolute to the UIViewRoot instead of relative to the parent naming container (which will work for component IDs, but not for client IDs).

<p:ajax update="picker,:#{myBean.clientId}"/>

As a completely different alternative (I find binding the client ID to a backing bean pretty itchy), just bind the component to the view and reference it instead of through an intermediary managed bean.

<h:someComponent binding="#{foo}" />
...

<p:ajax update="picker,:#{foo.clientId}"/>

Upvotes: 2

Related Questions