From the very beginning it is important to understand the page design concept behind
gracelets. If this is not understood, it can cause some confusion in regards to expected
functionality when writing gracelet pages.
This concept involves combined code that can participate in different parts of the JSF
life cycle. This could be divided into three different aspects of a gracelet page:
The code in blue is blueprint code. This code is only
ran once in order to build the blueprint that will be used to create this view.
The code in green is render code. This code will be ran
each time the page is rendered. In this instance the code reads from an xml file that is in the same
directory as the view so as to get a list of items for the menu.
The code in red is action code. On line 4, this is code inside
of a factory closure, which will initiate the currentUser bean when it is null. On line 25, this is part
of a value closure, which will determine in this case the rendered logic for the form, which here says
that if the loggedIn flag is false, show the login form. On line 29 and 35 we have a value binding closures which
allows the value of the specified bean property in the closure to be used as the binding for the input components. On
lines 40-43 we have action closure code, which will be executed when the user clicks on the "Login" button. And
lastly on line 48 we have another value closure which is also determining whether or not this template will
show the actual view using it depending on the loggedIn value of the currentUser bean.