You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Ludwig Magnusson <lu...@greenstreetconsulting.se> on 2009/01/27 10:50:33 UTC

Question about extending the screen object

Hi!

On my site I have several screens that I want a certain specific java-coded
behavior for. I see in the documentation that the way to do this is to
create a Super-Screen class and let all my other screens extend that one.
However, if I don't want to implement any other behavior in the screens this
means that I will have several java classes with an empty body, all they do
is extend my Super-Screen. 

Is this the way to do it or is there any way around this so I do not need to
create one class for each template?

 

Or rather, can FooTemplate.vm execute the code in BarClass.class?

/Ludwig


RE: Question about extending the screen object

Posted by Ludwig Magnusson <lu...@greenstreetconsulting.se>.
This was exactly the answer I was looking for. =)
Thank you very much
/Ludwig

-----Original Message-----
From: Juergen Hoffmann [mailto:hoffmann@apache.org] 
Sent: den 28 januari 2009 11:40
To: 'Turbine Users List'
Subject: AW: Question about extending the screen object

Hi Ludwig,

why do you not create to paths?

your.application.modules.screens.alpha.Default.class and
your.application.modules.screens.beta.Default.class

then under src/webapp/templates/screens/alpha you create A.vm, B.vm and C.vm
and under src/webapp/templates/screens/beta you create D.vm, E.vm and F.vm

If you have Functionality you need in both screen classes you go ahead and
create a your.application.modules.screens.Default.class and let
alpha.Default.class and beta.Default.class extend from that.

Will that solve your problems?

Kind regards

Juergen

> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Mittwoch, 28. Januar 2009 10:45
> An: 'Turbine Users List'
> Betreff: RE: Question about extending the screen object
> 
> I probably wasn't clear enough...
> 
> Let's say I have screens A, B and C and I want them to implement
> behavior
> alpha.
> I also have screens D, E and F and I want them to implement behavior
> beta.
> Now, I could create two abstract java screen classes called alpha and
> beta.
> Then I create java classes A - F and I let them extend alpha and beta.
> This
> will work, however I will have 6 classes (A-F) that do not have a body.
> They
> will all look like this:
> 
> public class A extends Alpha {
> 
> }
> 
> public abstract class Alpha extends VelocityScreen {
> 
> 	//Here there will actually be code
> 
> }
> 
> My question is:
> Is this the only way to execute the code in Alpha when a request for
> A.vm is
> made?
> The only issue here is that I might end up with 20 or something classes
> that
> look like the A class, and I wonder if that is really necessary.
> /Ludwig
> 
> -----Original Message-----
> From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> Sent: den 27 januari 2009 15:15
> To: 'Turbine Users List'
> Subject: AW: Question about extending the screen object
> 
> Hi Ludwig,
> 
> extend from your Default Screen and overwrite the methods you would
> like to
> change...
> 
> Did I get you wrong?
> 
> Kind regards
> 
> Juergen
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > Gesendet: Dienstag, 27. Januar 2009 14:20
> > An: 'Turbine Users List'
> > Betreff: RE: Question about extending the screen object
> >
> > Allright I think that will solve my problems for now, however what if
> I
> > want
> > two sets of screens that have different behavior? Is there a solution
> > for
> > that?
> > /Ludwig
> >
> > -----Original Message-----
> > From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> > Sent: den 27 januari 2009 11:53
> > To: 'Turbine Users List'
> > Subject: AW: Question about extending the screen object
> >
> > Hi Ludwig,
> >
> > create a Default.class Turbine will look for it if it cannot find a
> > screen
> > Class for a specific Template.
> >
> > It looks for <Package1>.<subpackage>.<TemplateName>.class
> > Then for <Package1>.<subpackage>.Default.class
> > Then for <Package1>.Default.class
> >
> > And so on.
> >
> > I hope this made it clear
> >
> > Kind regards
> >
> > Juergen
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > > Gesendet: Dienstag, 27. Januar 2009 10:51
> > > An: 'Turbine Users List'
> > > Betreff: Question about extending the screen object
> > >
> > > Hi!
> > >
> > > On my site I have several screens that I want a certain specific
> > java-
> > > coded
> > > behavior for. I see in the documentation that the way to do this is
> > to
> > > create a Super-Screen class and let all my other screens extend
> that
> > > one.
> > > However, if I don't want to implement any other behavior in the
> > screens
> > > this
> > > means that I will have several java classes with an empty body, all
> > > they do
> > > is extend my Super-Screen.
> > >
> > > Is this the way to do it or is there any way around this so I do
> not
> > > need to
> > > create one class for each template?
> > >
> > >
> > >
> > > Or rather, can FooTemplate.vm execute the code in BarClass.class?
> > >
> > > /Ludwig
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> > For additional commands, e-mail: user-help@turbine.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> > For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org



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


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


