You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by cctech <cc...@cityarchitect.co.uk> on 2003/09/17 13:43:01 UTC

Velocity newbie question

I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
Headlong into building a complex application with a large data model.

I have been constructing screens using Velocity for both displaying
Table data and for editing it. Trouble is, I seem to create Action
Classes for both display and for edit that are both exactly the same.

E.g. ShowDetails.java for ShowDetails.vm
And  EditDetails.java for EditDetails.vm (then goes to
UpdateDetails.java)

In this case the code for the two java classes (Show, Edit) is exactly
the same except with different class names.

Is there anyway of re-using the same class for different velocity
templates?
Have I missed something simple?

Thanks,

Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Velocity newbie question

Posted by Matt Hughes <mh...@uvic.ca>.
cctech writes:
 > I have been constructing screens using Velocity for both displaying
 > Table data and for editing it. Trouble is, I seem to create Action
 > Classes for both display and for edit that are both exactly the same.
 > 
 > E.g. ShowDetails.java for ShowDetails.vm
 > And  EditDetails.java for EditDetails.vm (then goes to
 > UpdateDetails.java)
 > 
 > In this case the code for the two java classes (Show, Edit) is exactly
 > the same except with different class names.

The way I usually approach this is to use the same Screen and template
for both showing and editing. The difference is setting a read only
flag when users shouldn't be able to edit the data. 

So one way is to test once in the velocity template:

#if ($readonly)
  ## Contents of ShowDetails.vm
#else
  ## Contents of EditDetails.vm
#end

