0

I have a JSF page, with some components rendered if a certain value is selected in SelectOneMenu. For that I change their rendered value and call RequestContext.getCurrentInstance().update("@form").

From the client point of view, whenever I select the value, I get a response from server:

<update id="mainForm:addUser:menu_14:menu">
<...some updated values...>
</update>

Yet, the element with id mainForm:addUser:menu_14:menu did not update.

Can anybody tell me what is wrong?

Update I can add commandButton with update="@form", and pressing this button actually redraws the form as needed. But I need to do this from the backing bean, so...

A.Panzer
  • 391
  • 3
  • 15
SMSk
  • 693
  • 8
  • 25
  • Usually it's easier to do these things from the Facelets page, not the backing bean. I haven't encountered an instance where I "need" to update from the backing bean. – DavidS Oct 01 '15 at 17:55
  • 1
    @DavidS: I have... But those are cases where a kind of framework is being developed – Kukeltje Oct 01 '15 at 19:22
  • @DavidS: It's exactly the case -- we have a framework that creates JSF pages from XML file, so I don't have an access to the page source – SMSk Oct 04 '15 at 14:04

2 Answers2

2

From the docs:

public abstract void update(String name)

Update a component with ajax.

name - Client side identifier of the component.

So you can't use selectors like you do from the xhtml file, you have to give client ID of the component.

RequestContext.getCurrentInstance().update("mainForm")
Community
  • 1
  • 1
Geinmachi
  • 1,251
  • 1
  • 8
  • 20
0

Are you using Primefaces? You should pass client id to RequestContext.update method. @form won't work. Try update(mainForm).

A.Panzer
  • 391
  • 3
  • 15