AW: Question about extending the screen object

Posted by Juergen Hoffmann <ho...@apache.org>.
Hi Ludwig,

why do you not create to paths?

your.application.modules.screens.alpha.Default.class and
your.application.modules.screens.beta.Default.class

then under src/webapp/templates/screens/alpha you create A.vm, B.vm and C.vm
and under src/webapp/templates/screens/beta you create D.vm, E.vm and F.vm

If you have Functionality you need in both screen classes you go ahead and
create a your.application.modules.screens.Default.class and let
alpha.Default.class and beta.Default.class extend from that.

Will that solve your problems?

Kind regards

Juergen

> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Mittwoch, 28. Januar 2009 10:45
> An: 'Turbine Users List'
> Betreff: RE: Question about extending the screen object
> 
> I probably wasn't clear enough...
> 
> Let's say I have screens A, B and C and I want them to implement
> behavior
> alpha.
> I also have screens D, E and F and I want them to implement behavior
> beta.
> Now, I could create two abstract java screen classes called alpha and
> beta.
> Then I create java classes A - F and I let them extend alpha and beta.
> This
> will work, however I will have 6 classes (A-F) that do not have a body.
> They
> will all look like this:
> 
> public class A extends Alpha {
> 
> }
> 
> public abstract class Alpha extends VelocityScreen {
> 
> 	//Here there will actually be code
> 
> }
> 
> My question is:
> Is this the only way to execute the code in Alpha when a request for
> A.vm is
> made?
> The only issue here is that I might end up with 20 or something classes
> that
> look like the A class, and I wonder if that is really necessary.
> /Ludwig
> 
> -----Original Message-----
> From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> Sent: den 27 januari 2009 15:15
> To: 'Turbine Users List'
> Subject: AW: Question about extending the screen object
> 
> Hi Ludwig,
> 
> extend from your Default Screen and overwrite the methods you would
> like to
> change...
> 
> Did I get you wrong?
> 
> Kind regards
> 
> Juergen
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > Gesendet: Dienstag, 27. Januar 2009 14:20
> > An: 'Turbine Users List'
> > Betreff: RE: Question about extending the screen object
> >
> > Allright I think that will solve my problems for now, however what if
> I
> > want
> > two sets of screens that have different behavior? Is there a solution
> > for
> > that?
> > /Ludwig
> >
> > -----Original Message-----
> > From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> > Sent: den 27 januari 2009 11:53
> > To: 'Turbine Users List'
> > Subject: AW: Question about extending the screen object
> >
> > Hi Ludwig,
> >
> > create a Default.class Turbine will look for it if it cannot find a
> > screen
> > Class for a specific Template.
> >
> > It looks for <Package1>.<subpackage>.<TemplateName>.class
> > Then for <Package1>.<subpackage>.Default.class
> > Then for <Package1>.Default.class
> >
> > And so on.
> >
> > I hope this made it clear
> >
> > Kind regards
> >
> > Juergen
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > > Gesendet: Dienstag, 27. Januar 2009 10:51
> > > An: 'Turbine Users List'
> > > Betreff: Question about extending the screen object
> > >
> > > Hi!
> > >
> > > On my site I have several screens that I want a certain specific
> > java-
> > > coded
> > > behavior for. I see in the documentation that the way to do this is
> > to
> > > create a Super-Screen class and let all my other screens extend
> that
> > > one.
> > > However, if I don't want to implement any other behavior in the
> > screens
> > > this
> > > means that I will have several java classes with an empty body, all
> > > they do
> > > is extend my Super-Screen.
> > >
> > > Is this the way to do it or is there any way around this so I do
> not
> > > need to
> > > create one class for each template?
> > >
> > >
> > >
> > > Or rather, can FooTemplate.vm execute the code in BarClass.class?
> > >
> > > /Ludwig
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> > For additional commands, e-mail: user-help@turbine.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> > For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org



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