But the way I do it is to set a readonly flag for each individual
field (so that if a user doesn't have permission to update a given
field, they can't), and test that field in the #formXXX generation
macro. This is in a sort of homebrew Intake implementation which
stores for definitions in the database, btw.

The other advantage of checking at each item (in macros) is that when
you change the template, you only have to change it once, rather than
remembering to change two files or on both sides of an #else.

-- 
 Matt Hughes
  + mhughe@uvic.ca
  + http://susurrous.net/
  + "Were there monkeys? Some terrifying space monkeys maybe got loose?"

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Velocity newbie question

Posted by Matt Hughes <mh...@uvic.ca>.
cctech writes:
 > I have been constructing screens using Velocity for both displaying
 > Table data and for editing it. Trouble is, I seem to create Action
 > Classes for both display and for edit that are both exactly the same.
 > 
 > E.g. ShowDetails.java for ShowDetails.vm
 > And  EditDetails.java for EditDetails.vm (then goes to
 > UpdateDetails.java)
 > 
 > In this case the code for the two java classes (Show, Edit) is exactly
 > the same except with different class names.

The way I usually approach this is to use the same Screen and template
for both showing and editing. The difference is setting a read only
flag when users shouldn't be able to edit the data. 

So one way is to test once in the velocity template:

#if ($readonly)
  ## Contents of ShowDetails.vm
#else
  ## Contents of EditDetails.vm
#end

But the way I do it is to set a readonly flag for each individual
field (so that if a user doesn't have permission to update a given
field, they can't), and test that field in the #formXXX generation
macro. This is in a sort of homebrew Intake implementation which
stores for definitions in the database, btw.

The other advantage of checking at each item (in macros) is that when
you change the template, you only have to change it once, rather than
remembering to change two files or on both sides of an #else.

-- 
 Matt Hughes
  + mhughe@uvic.ca
  + http://susurrous.net/
  + "Were there monkeys? Some terrifying space monkeys maybe got loose?"

RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Brian,

Thanks. I have around 50 Entities in my database, so I guess that I
Am going to end up with 50 List .vm and .javas, and either 50/100/150
Edit and Display .vms and .javas. I'd rather not let them all be
Called Default :)

Funny thing, when looking at the files I've produced, they are somewhat
Formulaic; it should be possible to generate them all from the initial
Torque, Schema.xml file, apart from the one-to-many and many-to-many
Relationships of course; you would have to extend the schema dtd to
Declare the relationships for those.

There's a challenge for someone.......

Steve

-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 15:39
To: Turbine Users List
Subject: Re: Velocity newbie question


Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I 
> think of that?). Slight drawback is that I've got three files now 
> (although one with actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your 
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone

>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying 
>> Table data and for editing it. Trouble is, I seem to create Action 
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is 
>> exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity 
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Velocity newbie question

Posted by Jeffery Painter <pa...@kiasoft.com>.
I'll make a note of it :)

Henning said he would work with me towards putting the book together. We 
have hurricane Isabel sweeping through my neighborhood today so I have 
some off time till Monday to do some writing.

turning my computers off for a few days...

Jeffery


On Thu, 18 Sep 2003, cctech wrote:

> Thanks to Brian, Matt and Jeffery!
> 
> You think that you know everything from reading the instructions, but
> there's no substitute for experience when it comes to actually producing
> something using Turbine. 
> 
> I have used the ideas and cut the number of files per database table
> down to 5;
> 
> EditTableEntry.java EditTableEntry.vm and UpdateTableEntry.java
> Plus
> ListTable.java and ListTable.vm
> 
> Plus, I've learnt to use the addPathInfo to pass my mode parameters (and
> getParameters in my java to put it back into the context).
> 
> And, I've learnt to use #if ($mode == blah) liberally in my screen .vm
> files to sort out what should be displayed and what shouldn't, and what
> should be editable and what shouldn't.
> 
> And I'm far happier for the experience...
> 
> This stuff should be in the "turbine book" talked about on the list;
> supplement the technical reference with real experience, "how-tos".
> 
> Thanks to all for your help!
> 
> Steve 
> 
> 
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com] 
> Sent: 17 September 2003 15:39
> To: Turbine Users List
> Subject: Re: Velocity newbie question
> 
> 
> Turbine's implementation of MVC pretty much implies a one-to-one 
> mapping between Screen templates and Screen classes, but there is one 
> wrinkle: Default.java
> 
> The order of resolution for finding a screen class includes looking for 
> a Default.java file if there is not a correctly named class to service 
> the Screen request.  Basically, the order for resolving a screen called 
> foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
> foo.bar.Default, then for foo.Default, then for Default.  If you are 
> doing things on a very granular level (i.e. one subdir per data 
> element) then you could conceivably use the Default class as the single 
> point for your logic.
> 
> Having said all that, it is probably a bad idea, as your system may 
> soon contain dozens of classes named Default.
> 
> So my initial suggestion is still the one I would go with.  Perhaps you 
> could put all of the code in ShowDetails and have EditDetails extend 
> ShowDetails.   That gets you down to 2 and preserves reasonable naming 
> for your screen classes.
> 
> -Brian
> 
> On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:
> 
> > Brian,
> >
> > Thank you. That would be the correct OO way of doing it (Why didn't I 
> > think of that?). Slight drawback is that I've got three files now 
> > (although one with actual code),
> > And I was rather trying to get to one file.
> >
> > Thanks,
> >
> > Steve
> >
> > -----Original Message-----
> > From: Brian Lawler [mailto:brian@tribenetwork.com]
> > Sent: 17 September 2003 13:54
> > To: Turbine Users List
> > Subject: Re: Velocity newbie question
> >
> >
> > Steve-
> >
> > You can make a base class for the 2 screens and have both of your 
> > actual screen classes extend it:
> >
> > BaseDetails - has all of your common code.
> >
> > ShowDetails extends BaseDetails
> > EditDetails extends BaseDetails
> >
> > Just be sure to call super.doPerform() from you child classes.
> >
> > -Brian
> >
> > On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
> >
> >> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> 
> >> Headlong into building a complex application with a large data model.
> >>
> >> I have been constructing screens using Velocity for both displaying 
> >> Table data and for editing it. Trouble is, I seem to create Action 
> >> Classes for both display and for edit that are both exactly the same.
> >>
> >> E.g. ShowDetails.java for ShowDetails.vm
> >> And  EditDetails.java for EditDetails.vm (then goes to
> >> UpdateDetails.java)
> >>
> >> In this case the code for the two java classes (Show, Edit) is 
> >> exactly
> >
> >> the same except with different class names.
> >>
> >> Is there anyway of re-using the same class for different velocity 
> >> templates? Have I missed something simple?
> >>
> >> Thanks,
> >>
> >> Steve
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 

