Questo contenuto non è disponibile nella lingua selezionata.

1.5.2. How it works


The game begins in the numberGuess.jspx view. When the page is first displayed, the pages.xml configuration activates a conversation and associates it with the numberGuess pageflow. The pageflow starts with a start-page tag (a wait state), so the numberGuess.xhtml is rendered.
The view references the numberGuess component, which causes a new instance to be created and stored in the conversation. the @Create method is called, initializing the game's state. The view displays an h:form, which allows the user to edit #{numberGuess.currentGuess}.
The "Guess" button triggers the guess action. Seam refers to the pageflow to handle the action, and the pageflow invokes #{numberGuess.guess} (which updates the guess count and highest/lowest suggestions in the numberGuess component), and transitions to the evaluateGuess state.
The evaluateGuess state checks the value of #{numberGuess.correctGuess} and transitions to either the win or evaluatingRemainingGuesses state. Assuming the number was incorrect, the pageflow transitions to evaluatingRemainingGuesses. This is also a decision state, which tests the #{numberGuess.lastGuess} state to determine whether or not the user is allowed further guesses. If further guesses are allowed (lastGuess is false), we transition back to the original displayGuess state. Since this is a page state, the associated page /numberGuess.jspx is displayed. This page also contains a redirect element, so Seam sends a redirect to the user's browser, which begins the process again.
If on a future request either the win or the lose transition were invoked, the user would be taken to /win.jspx or /lose.jspx respectively. Both states specify that Seam should end the conversation, stop holding game and pageflow state, and redirect the user to the final page.
The numberguess example also contains Give up and Cheat buttons. The pageflow state for both actions is relatively easy to trace, so we do not describe it here. Pay particular attention to the cheat transition, which loads a sub-process to handle that particular flow. Although in this application this process is superfluous, this demonstrates how complex pageflows can be broken down into smaller, simpler structures to make them easier to understand.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat