You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by An...@leoni.com on 2005/06/10 16:33:58 UTC

referencing an application component from inside a library

I am trying to bundle a Border component into a library. That way, the 
cororate look and feel would be easily plugable in future projects.

Unfortunatly the component in the library needs to reference a component 
outside the library in the application namespace. How can I reference 
this component?

Andy Pahne


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


Re: referencing an application component from inside a library

Posted by Andreas Andreou <an...@di.uoa.gr>.
andyman,
perhaps you missed MindBridge's reply which solves your problem


 wrote:

>The Border component in the library needs to render the future
>applications main Menu. I don't know about future application's menus,
>so I can't include it in the library.
>
>
>
>
>
>Viktor Szathmary schrieb:
>  
>
>>If it has a dependency on an component that's not in the library, it's
>>not a reusable component, is it?
>>
>>Move the dependent components in the library as well.
>>
>> viktor
>>
>>On 6/10/05, Andy.Pahne-external@leoni.com <An...@leoni.com> wrote:
>>
>>    
>>
>>>I am trying to bundle a Border component into a library. That way, the
>>>cororate look and feel would be easily plugable in future projects.
>>>
>>>Unfortunatly the component in the library needs to reference a component
>>>outside the library in the application namespace. How can I reference
>>>this component?
>>>
>>>Andy Pahne
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>


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


Re: referencing an application component from inside a library

Posted by andyman <ap...@der-die-das.org>.
The Border component in the library needs to render the future
applications main Menu. I don't know about future application's menus,
so I can't include it in the library.





Viktor Szathmary schrieb:
> If it has a dependency on an component that's not in the library, it's
> not a reusable component, is it?
> 
> Move the dependent components in the library as well.
> 
>  viktor
> 
> On 6/10/05, Andy.Pahne-external@leoni.com <An...@leoni.com> wrote:
> 
>>I am trying to bundle a Border component into a library. That way, the
>>cororate look and feel would be easily plugable in future projects.
>>
>>Unfortunatly the component in the library needs to reference a component
>>outside the library in the application namespace. How can I reference
>>this component?
>>
>>Andy Pahne
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: referencing an application component from inside a library

Posted by Viktor Szathmary <ph...@gmail.com>.
If it has a dependency on an component that's not in the library, it's
not a reusable component, is it?

Move the dependent components in the library as well.

 viktor

On 6/10/05, Andy.Pahne-external@leoni.com <An...@leoni.com> wrote:
> I am trying to bundle a Border component into a library. That way, the
> cororate look and feel would be easily plugable in future projects.
> 
> Unfortunatly the component in the library needs to reference a component
> outside the library in the application namespace. How can I reference
> this component?
> 
> Andy Pahne
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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


Re: referencing an application component from inside a library

Posted by Kent Tong <ke...@cpttm.org.mo>.
phillip rhodes <rhodepc <at> yahoo.com> writes:

> However, if my pages were encapsulated within a
> library, this would not work since the  <at> Border would
> not resolve since it is not in that libraries
> namespace.

I don't know if it works, but you may having these in
your lib:

class Border extends AbstractComponent {
  void render(RequestCycle cycle) {
    PeerBorder peer = PeerLoaderHoder.loader.load(cycle);
    peer.setPeerContainer(getContainer());
    peer.render(cycle);
  }
}

interface PeerLoader {
  PeerBorder load(RequestCycle cycle);
}
class PeerLoaderHolder {
  public static PeerLoader loader;
}

interface PeerBorder extends IRender {
  void setPeerContainer(IComponent peerContainer);
}

SomePage.html:
<span jwcid="@Border">
  <span jwcid="mainBody@Block">...</span>
  <span jwcid="footer@Block">...</span>
</span>

In an app:

class Global {
  public Global() {
    PeerLoaderHolder.loader = new PeerLoader() {
      PeerBorder load(RequestCycle cycle) {
        return cycle.getPage("MyPeerBorderPage").getComponent("peerBorder");
      }
    };
  }
}

MyPeerBorderPage.html:
<span jwcid="peerBorder@MyPeerBorder"/>

MyPeerBorder.jwc:
<component-specification class="MyPeerBorder">
  <property-specification name="peerContainer" type="IComponent"/>
<component-specification/>

MyPeerBorder.html:
<html>
<span jwcid="@RenderBlock" block="ognl: peerContainer.components.mainBody"/>
<span jwcid="@RenderBlock" block="ognl: peerContainer.components.footer"/>
</html>

class MyPeerBorder extends BaseComponent implements PeerBorder {
}



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


Re: referencing an application component from inside a library

Posted by phillip rhodes <rh...@yahoo.com>.
I would have to side with Andy and say that this is an
excellent question that I was wondering how to do
myself.

I have been staying away from putting any pages into
libraries just for this reason.

It's fine to me that a library component has a
dependency on a particular component (still reusable
to me).  What is important is that I can provide to
the component or page what the particular
implementation of the component is (i.e. Border)

I have a Border component UI that I like to change on
a per project basis. (i know, use css, but that's not
enough.)  This is easily accomplished by defining the
specific Border component in my application
specification.
Since each of my pages (in each of the different
projects) refer to Border in the default application
namespace, it works well for me.

However, if my pages were encapsulated within a
library, this would not work since the @Border would
not resolve since it is not in that libraries
namespace.


It would be nice to be be able to override a library
component from within one's application specification.

Thanks.

--- Mind Bridge <mi...@yahoo.com> wrote:

> I agree with Viktor on this one, but here is one
> other alternative just in
> case:
> 
> Your Border component can take a Block as a
> parameter and then render it
> where it has to go using RenderBlock.
> Alternatively, it can actually take a component as a
> parameter and renderer
> it using Delegator.
> 
> The only downside is that the code every time you
> use your Border becomes a
> bit bigger, as you need to declare the parameter (as
> long as it is
> required):
> 
> <span jwcid="@lib:Border" section="...">
> ...
> </span>
> 
> ----- Original Message ----- 
> From: <An...@leoni.com>
> To: <ta...@jakarta.apache.org>
> Sent: Friday, June 10, 2005 5:33 PM
> Subject: referencing an application component from
> inside a library
> 
> 
> > I am trying to bundle a Border component into a
> library. That way, the
> > cororate look and feel would be easily plugable in
> future projects.
> >
> > Unfortunatly the component in the library needs to
> reference a component
> > outside the library in the application namespace.
> How can I reference
> > this component?
> >
> > Andy Pahne
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> >
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: referencing an application component from inside a library

Posted by Mind Bridge <mi...@yahoo.com>.
I agree with Viktor on this one, but here is one other alternative just in
case:

Your Border component can take a Block as a parameter and then render it
where it has to go using RenderBlock.
Alternatively, it can actually take a component as a parameter and renderer
it using Delegator.

The only downside is that the code every time you use your Border becomes a
bit bigger, as you need to declare the parameter (as long as it is
required):

<span jwcid="@lib:Border" section="...">
...
</span>

----- Original Message ----- 
From: <An...@leoni.com>
To: <ta...@jakarta.apache.org>
Sent: Friday, June 10, 2005 5:33 PM
Subject: referencing an application component from inside a library


> I am trying to bundle a Border component into a library. That way, the
> cororate look and feel would be easily plugable in future projects.
>
> Unfortunatly the component in the library needs to reference a component
> outside the library in the application namespace. How can I reference
> this component?
>
> Andy Pahne
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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