-- 

Jeff Painter
------------
painter@kiasoft.com

President
Kiasoft, Inc.
PO Box 4315
Cary, NC 27519-4315

http://kiasoft.com
(919) 677-8525


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Velocity newbie question

Posted by Jeffery Painter <pa...@kiasoft.com>.
I'll make a note of it :)

Henning said he would work with me towards putting the book together. We 
have hurricane Isabel sweeping through my neighborhood today so I have 
some off time till Monday to do some writing.

turning my computers off for a few days...

Jeffery


On Thu, 18 Sep 2003, cctech wrote:

> Thanks to Brian, Matt and Jeffery!
> 
> You think that you know everything from reading the instructions, but
> there's no substitute for experience when it comes to actually producing
> something using Turbine. 
> 
> I have used the ideas and cut the number of files per database table
> down to 5;
> 
> EditTableEntry.java EditTableEntry.vm and UpdateTableEntry.java
> Plus
> ListTable.java and ListTable.vm
> 
> Plus, I've learnt to use the addPathInfo to pass my mode parameters (and
> getParameters in my java to put it back into the context).
> 
> And, I've learnt to use #if ($mode == blah) liberally in my screen .vm
> files to sort out what should be displayed and what shouldn't, and what
> should be editable and what shouldn't.
> 
> And I'm far happier for the experience...
> 
> This stuff should be in the "turbine book" talked about on the list;
> supplement the technical reference with real experience, "how-tos".
> 
> Thanks to all for your help!
> 
> Steve 
> 
> 
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com] 
> Sent: 17 September 2003 15:39
> To: Turbine Users List
> Subject: Re: Velocity newbie question
> 
> 
> Turbine's implementation of MVC pretty much implies a one-to-one 
> mapping between Screen templates and Screen classes, but there is one 
> wrinkle: Default.java
> 
> The order of resolution for finding a screen class includes looking for 
> a Default.java file if there is not a correctly named class to service 
> the Screen request.  Basically, the order for resolving a screen called 
> foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
> foo.bar.Default, then for foo.Default, then for Default.  If you are 
> doing things on a very granular level (i.e. one subdir per data 
> element) then you could conceivably use the Default class as the single 
> point for your logic.
> 
> Having said all that, it is probably a bad idea, as your system may 
> soon contain dozens of classes named Default.
> 
> So my initial suggestion is still the one I would go with.  Perhaps you 
> could put all of the code in ShowDetails and have EditDetails extend 
> ShowDetails.   That gets you down to 2 and preserves reasonable naming 
> for your screen classes.
> 
> -Brian
> 
> On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:
> 
> > Brian,
> >
> > Thank you. That would be the correct OO way of doing it (Why didn't I 
> > think of that?). Slight drawback is that I've got three files now 
> > (although one with actual code),
> > And I was rather trying to get to one file.
> >
> > Thanks,
> >
> > Steve
> >
> > -----Original Message-----
> > From: Brian Lawler [mailto:brian@tribenetwork.com]
> > Sent: 17 September 2003 13:54
> > To: Turbine Users List
> > Subject: Re: Velocity newbie question
> >
> >
> > Steve-
> >
> > You can make a base class for the 2 screens and have both of your 
> > actual screen classes extend it:
> >
> > BaseDetails - has all of your common code.
> >
> > ShowDetails extends BaseDetails
> > EditDetails extends BaseDetails
> >
> > Just be sure to call super.doPerform() from you child classes.
> >
> > -Brian
> >
> > On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
> >
> >> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> 
> >> Headlong into building a complex application with a large data model.
> >>
> >> I have been constructing screens using Velocity for both displaying 
> >> Table data and for editing it. Trouble is, I seem to create Action 
> >> Classes for both display and for edit that are both exactly the same.
> >>
> >> E.g. ShowDetails.java for ShowDetails.vm
> >> And  EditDetails.java for EditDetails.vm (then goes to
> >> UpdateDetails.java)
> >>
> >> In this case the code for the two java classes (Show, Edit) is 
> >> exactly
> >
> >> the same except with different class names.
> >>
> >> Is there anyway of re-using the same class for different velocity 
> >> templates? Have I missed something simple?
> >>
> >> Thanks,
> >>
> >> Steve
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 

