0

Here is my code for the <h:selectOneMenu>.
I am trying to update its value from the backing bean after assigning the value in backing bean execdirectorRC="XXXvalue". Here,the executivedirectorslist does have a list values.

Here is the code in the form

<h:form id="ipdpform">
  <h:selectOneMenu id="exedirectors" value="#{Bean.execdirectorRC}">
    <f:selectItems value="#{Bean.executivedirectorslist}"
       var="s" itemLabel="#{s.label}" itemValue="#{s.value}" />
    <p:ajax listener="#{Bean.getDirectReporters}"
       update="rpt2 :growl :error" execute="@this"
       partialSubmit="true" />
    <f:param name="rpt1" value="rpt1" />
  </h:selectOneMenu>
</h:form >

Here is the code I am trying to udpate the value from the backing bean

RequestContext context = RequestContext.getCurrentInstance();
                execdirectorRC = "XXX,Name";
                context.update("ipdpform:exedirectors");


My problem is the value "XXX,Name" is not getting udpated in the <h:selectOneMenu>. and the values is already available in the Bean.executivedirectorslist.How can i update it from backing bean ?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Karthik
  • 371
  • 3
  • 7
  • 30

1 Answers1

0

You can use static utility functions like below.

public static void addWillBeUpdatedComponent(final String componentId) {
        FacesContext.getCurrentInstance().getPartialViewContext()
                .getRenderIds().add(componentId);
    }

public static void removeWillBeUpdatedComponent(final String componentId) {
        FacesContext.getCurrentInstance().getPartialViewContext()
                .getRenderIds().remove(componentId);
}

componentId must be in this format form:componentId not :form:componentId.

erk
  • 1
  • 2
  • Thanks erk.But is there any way other than the above method like the one I have mentioned ?context.update("ipdpform:exedirectors"); ? – Karthik Mar 25 '14 at 10:37
  • Thanks erk.But doesn't the code work in this way ?RequestContext context = RequestContext.getCurrentInstance(); execdirectorRC = "XXX,Name"; context.update("ipdpform:exedirectors"); – Karthik Mar 25 '14 at 12:14