Search code examples
eventsrichfaces

Richfaces prohibit event by passing by user


I have a text box and value change listener on it. And there is a save button. The user avoids/bypasses value change listener by directly editing text box value in html code and then saves it. How can i prohibit the user, so that he/she is not able to change value this way? And thus make sure that value change listener is always called.

I am looking for some generic mechanism to stop such cases on all inputs/and event listeners.

Thanks


Solution

  • You need to accept that the user can actually do EVERYTHING he wants with his client (the browser). He can disable Javascript, remove inputs completely, change validation or call Ajax functionality manually. He might not even use a browser and send an HTTP request using a command line tool.

    It is just impossible to prohibit such things.

    On the other hand I think that in case you use a valueChangeListener on your h:inputText, then it should be called in any case, because it will be evaluated serverside. It might be that you edited it the wrong way and the value actually doesn't change when you save the content of the form. (Check that the value really gets set by adding a breakpoint to your setter).

    If you use Ajax functionality using <f:ajax> with event="change" and a listener, then there is no way to prevent bypassing it by manually editing the html. Either check for the changed value in your save method, or use the valueChangeListener instead.