10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Update ModelValues Phase<br />

After the <strong>Java</strong>Server Faces implementation determines that the data is valid, it can walk the<br />

component tree and set the corresponding server-side object properties to the components’<br />

local values. <strong>The</strong> <strong>Java</strong>Server Faces implementation will update only the bean properties pointed<br />

at by an input component’s value attribute. If the local data cannot be converted to the types<br />

specified by the bean properties, the life cycle advances directly to the render response phase so<br />

that the page is re-rendered with errors displayed. This is similar to what happens with<br />

validation errors.<br />

If any updateModels methods or any listeners called renderResponse on the current<br />

FacesContext instance, the <strong>Java</strong>Server Faces implementation skips to the render response<br />

phase.<br />

At this point, if the application needs to redirect to a different web application resource or<br />

generate a response that does not contain any <strong>Java</strong>Server Faces components, it can call<br />

FacesContext.responseComplete.<br />

If events have been queued during this phase, the <strong>Java</strong>Server Faces implementation broadcasts<br />

them to interested listeners.<br />

At this stage, the userNo property of the UserNumberBean is set to the local value of the<br />

userNumber component.<br />

Invoke Application Phase<br />

<strong>The</strong> Life Cycle of a <strong>Java</strong>Server Faces Page<br />

During this phase, the <strong>Java</strong>Server Faces implementation handles any application-level events,<br />

such as submitting a form or linking to another page.<br />

At this point, if the application needs to redirect to a different web application resource or<br />

generate a response that does not contain any <strong>Java</strong>Server Faces components, it can call<br />

FacesContext.responseComplete.<br />

If the view being processed was reconstructed from state information from a previous request<br />

and if a component has fired an event, these events are broadcast to interested listeners.<br />

<strong>The</strong> greeting.jsp page from the guessNumber example has one application-level event<br />

associated with the UICommand component. When processing this event, a default<br />

ActionListener implementation retrieves the outcome, success, from the component’s<br />

action attribute. <strong>The</strong> listener passes the outcome to the default NavigationHandler. <strong>The</strong><br />

NavigationHandler matches the outcome to the proper navigation rule defined in the<br />

application’s application configuration resource file to determine which page needs to be<br />

displayed next. See “Configuring Navigation Rules” on page 449 for more information on<br />

managing page navigation. <strong>The</strong> <strong>Java</strong>Server Faces implementation then sets the response view to<br />

that of the new page. Finally, the <strong>Java</strong>Server Faces implementation transfers control to the<br />

render response phase.<br />

Chapter 10 • <strong>Java</strong>Server FacesTechnology 315

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!