Re: T5: Best practice for rendering a dynamic component

2008-12-09 Thread mad7777

Hi,

I need to translate a WebObjects WOSwitchComponent to something equivalent
in T5.

I've looked at the BeanEditForm source, but I'm afraid I don't understand
how this is working.  The relevant bit seems to be:



... but maybe the key is actually somewhere in PropertyEditor?

When you say "put the components on another page", do you mean that I would
need to list every type of component explicitly?  Also, I'm not clear on
what you mean by, "choose the component from that page".

Ideally, I'd like to have something really simple, like this:



I appreciate that templates are supposed to be statically typed, but what
can I do if I don't have the name of the component until runtime?

Thanks,
Marc


Howard Lewis Ship wrote:
> 
> This is very easy in Tapestry; just put the components on another page,
> inject the page, and choose the component from that page.
> 
> This same approach is what drives BeanEditForm and Grid: the ability to
> choose components or blocks to render at any particular time.
> 
> On 5/23/07, Daniel Tabuenca <[EMAIL PROTECTED]> wrote:
>>
>> What I'm trying to do is related to this. It would be very useful to
>> be able to get components from some pool (just like pages). Then I
>> could dynamiclally render any component dynamically on any page using
>> the Delegator. This is useful in dynamic pages where the page
>> structure itself is highly dynamic. Each delegator can then
>> dynamically ask for the component it should render. I know you could
>> do this by by listing all the possible @Components in each page class,
>> but this gets very ugly if you have lots of possible components to
>> choose from but you only use one. Is there anyway to do this or
>> simulate this?
>>
>> On 5/23/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
>> > Absolutely.  You can put it inside a  to keep it from
>> rendering
>> > normally.
>> >
>> > On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>> > >
>> > > Hrm...
>> > >
>> > > I have the code setup as listed below, but I'm getting:
>> > >
>> > > org.apache.tapestry.ioc.internal.util.TapestryException: Component
>> > > org.foo.pages.Start does not contain an embedded component with id
>> > > 'apple'.
>> > >
>> > > Does it expect me to have a  tag in the page even though
>> I'm
>> > > delegating the rendering of it?
>> > >
>> > > -Original Message-
>> > > From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
>> > > Sent: Wednesday, May 23, 2007 1:41 PM
>> > > To: Tapestry users
>> > > Subject: Re: T5: Best practice for rendering a dynamic component
>> > >
>> > > The Delegate component is what you need:
>> > >
>> > > 
>> > >
>> > > @Component
>> > > private Apple apple;
>> > >
>> > > @Component
>> > > private Banana banana;
>> > >
>> > > public Object getFruit() {
>> > >   if ( ... ) return apple;
>> > >
>> > >   return banana;
>> > > }
>> > >
>> > > With Tapestry, the construction of pages is static, fixed,
>> unchanging,
>> > > much like the construction of your classes.  However, Tapestry is
>> quite
>> > > dynamic when it comes to rendering, you can choose which objects
>> render
>> > > at what time in the rendering process, which ends up being about the
>> > > same thing.
>> > >
>> > >
>> > > On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>> > > >
>> > > > Hello all,
>> > > >
>> > > > I'm interested in rendering a component template that I can
>> > > > selectively declare.  For example, I'd like to do something like
>> the
>> > > following:
>> > > >
>> > > > <<<<>>>>
>> > > >
>> > > > public class MyPage {
>> > > >
>> > > > @Component
>> > > > private Fruit myFruit;
>> > > >
>> > > > Object onAction(String switchValue) {
>> > > > if(switchValue.equals("apple") {
>> > > > myFruit = new Apple();
>> > > > } else {
>&

Re: T5: Best practice for rendering a dynamic component

2007-05-25 Thread Howard Lewis Ship

In fact, BeanEditForm and Grid suffer from the same problem, and a fix will
be forthcoming.

Basically, there will be a configuration point for contributing page names,
and matching them up to (in BeanEditForm/Grid) various property types.

The same pattern can hold; define new pages, contribute a LibraryMapping
into the configuration for ComponentClassResolver service, contribute
whatever into a service you write to vend out the correct Blocks.

On 5/24/07, Ivan Dubrov <[EMAIL PROTECTED]> wrote:


Howard Lewis Ship wrote:
> This is very easy in Tapestry; just put the components on another page,
> inject the page, and choose the component from that page.
And how to deal with actionlink's inside the component/block from
another page? All actions will go to the page the component/block
belongs to, not to the page that rendered the component/block.

Of course, I could place all required components on first page inside a
block, as described earlier, but in this case to add a new fruit type
(for example, "orange") I have to modify Page1 template. And I want the
ability to add new view type ("lemon", "grapefruit") by adding
additional .jar inside my application.

Currently it looks like the following: I have several pages like
ViewLemon, ViewGrapeFruit with required blocks inside them and page
ViewFruit. The ViewFruit page determines the fruit type, requests the
certain page from the RequestPageCache service (although it's internal,
so it is not good idea to use it), retrieves block from the page and
renders it. I could add new fruit types dynamically (by adding
additional .jar file to WEB-INF/lib with new fruit type and View page). It works OK, besides the actionlink's inside the block. Do
you have any idea how can I deal with this situation? I need the ability
to add new "fruit types" (application plugins) without modification of
page templates.
>
> This same approach is what drives BeanEditForm and Grid: the ability to
> choose components or blocks to render at any particular time.
>


--
WBR,
Ivan S. Dubrov







--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com


Re: T5: Best practice for rendering a dynamic component

2007-05-24 Thread Ivan Dubrov
Howard Lewis Ship wrote:
> This is very easy in Tapestry; just put the components on another page,
> inject the page, and choose the component from that page.
And how to deal with actionlink's inside the component/block from
another page? All actions will go to the page the component/block
belongs to, not to the page that rendered the component/block.

Of course, I could place all required components on first page inside a
block, as described earlier, but in this case to add a new fruit type
(for example, "orange") I have to modify Page1 template. And I want the
ability to add new view type ("lemon", "grapefruit") by adding
additional .jar inside my application.

Currently it looks like the following: I have several pages like
ViewLemon, ViewGrapeFruit with required blocks inside them and page
ViewFruit. The ViewFruit page determines the fruit type, requests the
certain page from the RequestPageCache service (although it's internal,
so it is not good idea to use it), retrieves block from the page and
renders it. I could add new fruit types dynamically (by adding
additional .jar file to WEB-INF/lib with new fruit type and View page). It works OK, besides the actionlink's inside the block. Do
you have any idea how can I deal with this situation? I need the ability
to add new "fruit types" (application plugins) without modification of
page templates.
>
> This same approach is what drives BeanEditForm and Grid: the ability to
> choose components or blocks to render at any particular time.
>


-- 
WBR,
Ivan S. Dubrov




signature.asc
Description: OpenPGP digital signature


Re: T5: Best practice for rendering a dynamic component

2007-05-24 Thread Howard Lewis Ship

Or, alternately:

HTML:
  

  
  
  
  

Java:

  private boolean displayApple;  //set this however you want to
  private boolean displayBanana; //set this however you want to

  @Component
  private Apple apple;

  @Component
  private Banana banana;

  public Object getTypeOfFruit() {
if (displayApple) {
return apple;
} else if(displayBanana) {
return banana;
}
return null;
  }

Anonymous blocks are for "keeping components out of play."


On 5/24/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:


Thanks Howard!

For the community, the final "code-alization" of this discussion ends up
being:

HTML:










Java:

private boolean displayApple;  //set this however you want to
private boolean displayBanana; //set this however you want to

@Inject
private Block appleBlock;

@Inject
private Block bananaBlock;

@Component
private Apple apple;

@Component
private Banana banana;

public Object getTypeOfFruit() {
  if (displayApple) {
  return appleBlock;
  } else if(displayBanana) {
  return bananaBlock;
  }
  return null;
}


-Original Message-
From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 23, 2007 4:08 PM
To: Tapestry users
Subject: Re: T5: Best practice for rendering a dynamic component

Absolutely.  You can put it inside a  to keep it from rendering
normally.

On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>
> Hrm...
>
> I have the code setup as listed below, but I'm getting:
>
> org.apache.tapestry.ioc.internal.util.TapestryException: Component
> org.foo.pages.Start does not contain an embedded component with id
> 'apple'.
>
> Does it expect me to have a  tag in the page even though I'm

> delegating the rendering of it?
>
> -Original Message-
> From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 23, 2007 1:41 PM
> To: Tapestry users
> Subject: Re: T5: Best practice for rendering a dynamic component
>
> The Delegate component is what you need:
>
> 
>
> @Component
> private Apple apple;
>
> @Component
> private Banana banana;
>
> public Object getFruit() {
>   if ( ... ) return apple;
>
>   return banana;
> }
>
> With Tapestry, the construction of pages is static, fixed, unchanging,

> much like the construction of your classes.  However, Tapestry is
> quite dynamic when it comes to rendering, you can choose which objects

> render at what time in the rendering process, which ends up being
> about the same thing.
>
>
> On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> >
> > I'm interested in rendering a component template that I can
> > selectively declare.  For example, I'd like to do something like the
> following:
> >
> > <<<<>>>>
> >
> > public class MyPage {
> >
> > @Component
> > private Fruit myFruit;
> >
> > Object onAction(String switchValue) {
> > if(switchValue.equals("apple") {
> > myFruit = new Apple();
> > } else {
> > myFruit = new Banana();
> > }
> > }
> > }
> >
> > <<<<>>>>
> >
> > 
> >
> > Make me an Apple!
> >
> >
> >
> > I'll save you from having to read the "Apple.html" and "Banana.html"
> > component templates.  :-)
> >
> > Anyway, I'm pretty sure it's not this easy, and I was wondering
> > what's
>
> > the "best practice" for accomplishing what I'm after.
> >
> > Thanks!
> >
> > Joel
> >
> > 
> > - To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
> Apache Tapestry Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support and project work.
> http://howardlewisship.com
>
> -

RE: T5: Best practice for rendering a dynamic component

2007-05-24 Thread Joel Wiegman
Thanks Howard!

For the community, the final "code-alization" of this discussion ends up
being:

HTML:








 

Java:

private boolean displayApple;  //set this however you want to
private boolean displayBanana; //set this however you want to

@Inject
private Block appleBlock;

@Inject
private Block bananaBlock;

@Component
private Apple apple;

@Component
private Banana banana;

public Object getTypeOfFruit() {
  if (displayApple) {
  return appleBlock;
  } else if(displayBanana) {
  return bananaBlock;
  }
  return null;
}


-Original Message-
From: Howard Lewis Ship [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 23, 2007 4:08 PM
To: Tapestry users
Subject: Re: T5: Best practice for rendering a dynamic component

Absolutely.  You can put it inside a  to keep it from rendering
normally.

On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>
> Hrm...
>
> I have the code setup as listed below, but I'm getting:
>
> org.apache.tapestry.ioc.internal.util.TapestryException: Component 
> org.foo.pages.Start does not contain an embedded component with id 
> 'apple'.
>
> Does it expect me to have a  tag in the page even though I'm

> delegating the rendering of it?
>
> -Original Message-
> From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 23, 2007 1:41 PM
> To: Tapestry users
> Subject: Re: T5: Best practice for rendering a dynamic component
>
> The Delegate component is what you need:
>
> 
>
> @Component
> private Apple apple;
>
> @Component
> private Banana banana;
>
> public Object getFruit() {
>   if ( ... ) return apple;
>
>   return banana;
> }
>
> With Tapestry, the construction of pages is static, fixed, unchanging,

> much like the construction of your classes.  However, Tapestry is 
> quite dynamic when it comes to rendering, you can choose which objects

> render at what time in the rendering process, which ends up being 
> about the same thing.
>
>
> On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> >
> > I'm interested in rendering a component template that I can 
> > selectively declare.  For example, I'd like to do something like the
> following:
> >
> > <<<<>>>>
> >
> > public class MyPage {
> >
> > @Component
> > private Fruit myFruit;
> >
> > Object onAction(String switchValue) {
> > if(switchValue.equals("apple") {
> > myFruit = new Apple();
> > } else {
> > myFruit = new Banana();
> > }
> > }
> > }
> >
> > <<<<>>>>
> >
> > 
> >
> > Make me an Apple!
> >
> >
> >
> > I'll save you from having to read the "Apple.html" and "Banana.html"
> > component templates.  :-)
> >
> > Anyway, I'm pretty sure it's not this easy, and I was wondering 
> > what's
>
> > the "best practice" for accomplishing what I'm after.
> >
> > Thanks!
> >
> > Joel
> >
> > 
> > - To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, 
> Apache Tapestry Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support and project work.
> http://howardlewisship.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
Apache Tapestry Creator, Apache HiveMind

Professional Tapestry training, mentoring, support and project work.
http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Best practice for rendering a dynamic component

2007-05-23 Thread Howard Lewis Ship

This is very easy in Tapestry; just put the components on another page,
inject the page, and choose the component from that page.

This same approach is what drives BeanEditForm and Grid: the ability to
choose components or blocks to render at any particular time.

On 5/23/07, Daniel Tabuenca <[EMAIL PROTECTED]> wrote:


What I'm trying to do is related to this. It would be very useful to
be able to get components from some pool (just like pages). Then I
could dynamiclally render any component dynamically on any page using
the Delegator. This is useful in dynamic pages where the page
structure itself is highly dynamic. Each delegator can then
dynamically ask for the component it should render. I know you could
do this by by listing all the possible @Components in each page class,
but this gets very ugly if you have lots of possible components to
choose from but you only use one. Is there anyway to do this or
simulate this?

On 5/23/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
> Absolutely.  You can put it inside a  to keep it from rendering
> normally.
>
> On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
> >
> > Hrm...
> >
> > I have the code setup as listed below, but I'm getting:
> >
> > org.apache.tapestry.ioc.internal.util.TapestryException: Component
> > org.foo.pages.Start does not contain an embedded component with id
> > 'apple'.
> >
> > Does it expect me to have a  tag in the page even though I'm
> > delegating the rendering of it?
> >
> > -Original Message-
> > From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, May 23, 2007 1:41 PM
> > To: Tapestry users
> > Subject: Re: T5: Best practice for rendering a dynamic component
> >
> > The Delegate component is what you need:
> >
> > 
> >
> > @Component
> > private Apple apple;
> >
> > @Component
> > private Banana banana;
> >
> > public Object getFruit() {
> >   if ( ... ) return apple;
> >
> >   return banana;
> > }
> >
> > With Tapestry, the construction of pages is static, fixed, unchanging,
> > much like the construction of your classes.  However, Tapestry is
quite
> > dynamic when it comes to rendering, you can choose which objects
render
> > at what time in the rendering process, which ends up being about the
> > same thing.
> >
> >
> > On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
> > >
> > > Hello all,
> > >
> > > I'm interested in rendering a component template that I can
> > > selectively declare.  For example, I'd like to do something like the
> > following:
> > >
> > > <<<<>>>>
> > >
> > > public class MyPage {
> > >
> > > @Component
> > > private Fruit myFruit;
> > >
> > > Object onAction(String switchValue) {
> > > if(switchValue.equals("apple") {
> > > myFruit = new Apple();
> > > } else {
> > > myFruit = new Banana();
> > > }
> > > }
> > > }
> > >
> > > <<<<>>>>
> > >
> > > 
> > >
> > > Make me an Apple!
> > >
> > >
> > >
> > > I'll save you from having to read the "Apple.html" and "Banana.html"
> > > component templates.  :-)
> > >
> > > Anyway, I'm pretty sure it's not this easy, and I was wondering
what's
> >
> > > the "best practice" for accomplishing what I'm after.
> > >
> > > Thanks!
> > >
> > > Joel
> > >
> > >
-
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
> > Apache Tapestry Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support and project work.
> > http://howardlewisship.com
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com


Re: T5: Best practice for rendering a dynamic component

2007-05-23 Thread Daniel Tabuenca

What I'm trying to do is related to this. It would be very useful to
be able to get components from some pool (just like pages). Then I
could dynamiclally render any component dynamically on any page using
the Delegator. This is useful in dynamic pages where the page
structure itself is highly dynamic. Each delegator can then
dynamically ask for the component it should render. I know you could
do this by by listing all the possible @Components in each page class,
but this gets very ugly if you have lots of possible components to
choose from but you only use one. Is there anyway to do this or
simulate this?

On 5/23/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:

Absolutely.  You can put it inside a  to keep it from rendering
normally.

On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>
> Hrm...
>
> I have the code setup as listed below, but I'm getting:
>
> org.apache.tapestry.ioc.internal.util.TapestryException: Component
> org.foo.pages.Start does not contain an embedded component with id
> 'apple'.
>
> Does it expect me to have a  tag in the page even though I'm
> delegating the rendering of it?
>
> -Original Message-
> From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 23, 2007 1:41 PM
> To: Tapestry users
> Subject: Re: T5: Best practice for rendering a dynamic component
>
> The Delegate component is what you need:
>
> 
>
> @Component
> private Apple apple;
>
> @Component
> private Banana banana;
>
> public Object getFruit() {
>   if ( ... ) return apple;
>
>   return banana;
> }
>
> With Tapestry, the construction of pages is static, fixed, unchanging,
> much like the construction of your classes.  However, Tapestry is quite
> dynamic when it comes to rendering, you can choose which objects render
> at what time in the rendering process, which ends up being about the
> same thing.
>
>
> On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> >
> > I'm interested in rendering a component template that I can
> > selectively declare.  For example, I'd like to do something like the
> following:
> >
> > <<<<>>>>
> >
> > public class MyPage {
> >
> > @Component
> > private Fruit myFruit;
> >
> > Object onAction(String switchValue) {
> > if(switchValue.equals("apple") {
> > myFruit = new Apple();
> > } else {
> > myFruit = new Banana();
> > }
> > }
> > }
> >
> > <<<<>>>>
> >
> > 
> >
> > Make me an Apple!
> >
> >
> >
> > I'll save you from having to read the "Apple.html" and "Banana.html"
> > component templates.  :-)
> >
> > Anyway, I'm pretty sure it's not this easy, and I was wondering what's
>
> > the "best practice" for accomplishing what I'm after.
> >
> > Thanks!
> >
> > Joel
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
> Apache Tapestry Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support and project work.
> http://howardlewisship.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Best practice for rendering a dynamic component

2007-05-23 Thread Howard Lewis Ship

Absolutely.  You can put it inside a  to keep it from rendering
normally.

On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:


Hrm...

I have the code setup as listed below, but I'm getting:

org.apache.tapestry.ioc.internal.util.TapestryException: Component
org.foo.pages.Start does not contain an embedded component with id
'apple'.

Does it expect me to have a  tag in the page even though I'm
delegating the rendering of it?

-Original Message-
From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 23, 2007 1:41 PM
To: Tapestry users
Subject: Re: T5: Best practice for rendering a dynamic component

The Delegate component is what you need:



@Component
private Apple apple;

@Component
private Banana banana;

public Object getFruit() {
  if ( ... ) return apple;

  return banana;
}

With Tapestry, the construction of pages is static, fixed, unchanging,
much like the construction of your classes.  However, Tapestry is quite
dynamic when it comes to rendering, you can choose which objects render
at what time in the rendering process, which ends up being about the
same thing.


On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I'm interested in rendering a component template that I can
> selectively declare.  For example, I'd like to do something like the
following:
>
> <<<<>>>>
>
> public class MyPage {
>
> @Component
> private Fruit myFruit;
>
> Object onAction(String switchValue) {
> if(switchValue.equals("apple") {
> myFruit = new Apple();
> } else {
> myFruit = new Banana();
> }
> }
> }
>
> <<<<>>>>
>
> 
>
> Make me an Apple!
>
>
>
> I'll save you from having to read the "Apple.html" and "Banana.html"
> component templates.  :-)
>
> Anyway, I'm pretty sure it's not this easy, and I was wondering what's

> the "best practice" for accomplishing what I'm after.
>
> Thanks!
>
> Joel
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
Apache Tapestry Creator, Apache HiveMind

Professional Tapestry training, mentoring, support and project work.
http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com


RE: T5: Best practice for rendering a dynamic component

2007-05-23 Thread Joel Wiegman
Hrm...

I have the code setup as listed below, but I'm getting:

org.apache.tapestry.ioc.internal.util.TapestryException: Component
org.foo.pages.Start does not contain an embedded component with id
'apple'. 

Does it expect me to have a  tag in the page even though I'm
delegating the rendering of it?

-Original Message-
From: Howard Lewis Ship [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 23, 2007 1:41 PM
To: Tapestry users
Subject: Re: T5: Best practice for rendering a dynamic component

The Delegate component is what you need:



@Component
private Apple apple;

@Component
private Banana banana;

public Object getFruit() {
  if ( ... ) return apple;

  return banana;
}

With Tapestry, the construction of pages is static, fixed, unchanging,
much like the construction of your classes.  However, Tapestry is quite
dynamic when it comes to rendering, you can choose which objects render
at what time in the rendering process, which ends up being about the
same thing.


On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I'm interested in rendering a component template that I can 
> selectively declare.  For example, I'd like to do something like the
following:
>
> <<<<>>>>
>
> public class MyPage {
>
> @Component
> private Fruit myFruit;
>
> Object onAction(String switchValue) {
> if(switchValue.equals("apple") {
> myFruit = new Apple();
> } else {
> myFruit = new Banana();
> }
> }
> }
>
> <<<<>>>>
>
> 
>
> Make me an Apple!
>
>
>
> I'll save you from having to read the "Apple.html" and "Banana.html"
> component templates.  :-)
>
> Anyway, I'm pretty sure it's not this easy, and I was wondering what's

> the "best practice" for accomplishing what I'm after.
>
> Thanks!
>
> Joel
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
Apache Tapestry Creator, Apache HiveMind

Professional Tapestry training, mentoring, support and project work.
http://howardlewisship.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Best practice for rendering a dynamic component

2007-05-23 Thread Howard Lewis Ship

The Delegate component is what you need:



@Component
private Apple _apple;

@Component
private Banana _banana;

public Object getFruit() {
 if ( ... ) return _apple;

 return _banana;
}

With Tapestry, the construction of pages is static, fixed, unchanging, much
like the construction of your classes.  However, Tapestry is quite dynamic
when it comes to rendering, you can choose which objects render at what time
in the rendering process, which ends up being about the same thing.


On 5/23/07, Joel Wiegman <[EMAIL PROTECTED]> wrote:


Hello all,

I'm interested in rendering a component template that I can selectively
declare.  For example, I'd like to do something like the following:



public class MyPage {

@Component
private Fruit myFruit;

Object onAction(String switchValue) {
if(switchValue.equals("apple") {
myFruit = new Apple();
} else {
myFruit = new Banana();
}
}
}





Make me an Apple!



I'll save you from having to read the "Apple.html" and "Banana.html"
component templates.  :-)

Anyway, I'm pretty sure it's not this easy, and I was wondering what's
the "best practice" for accomplishing what I'm after.

Thanks!

Joel

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com