1
<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.

Ravi Kadaboina
  • 8,494
  • 3
  • 30
  • 42

1 Answers1

2

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}"/>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you, Works fine separately but is breaking other autocomplete components. I need to figure that out. – Ravi Kadaboina Jan 19 '12 at 18:17
  • You're welcome. Yes, that's a completely different problem. Feel free to ask a new question if you stucks. – BalusC Jan 19 '12 at 18:18
  • BalusC, I have mixed two of your answers for this [question](http://stackoverflow.com/questions/8797287/is-conditional-rendering-of-components-possible-inside-datatable-without-updatin/8957536#8957536). Please post your thoughts on the solution. Thanks! – Ravi Kadaboina Jan 24 '12 at 17:42