Jon,
I think this is a great idea. This would effectively eliminate a lot of
screens in most applications.  In most of the stuff I've done, the
screens are used (for the most part) to populate the context as the
results of a query.     

I see this as kind of a hybrid between a WebMacro context tool and a JSP
tag library. 

Here's a suggestion as a start,  what about having a base class or
interface that all tags implement and are configured via an XML file.  The
XML file could be loaded when the WebMacro/Velocity service is started. 
The XML file would point to the bean like Object that you want to put
into the context along with any other parameters you might pass to the
bean ( the parameters could be things like permission, etc. ).  This XML
file could be loaded during the TemplateService initialization.

Here's a rough example of a tag for the phone demo.

public abstract class TemplateTag 
{
private String name;
private Hashtable properties;
         
public void doBuild( RunData data){};

public void setName(String val)
{
//loaded from the XML file
}
public String getName()
{
return name;
}

public void setProperty(String name, String value)  
{
//loaded from the XML file for each property specified.         
}

public String getProperty( String name )
{
return properties.get( name );
}                           
}        

// Here's a custom tag that lists phone numbers.

public Phonelist implements TemplateTag
{
public void doBuild( RunData data )
{ 

if ( !data.getACL().hasPermission( getProperty("permission") )
{
data.setMessage( getProperty("message") );
data.getTemplateInfo().setTemplate( getProperty("nextscreen");
}
  
// Puts a list of phone numbers in the Vector
Vector results = Phone.doSelect( new Criteria() );
data.getTemplateInfo().setTemplateContext(getName(), results );
}
}

Configuration file loaded when the service starts:

<TemplateTag name=phonelist class=org.turbine.Phonelist>
<property name="permission" value="view-phonelist"/>
<property name="nextscreen" value="login"/>
<property name="message" value="You're not authorized!/>
</TemplateTag>

Then in the HTML Page - listphonenumbers.vm

#foreach $number in $phonelist
{ 
<td>$number</td>
}

This is a rough example, but hopefully it gets the idea across.  With
this method you could even have Torque generate the Tags for each
BaseObject since in a lot of cases you want access to the database. With
the XML configuration file, the programmer decides what the template author
has access to. 

As you've already mentioned there are some issues with MTs and more than
one  Turbine app running in the same VM that need to be sorted out with
this.

Anyway, I finally have some free time so I'd be happy to help you with
this. This would be very useful to me!

-- 
dave
[EMAIL PROTECTED]
----------------------



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to