When making the switch from FreeMarker to WebMacro, I did not like the idea
of forcing my business objects to provide display oriented methods.  So my
first idea was to create a DisplayProxy that wrapped a business object and
implemented methods in a display oriented manner.

For example:

Taxes
{
...
    public double getSalesTax()
    {
        return 0.0825;
    }
}

TaxesDisplayProxy extends Hashtable
{
...
    public String getSalesTax()
    {
        return formatPercent(tax.getSalesTax());
    }
}

I am now thinking it might lead to less code to develop some generally
useful functions are available in the Context, and just stuff the business
object directly into the Context.  This would make the templates slightly
messier, but its a pretty small price to pay to eliminate a lot of
repetitious code.

One problem though,  I liked to have the display objects extend a Hashtable
so that it was easy to add things like a link (DynamicURI) for the object,
so for example a loop through a list of objects with Edit or Delete links
(buttons)
is easy to read and write in the template.

I was thinking it should be possible to define a generic DisplayProxy like

DisplayProxy extends Hashtable
{
    public Object obj;
    DisplayProxy(Object obj)
    {
        this.obj = obj;
    }
}

Since WM is using reflection to find the objects methods, I was thinking
there should not be any casting problems with this approach.  Is this
correct?

What are your thoughts on this approach?  What other ways are there to
accomplish what I want?

which is that a link can be specified like

<a href="$project.deleteLink">delete</a>

and not

<a href="$link.setPathInfo("action",
"UpdateProject").setPathInfo("project_id",
$project.getId()).setPathInfo("submitevent_delete","submitevent_delete"">del
ete</a>

Or maybe there is little benefit to the readablitiy of the first.

Let me know your thoughts,

John McNally




------------------------------------------------------------
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