I am building a web application using Click on the Google App Engine. One of 
the 'features' I would like to have is the ability to try setting a template -- 
if it is available. Like the Click example we have a BasePage > BorderPage 
(with a template of border.htm) and our Page classes extend BorderPage. 

One of those Page classes is BrandPage -- for some consumer brands. The 
BrandPage will have some common methods - search for products matching this 
brand for example - think ecommerce. Additionally, there is a brand.htm file 
for the BrandPage. 

However, I would like some brands, not all, to have a template available to 
parse - we would like to build out some custom .htm pages to parse in the 
brand.htm. For example we may have three brands , A, B, C and A.htm, C.htm but 
not a B.htm in a directory say ... /brand/A.htm 

Normally in the BrandPage I would put something like this: 

public String getTemplate() 
{ 
return A.htm (or C.htm, or even B.htm) 
} 

From the example above, while A.htm or C.htm exist, B.htm does not. 

How this would have happened is that when the BrandPage was requested, with a 
brand id for example, the database search would return the brand (and product 
etc...). I would then 'dynamically' set the getTemplate() return to [Normalized 
Brand Name].htm 

My question is this -- how can I test to see if B.htm exists before I even set 
the getTemplate return value? My focus has been using something utility-wise in 
Click - am I missing a simple way to do this? Wrap a try catch somewhere? As 
you would expect, I currently get the 
org.apache.velocity.exception.ResourceNotFoundException -- but I cannot catch 
it in the Page in order to do something else. 

I also want it to be a quick process. I have pondered using File to look in a 
specific directory ("/brand/file.htm"). My biggest concerns are: 1. Speed for 
this 'function', 2. Google App Engine restrictions - would looking at a file in 
the /war cause an issue, and finally if Click has something I missed as a 
convenience for this idea. Solving this gives us tremendous flexibility on the 
presentation and is a critical feature to our application. I am also concerned 
that the way I am thinking about this is flawed so any alternative design 
pattern suggestions are welcome. 

Thank you for a great framework - I have tried nearly all of them and Click 
nailed it.

Reply via email to