Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Made images big enough to see

...

Running the application gives us our start:

Image RemovedImage Added

However, clicking the link doesn't do anything yet, as its just a placeholder \<a\> tag, not an actual Tapestry component. Let's think about what should happen when the user clicks that link:

...

If you click the link, you'll get an error:

Image RemovedImage Added

Tapestry is telling us that we need to provide some kind of event handler for that event. What does that look like?

...

So ... let's click the link and see what we get:

Image RemovedImage Added

Ah! We didn't create a Guess page template. Tapestry was really expecting us to create one, so we better do so.

...

Hit the browser's back button, then click the "start guessing" link again. We're getting closer:

Image RemovedImage Added

If you scroll down, you'll see the line of the Guess.tml template that has the error. We have a field named target, but it is private and there's no corresponding property, so Tapestry was unable to access it.

...

We are getting very close but there's one last big oddity to handle. Once you refresh the page you'll see that target is 0!

Image RemovedImage Added

What gives? We know it was set to at least 1 ... where did the value go?

...

Go back to the Index page and click the link again. Finally, we have a target number:

Image RemovedImage Added

That enough for us to get started. Let's build out the Guess page, and get ready to let the user make guesses. We'll show the count of guesses, and increment that count when they make them. We'll worry about high and low and actually selecting the correct value later.

...

At this point, the page is partially operational:

Image RemovedImage Added

Our next step is to actually check the value provided by the user against the target and provide feedback: either they guessed too high, or too low, or just right. If they get it just right, we'll switch to the GameOver page.

For wrong guesses, we'll see an update such as:

Image Modified

And correct guesses will send us to the GameOver page:

Image RemovedImage Added

Let's start with the Guess page; it now needs a new property to store the message to be displayed to the user, and needs a field for the injected GameOver page:

...