Book Image

Tapestry 5: Building Web Applications

Book Image

Tapestry 5: Building Web Applications

Overview of this book

Table of Contents (17 chapters)
Tapestry 5
Credits
About the Author
About the Reviewers
Preface
Foreword
Where to Go Next

Was an ASO Already Instantiated?


The final important piece of knowledge about dealing with an ASO is checking whether it exists or not. Consider the following scenario—as soon as the user has successfully logged in, you are storing his or her data in an ASO. On the other pages you are going to check whether the user is logged in and change the displayed information appropriately.

Remember that Tapestry will always give you an ASO as soon as you request for it. So you can request for the User ASO, check its contents, and if the contents are default, then the user hasn't logged in yet. All this is fine; but the problem is that you want to make your application highly scalable, which means you do not want to create a session unless it is absolutely necessary. Tapestry will create a session, the first time you request an ASO, even if you just wanted to check whether the values are default.

Fortunately, Tapestry provides a convenient way of checking whether an ASO was ever requested (and so...