Re: Freemarker in Java app server, best practices

Chris <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
> It's of course completely up to the Web Application Framework how it
> associates the views (templates) with the backing "action" (which is
> usually represented by a class or a method)... do it on the way it
> best fits your particular application. But usually it's the action
> that chooses the view, and not the other way around. This is because
> request URL-s are normally associated with actions (not with views),
> as actions do the MVC Controlling and other application-logic
> decisions (which may includes forwarding to another URL, which is
> clearly pre-view-rendering stuff), so naturally they run first, and
> only then will the view be rendered. Also, an action may conditionally
> chooses from multiple views. But if you still want to do this on the
> other way around, then you can use something like <#ftl
> attributes={"action":"com.example.YourClass"}>, and then in your
> framework (i.e., not on the application level) ensure that before
> templates are executed this attribute is extracted with
> theTemplate.getCustomAttribute("action") and processed as it should
> be.
> 

This makes sense, although in my app several different views have the 
same action. I'd have to write an action that would extract a view 
parameter from the URL (http://foo.com/myaction?myview=bar) and then 
dispatch the call to the appropriate view. Possible, but it's backwards 
from the way most frameworks work. JSP pages, for example, call the view 
and then the view figures out how to render itself. It's a lot easier to 
just drop a page in a site and have it work without fiddling with a 
controller.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.