previous | index | next

Faking a Form Submit

The reference window.document.forms[0].action represents the action for the only form on the page.

Note that this URL does not end in .ajax, so the Ajax servlet does not handle it.

Sending it tricks JSF into thinking that the user submitted the form, causing the JSF life cycle to start.

Why? Because we need the component tree to be updated by the Restore View phase of the JSF life cycle so the entered zip code can be accessed.

We only need the JSF for the first phase, after which we can short-circuit the rest of the life cycle using a phase listener.


previous | index | next