-- 

Jeff Painter
------------
painter@kiasoft.com

President
Kiasoft, Inc.
PO Box 4315
Cary, NC 27519-4315

http://kiasoft.com
(919) 677-8525


RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Thanks to Brian, Matt and Jeffery!

You think that you know everything from reading the instructions, but
there's no substitute for experience when it comes to actually producing
something using Turbine. 

I have used the ideas and cut the number of files per database table
down to 5;

EditTableEntry.java EditTableEntry.vm and UpdateTableEntry.java
Plus
ListTable.java and ListTable.vm

Plus, I've learnt to use the addPathInfo to pass my mode parameters (and
getParameters in my java to put it back into the context).

And, I've learnt to use #if ($mode == blah) liberally in my screen .vm
files to sort out what should be displayed and what shouldn't, and what
should be editable and what shouldn't.

And I'm far happier for the experience...

This stuff should be in the "turbine book" talked about on the list;
supplement the technical reference with real experience, "how-tos".

Thanks to all for your help!

Steve 


-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 15:39
To: Turbine Users List
Subject: Re: Velocity newbie question


Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I 
> think of that?). Slight drawback is that I've got three files now 
> (although one with actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your 
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone

>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying 
>> Table data and for editing it. Trouble is, I seem to create Action 
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is 
>> exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity 
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Brian,

Thanks. I have around 50 Entities in my database, so I guess that I
Am going to end up with 50 List .vm and .javas, and either 50/100/150
Edit and Display .vms and .javas. I'd rather not let them all be
Called Default :)

Funny thing, when looking at the files I've produced, they are somewhat
Formulaic; it should be possible to generate them all from the initial
Torque, Schema.xml file, apart from the one-to-many and many-to-many
Relationships of course; you would have to extend the schema dtd to
Declare the relationships for those.

There's a challenge for someone.......

Steve

-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 15:39
To: Turbine Users List
Subject: Re: Velocity newbie question


Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I 
> think of that?). Slight drawback is that I've got three files now 
> (although one with actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your 
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone

>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying 
>> Table data and for editing it. Trouble is, I seem to create Action 
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is 
>> exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity 
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Thanks to Brian, Matt and Jeffery!

You think that you know everything from reading the instructions, but
there's no substitute for experience when it comes to actually producing
something using Turbine. 

I have used the ideas and cut the number of files per database table
down to 5;

EditTableEntry.java EditTableEntry.vm and UpdateTableEntry.java
Plus
ListTable.java and ListTable.vm

Plus, I've learnt to use the addPathInfo to pass my mode parameters (and
getParameters in my java to put it back into the context).

And, I've learnt to use #if ($mode == blah) liberally in my screen .vm
files to sort out what should be displayed and what shouldn't, and what
should be editable and what shouldn't.

And I'm far happier for the experience...

This stuff should be in the "turbine book" talked about on the list;
supplement the technical reference with real experience, "how-tos".

Thanks to all for your help!

Steve 


-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 15:39
To: Turbine Users List
Subject: Re: Velocity newbie question


Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I 
> think of that?). Slight drawback is that I've got three files now 
> (although one with actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your 
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone

>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying 
>> Table data and for editing it. Trouble is, I seem to create Action 
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is 
>> exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity 
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity newbie question

Posted by Brian Lawler <br...@tribenetwork.com>.
Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I
> think of that?).
> Slight drawback is that I've got three files now (although one with
> actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying
>> Table data and for editing it. Trouble is, I seem to create Action
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity newbie question

