Search code examples
javajsfrendervisible

2 Mutually Exclusive InputComponents Referring to the same Field is updating the same field Twice


I have a screen with 2 JSF Input Components: inputText and inputText with suggestionBox. They are both bound to the same field, but only one can be visible/rendered (mutual exclusion).
The thing is that if I write something in one and then submit, the other component which is not displayed is updating the model (the same field is updated again) with it's value (which is empty string or null). To work around this I created another field in my Class, so that the 2 components don't refer to the same field.
I don't like this, because I'm altering my model to solve a GUI problem.

How can I have 2 mutually exclusive input components referring the same value working as I want ?


Solution

  • As I stated I can't use rendered, so in this case using readonly true with visible false gives me the behavior I need. Thanks.