Closing Modal Window causes commits changes with JPA form

[font=Arial]
[size=5]

[/size]Hi,

i put a simple textarea with a datasource pointing to a EntityItem ( from JPAContainer). The problem is that when i close de modal window (clicking the ‘X’) changes at TextArea are commited. Why? How can i avoid this?.

Thanks in advance!
[/font]

This happens because the textarea is by default non-immediate which means client-side value change events are just put in a queue but do not trigger a round-trip to the server. The window is however by default immediate which means that the client-side close event is immediately sent. When something is sent to the server, everything that has been queued is also sent to maintain a consistent event ordering.

What you should to to avoid accidentally updating the EntityItem is to disable the text area’s write through (using myTextArea.setWriteThrough(false)). When you want to commit the current value (e.g. when the user presses a submit button), you can call the commit() method on the text area to write its UI value to the EntityItem. If you have multiple fields in a Form, you don’t need to commit each field separately but you can instead invoke Form.commit() which commits all the fields in that Form.

Thank you very much Leif!