Saturday, 25 April 2009

Useful Seam Tip - Page Actions

The page-action tag is a useful way of settings things up in the backing bean, ready for rendering the page. However, it' important to note that the page action is re-fired on every submission.

In many cases, I use the page action to set up default data, and to populate lists for dropdowns, etc. I don't want this to be re-executed during the conversation, as this would result in loss of user-entered data (e.g. knowing which item they selected in a DataTable). I've spent time debugging strange behavior, only to realise that the problem was caused by Seam re-triggering the page action (usually the wire() function on the EntityHome).

It's pretty easy fix - just set on-postback to false:


<action execute="#{myEntityHome.wire}" on-postback="false">


This tells Seam not to trigger the function when a form is posted back to the server as a result of actions being executed/validation within the conversation.

No comments:

Post a Comment