|
Re: html macro library: msg#00206jakarta.velocity.user
I like this approach too. I did something that looks similar but uses a bunch of classes I wrote instead of an XML library. In my version $utils refers to my tool loader class. Each tool has a hashmap of properties and implements a toString method so you do it similarly like this: #set($checkfield = $tools.getElement('checkbox')) $checkfield.setProperty('choices', '...') $checkfield.setProperty('checked', '...') $checkfield You only need to put '$checkfield' at the end because all my tools have a toString method and Velocity calls this method for every $reference anyway. Using a tool like this you can also put some smarts in it if you like. I agree that this kind of thing is easier despite requiring more lines. I think it makes more sense (easier to read and write) when you're writing templates to see what you are setting. Cheers, Andrew Tetlaw Bligh Voller Nield http://www.bvn.com.au p: (07) 3251 5778 f: (07) 3852 2544 "Rodrigo Reyes" <rodrigo@xxxxxxxxxxxxxx> wrote on 31/05/2003 03:49:47 AM: > Hi > I have been using Velocity on a pretty complex website. One of the > things I learned from this project is that maybe the easiest and most > maintainable way to handle the creation of tags inside a template is using > an XML library. For my specific needs, I use JDOM. So when I need to have a > link created I do something like this: > > #set($a = $utils.getElement('a')) > $a.setAttributeValue('href', '...') > $a.setAttributeValue(target, '...') > $a.setAttributeValue('onClick', '...') > .... > $a.setText('This text is linked to ...') > $utils.toString($a) > > I know that those are many lines of code for a simple link, but from my > experience, it's a lot easier to read and maintain. And an Element in JDOM > could also contain other Elements, so I can have that as recursive as I > need. > My 2 c... > > Rodrigo <font face="Arial, Helvetica, sans-serif" size="2"> <b> Please Also Note </b>This document, including attachments, is only intended for the addressees and may contain privileged or confidential information. Unauthorised use, copying or distribution of the document or any part of its contents, is prohibited. If you receive this Email in error please notify us by return Email or telephone. We will reimburse you for any reasonable expenses incurred in meeting this request.</font> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: html macro library: 00206, Andrew Tetlaw |
|---|---|
| Next by Date: | Re: security audit: 00206, Will Glass-Husain |
| Previous by Thread: | RE: html macro libraryi: 00206, Kevin Bolton |
| Next by Thread: | Re: html macro library: 00206, Daniel Dekany |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |