Search code examples
javajsficefaces

How to modify a JSF backing bean value before the UpdateModelValuesPhase?


I have a JSF form that consists of a grid and some detail fields. The detail fields contain the data of the first row in the grid. I have a backing bean that listens to the grid row selection and updates the detail fields' backing beans to represent the new values. Here comes the problem: I update the detail fields as needed (the listener is invoked in the ApplyRequestValuesPhase), but later the JSF framework reassings the old values to them in the UpdateModelValuesPhase.

My question is how to fix it? How could I assign new values to some JSF components from the grid selection change event?

Note: this is about the very the same thing as in JSF component doesn't update if changes came from grid click but I see the problem more clearly now I think, that's why I posted a new question.


Solution

  • It's not normal that a listener is invoked during apply request values phase. Perhaps you've set immediate="true" somewhere which will cause the actions to be performed during apply request values phase. You need to make sure that the listener is invoked during the invoke action phase which runs right after the update model values phase. Set immediate="false" or just remove the attribute altogether, it's the default behaviour already.

    As per the comments, you seem to indeed have set the immediate="true" on the row selector, you'd need to remove it.