Posted by Brian Lawler <br...@tribenetwork.com>.
Turbine's implementation of MVC pretty much implies a one-to-one 
mapping between Screen templates and Screen classes, but there is one 
wrinkle: Default.java

The order of resolution for finding a screen class includes looking for 
a Default.java file if there is not a correctly named class to service 
the Screen request.  Basically, the order for resolving a screen called 
foo/bar/Baz.vm is to first look for the foo.bar.Baz class, then for 
foo.bar.Default, then for foo.Default, then for Default.  If you are 
doing things on a very granular level (i.e. one subdir per data 
element) then you could conceivably use the Default class as the single 
point for your logic.

Having said all that, it is probably a bad idea, as your system may 
soon contain dozens of classes named Default.

So my initial suggestion is still the one I would go with.  Perhaps you 
could put all of the code in ShowDetails and have EditDetails extend 
ShowDetails.   That gets you down to 2 and preserves reasonable naming 
for your screen classes.

-Brian

On Wednesday, September 17, 2003, at 07:08  AM, cctech wrote:

> Brian,
>
> Thank you. That would be the correct OO way of doing it (Why didn't I
> think of that?).
> Slight drawback is that I've got three files now (although one with
> actual code),
> And I was rather trying to get to one file.
>
> Thanks,
>
> Steve
>
> -----Original Message-----
> From: Brian Lawler [mailto:brian@tribenetwork.com]
> Sent: 17 September 2003 13:54
> To: Turbine Users List
> Subject: Re: Velocity newbie question
>
>
> Steve-
>
> You can make a base class for the 2 screens and have both of your
> actual screen classes extend it:
>
> BaseDetails - has all of your common code.
>
> ShowDetails extends BaseDetails
> EditDetails extends BaseDetails
>
> Just be sure to call super.doPerform() from you child classes.
>
> -Brian
>
> On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:
>
>> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
>> Headlong into building a complex application with a large data model.
>>
>> I have been constructing screens using Velocity for both displaying
>> Table data and for editing it. Trouble is, I seem to create Action
>> Classes for both display and for edit that are both exactly the same.
>>
>> E.g. ShowDetails.java for ShowDetails.vm
>> And  EditDetails.java for EditDetails.vm (then goes to
>> UpdateDetails.java)
>>
>> In this case the code for the two java classes (Show, Edit) is exactly
>
>> the same except with different class names.
>>
>> Is there anyway of re-using the same class for different velocity
>> templates? Have I missed something simple?
>>
>> Thanks,
>>
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Brian,

Thank you. That would be the correct OO way of doing it (Why didn't I
think of that?).
Slight drawback is that I've got three files now (although one with
actual code),
And I was rather trying to get to one file.

Thanks,

Steve

-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 13:54
To: Turbine Users List
Subject: Re: Velocity newbie question


Steve-

You can make a base class for the 2 screens and have both of your 
actual screen classes extend it:

BaseDetails - has all of your common code.

ShowDetails extends BaseDetails
EditDetails extends BaseDetails

Just be sure to call super.doPerform() from you child classes.

-Brian

On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone 
> Headlong into building a complex application with a large data model.
>
> I have been constructing screens using Velocity for both displaying 
> Table data and for editing it. Trouble is, I seem to create Action 
> Classes for both display and for edit that are both exactly the same.
>
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
>
> In this case the code for the two java classes (Show, Edit) is exactly

> the same except with different class names.
>
> Is there anyway of re-using the same class for different velocity 
> templates? Have I missed something simple?
>
> Thanks,
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Velocity newbie question

Posted by cctech <cc...@cityarchitect.co.uk>.
Brian,

Thank you. That would be the correct OO way of doing it (Why didn't I
think of that?).
Slight drawback is that I've got three files now (although one with
actual code),
And I was rather trying to get to one file.

Thanks,

Steve

-----Original Message-----
From: Brian Lawler [mailto:brian@tribenetwork.com] 
Sent: 17 September 2003 13:54
To: Turbine Users List
Subject: Re: Velocity newbie question