RE: Question about extending the screen object

Posted by Ludwig Magnusson <lu...@greenstreetconsulting.se>.
I probably wasn't clear enough...

Let's say I have screens A, B and C and I want them to implement behavior
alpha.
I also have screens D, E and F and I want them to implement behavior beta.
Now, I could create two abstract java screen classes called alpha and beta.
Then I create java classes A - F and I let them extend alpha and beta. This
will work, however I will have 6 classes (A-F) that do not have a body. They
will all look like this:

public class A extends Alpha {

}

public abstract class Alpha extends VelocityScreen {

	//Here there will actually be code

}

My question is:
Is this the only way to execute the code in Alpha when a request for A.vm is
made?
The only issue here is that I might end up with 20 or something classes that
look like the A class, and I wonder if that is really necessary.
/Ludwig

-----Original Message-----
From: Juergen Hoffmann [mailto:hoffmann@apache.org] 
Sent: den 27 januari 2009 15:15
To: 'Turbine Users List'
Subject: AW: Question about extending the screen object

Hi Ludwig,

extend from your Default Screen and overwrite the methods you would like to
change...

Did I get you wrong?

Kind regards

Juergen 
 
> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Dienstag, 27. Januar 2009 14:20
> An: 'Turbine Users List'
> Betreff: RE: Question about extending the screen object
> 
> Allright I think that will solve my problems for now, however what if I
> want
> two sets of screens that have different behavior? Is there a solution
> for
> that?
> /Ludwig
> 
> -----Original Message-----
> From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> Sent: den 27 januari 2009 11:53
> To: 'Turbine Users List'
> Subject: AW: Question about extending the screen object
> 
> Hi Ludwig,
> 
> create a Default.class Turbine will look for it if it cannot find a
> screen
> Class for a specific Template.
> 
> It looks for <Package1>.<subpackage>.<TemplateName>.class
> Then for <Package1>.<subpackage>.Default.class
> Then for <Package1>.Default.class
> 
> And so on.
> 
> I hope this made it clear
> 
> Kind regards
> 
> Juergen
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > Gesendet: Dienstag, 27. Januar 2009 10:51
> > An: 'Turbine Users List'
> > Betreff: Question about extending the screen object
> >
> > Hi!
> >
> > On my site I have several screens that I want a certain specific
> java-
> > coded
> > behavior for. I see in the documentation that the way to do this is
> to
> > create a Super-Screen class and let all my other screens extend that
> > one.
> > However, if I don't want to implement any other behavior in the
> screens
> > this
> > means that I will have several java classes with an empty body, all
> > they do
> > is extend my Super-Screen.
> >
> > Is this the way to do it or is there any way around this so I do not
> > need to
> > create one class for each template?
> >
> >
> >
> > Or rather, can FooTemplate.vm execute the code in BarClass.class?
> >
> > /Ludwig
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org



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


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


AW: Question about extending the screen object

Posted by Juergen Hoffmann <ho...@apache.org>.
Hi Ludwig,

extend from your Default Screen and overwrite the methods you would like to
change...

Did I get you wrong?

Kind regards

Juergen 
 
> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Dienstag, 27. Januar 2009 14:20
> An: 'Turbine Users List'
> Betreff: RE: Question about extending the screen object
> 
> Allright I think that will solve my problems for now, however what if I
> want
> two sets of screens that have different behavior? Is there a solution
> for
> that?
> /Ludwig
> 
> -----Original Message-----
> From: Juergen Hoffmann [mailto:hoffmann@apache.org]
> Sent: den 27 januari 2009 11:53
> To: 'Turbine Users List'
> Subject: AW: Question about extending the screen object
> 
> Hi Ludwig,
> 
> create a Default.class Turbine will look for it if it cannot find a
> screen
> Class for a specific Template.
> 
> It looks for <Package1>.<subpackage>.<TemplateName>.class
> Then for <Package1>.<subpackage>.Default.class
> Then for <Package1>.Default.class
> 
> And so on.
> 
> I hope this made it clear
> 
> Kind regards
> 
> Juergen
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> > Gesendet: Dienstag, 27. Januar 2009 10:51
> > An: 'Turbine Users List'
> > Betreff: Question about extending the screen object
> >
> > Hi!
> >
> > On my site I have several screens that I want a certain specific
> java-
> > coded
> > behavior for. I see in the documentation that the way to do this is
> to
> > create a Super-Screen class and let all my other screens extend that
> > one.
> > However, if I don't want to implement any other behavior in the
> screens
> > this
> > means that I will have several java classes with an empty body, all
> > they do
> > is extend my Super-Screen.
> >
> > Is this the way to do it or is there any way around this so I do not
> > need to
> > create one class for each template?
> >
> >
> >
> > Or rather, can FooTemplate.vm execute the code in BarClass.class?
> >
> > /Ludwig
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org



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


RE: Question about extending the screen object

Posted by Ludwig Magnusson <lu...@greenstreetconsulting.se>.
Allright I think that will solve my problems for now, however what if I want
two sets of screens that have different behavior? Is there a solution for
that?
/Ludwig

-----Original Message-----
From: Juergen Hoffmann [mailto:hoffmann@apache.org] 
Sent: den 27 januari 2009 11:53
To: 'Turbine Users List'
Subject: AW: Question about extending the screen object

Hi Ludwig,

create a Default.class Turbine will look for it if it cannot find a screen
Class for a specific Template.

It looks for <Package1>.<subpackage>.<TemplateName>.class
Then for <Package1>.<subpackage>.Default.class
Then for <Package1>.Default.class

And so on. 

I hope this made it clear

Kind regards

Juergen

> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Dienstag, 27. Januar 2009 10:51
> An: 'Turbine Users List'
> Betreff: Question about extending the screen object
> 
> Hi!
> 
> On my site I have several screens that I want a certain specific java-
> coded
> behavior for. I see in the documentation that the way to do this is to
> create a Super-Screen class and let all my other screens extend that
> one.
> However, if I don't want to implement any other behavior in the screens
> this
> means that I will have several java classes with an empty body, all
> they do
> is extend my Super-Screen.
> 
> Is this the way to do it or is there any way around this so I do not
> need to
> create one class for each template?
> 
> 
> 
> Or rather, can FooTemplate.vm execute the code in BarClass.class?
> 
> /Ludwig



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


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


AW: Question about extending the screen object

Posted by Juergen Hoffmann <ho...@apache.org>.
Hi Ludwig,

create a Default.class Turbine will look for it if it cannot find a screen
Class for a specific Template.

It looks for <Package1>.<subpackage>.<TemplateName>.class
Then for <Package1>.<subpackage>.Default.class
Then for <Package1>.Default.class

And so on. 

I hope this made it clear

Kind regards

Juergen

> -----Ursprüngliche Nachricht-----
> Von: Ludwig Magnusson [mailto:ludwig@greenstreetconsulting.se]
> Gesendet: Dienstag, 27. Januar 2009 10:51
> An: 'Turbine Users List'
> Betreff: Question about extending the screen object
> 
> Hi!
> 
> On my site I have several screens that I want a certain specific java-
> coded
> behavior for. I see in the documentation that the way to do this is to
> create a Super-Screen class and let all my other screens extend that
> one.
> However, if I don't want to implement any other behavior in the screens
> this
> means that I will have several java classes with an empty body, all
> they do
> is extend my Super-Screen.
> 
> Is this the way to do it or is there any way around this so I do not
> need to
> create one class for each template?
> 
> 
> 
> Or rather, can FooTemplate.vm execute the code in BarClass.class?
> 
> /Ludwig



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