If you want to provide some type of Gracelet view that will handle all the requests in a particular
sub-url of your web context, you can do this via Gracelet Directory views. A Gracelet directory view
is a view whose source filename ends in '_directory.groovy'.
As long as you have not disabled the DirectoryFilter mentioned in
Getting
Setup, then views of this type will be automatically detected when the web application is deployed. The DirectoryFilter
will catch requests that match the prefix of the view. It will then forward the call to the JSF view using the
configured extension (defaults to .jsf, see
Getting Setup for information on
setting the extension used for directory views). For example the following table shows how different
directory views will handle different sub-url's of the web context:
Directory View Filename<->Mapping ExamplesSource file location | Url's mapped (relative to web context) |
/some_directory.groovy | /some/* |
/blog/entries_directory.groovy | /blog/entries/* |
/blog/users_directory.groovy | /blog/users/** |
With the examples above we say that the some_directory.groovy view will handle ALL requests for
any type of file/URL requested that is prefixed with /some/. Then we say that all URL requests that
are prefixed /blog/entries/ will be handled by the /blog/entries_directory.groovy view. The last example
should be self explanatory.
In order for the view to know what URL it is supposed to be handling a view relative path is stored and
provided in a request level variable called DIRECTORY_PATH. The Gracelet view script could then use this
variable to determine what it will show as a result.
You can see an example of this in the
Blog Application example.