Steve-

You can make a base class for the 2 screens and have both of your 
actual screen classes extend it:

BaseDetails - has all of your common code.

ShowDetails extends BaseDetails
EditDetails extends BaseDetails

Just be sure to call super.doPerform() from you child classes.

-Brian

On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone 
> Headlong into building a complex application with a large data model.
>
> I have been constructing screens using Velocity for both displaying 
> Table data and for editing it. Trouble is, I seem to create Action 
> Classes for both display and for edit that are both exactly the same.
>
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
>
> In this case the code for the two java classes (Show, Edit) is exactly

> the same except with different class names.
>
> Is there anyway of re-using the same class for different velocity 
> templates? Have I missed something simple?
>
> Thanks,
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity newbie question

Posted by Brian Lawler <br...@tribenetwork.com>.
Steve-

You can make a base class for the 2 screens and have both of your 
actual screen classes extend it:

BaseDetails - has all of your common code.

ShowDetails extends BaseDetails
EditDetails extends BaseDetails

Just be sure to call super.doPerform() from you child classes.

-Brian

On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> Headlong into building a complex application with a large data model.
>
> I have been constructing screens using Velocity for both displaying
> Table data and for editing it. Trouble is, I seem to create Action
> Classes for both display and for edit that are both exactly the same.
>
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
>
> In this case the code for the two java classes (Show, Edit) is exactly
> the same except with different class names.
>
> Is there anyway of re-using the same class for different velocity
> templates?
> Have I missed something simple?
>
> Thanks,
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity newbie question

Posted by Jeffery Painter <pa...@kiasoft.com>.
I typically build one screen for display/edit/new and try to organize the 
screens based on the data.

example, say you have a race track with horses and jockies

	/templates/app/screens/
	|
	\-/templates/app/screens/horse
	|
	\-/templates/app/screens/jockey

and each directory has a List.vm and an Edit.vm
List.vm will just be a display for all in list form leading you to Edit.vm 
for Showing details and or edit with other functions

I usually send a parameter called mode=
if Edit.vm recieves no data parameter, it enters Insert mode, you could 
send it a mode=display or mode=edit with the key to load the data

you access these screens with the $link.setPage("horse,List.vm") as such. 
Remember to use comma's instead of slashes. Slashes signify data 
parameters.

so you could use 

$link.setPage("horse,Edit.vm").addPathInfo("mode", "edit").addPathInfo("horseId", $entry.horseId)

and this would lead you to edit mode with the horse id passed along

you need to setup your screen class in the same directory format as your 
templates.

	org.myapp.modules.screens.horse.List
	org.myapp.modules.screens.horse.Edit

	org.myapp.modules.screens.jockey.List
	org.myapp.modules.screens.jockey.Edit

and deal with the mode parameter with a case statement or if structure to 
enter the correct mode.

you can test for Edit or New with #if ( $entry ) in your vm page. one 
other trick is that you use just one set of input fields using 

  <input type="text" name="horseName" value="$!entry.HorseName">

The bang after the $ signifies to velocity that if the object does not 
exist, it will ignore the entry and thus leave you with value="" which is 
what you would expect for a new entry.

On Wed, 17 Sep 2003, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> Headlong into building a complex application with a large data model.
> 
> I have been constructing screens using Velocity for both displaying
> Table data and for editing it. Trouble is, I seem to create Action
> Classes for both display and for edit that are both exactly the same.

I don't think you meant multiple action classes... you should really only 
need one action class for HorseSQL.java and JockeySQL.java

you can set multiple clauses within each action class

	org.myapp.modules.actions.HorseSQL

You want to follow the info on using action classes on the turbine site. 
Action classes should really be thought of as anything that needs to 
modify your data. doUpdate() doDelete() doAnything()

Which would be called from your form as eventSubmit_doUpdate 
eventSubmit_doDelete and eventSubmit_doAnything

screen classes should be thought of as presenting your data (which may 
also be nothing in the case of New entry)

> 
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
> 
> In this case the code for the two java classes (Show, Edit) is exactly
> the same except with different class names.
> 
> Is there anyway of re-using the same class for different velocity
> templates?
> Have I missed something simple?
> 
> Thanks,
> Steve

Jeffery Painter


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity newbie question

Posted by Jeffery Painter <pa...@kiasoft.com>.
I typically build one screen for display/edit/new and try to organize the 
screens based on the data.

example, say you have a race track with horses and jockies

	/templates/app/screens/
	|
	\-/templates/app/screens/horse
	|
	\-/templates/app/screens/jockey

and each directory has a List.vm and an Edit.vm
List.vm will just be a display for all in list form leading you to Edit.vm 
for Showing details and or edit with other functions

I usually send a parameter called mode=
if Edit.vm recieves no data parameter, it enters Insert mode, you could 
send it a mode=display or mode=edit with the key to load the data

you access these screens with the $link.setPage("horse,List.vm") as such. 
Remember to use comma's instead of slashes. Slashes signify data 
parameters.

so you could use 

$link.setPage("horse,Edit.vm").addPathInfo("mode", "edit").addPathInfo("horseId", $entry.horseId)

and this would lead you to edit mode with the horse id passed along

you need to setup your screen class in the same directory format as your 
templates.

	org.myapp.modules.screens.horse.List
	org.myapp.modules.screens.horse.Edit

	org.myapp.modules.screens.jockey.List
	org.myapp.modules.screens.jockey.Edit

and deal with the mode parameter with a case statement or if structure to 
enter the correct mode.

you can test for Edit or New with #if ( $entry ) in your vm page. one 
other trick is that you use just one set of input fields using 

  <input type="text" name="horseName" value="$!entry.HorseName">

The bang after the $ signifies to velocity that if the object does not 
exist, it will ignore the entry and thus leave you with value="" which is 
what you would expect for a new entry.

On Wed, 17 Sep 2003, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> Headlong into building a complex application with a large data model.
> 
> I have been constructing screens using Velocity for both displaying
> Table data and for editing it. Trouble is, I seem to create Action
> Classes for both display and for edit that are both exactly the same.

I don't think you meant multiple action classes... you should really only 
need one action class for HorseSQL.java and JockeySQL.java

you can set multiple clauses within each action class

	org.myapp.modules.actions.HorseSQL

You want to follow the info on using action classes on the turbine site. 
Action classes should really be thought of as anything that needs to 
modify your data. doUpdate() doDelete() doAnything()

Which would be called from your form as eventSubmit_doUpdate 
eventSubmit_doDelete and eventSubmit_doAnything

screen classes should be thought of as presenting your data (which may 
also be nothing in the case of New entry)

> 
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
> 
> In this case the code for the two java classes (Show, Edit) is exactly
> the same except with different class names.
> 
> Is there anyway of re-using the same class for different velocity
> templates?
> Have I missed something simple?
> 
> Thanks,
> Steve

Jeffery Painter


Re: Velocity newbie question

Posted by Brian Lawler <br...@tribenetwork.com>.
Steve-

You can make a base class for the 2 screens and have both of your 
actual screen classes extend it:

BaseDetails - has all of your common code.

ShowDetails extends BaseDetails
EditDetails extends BaseDetails

Just be sure to call super.doPerform() from you child classes.

-Brian

On Wednesday, September 17, 2003, at 04:43  AM, cctech wrote:

> I'll fairly new to Turbine and Velocity, but nonetheless, I have gone
> Headlong into building a complex application with a large data model.
>
> I have been constructing screens using Velocity for both displaying
> Table data and for editing it. Trouble is, I seem to create Action
> Classes for both display and for edit that are both exactly the same.
>
> E.g. ShowDetails.java for ShowDetails.vm
> And  EditDetails.java for EditDetails.vm (then goes to
> UpdateDetails.java)
>
> In this case the code for the two java classes (Show, Edit) is exactly
> the same except with different class names.
>
> Is there anyway of re-using the same class for different velocity
> templates?
> Have I missed something simple?
>
> Thanks,
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>