You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark Lehmacher <ma...@gmx.de> on 2004/09/29 20:00:43 UTC

informal parameter injection

Hello everyone,

I have been playing with Tapestry the last couple of days and are still
trying to get my head around it's concepts.

What I want at the moment is to have a custom PageLink component, which adds
a class="current" to it's informal parameters when the target page equals
the current page (name). How would I go about that? Namely adding something
to the informal parameters of a component in code?

I would imagine the code to look something like that:

public abstract class CurrentPageLink extends PageLink {

    public void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {

        String pageName = getPage.getPageName();
        if (pageName.endsWith(getTargetPage()) {
            addInformalParameter("class", "current");
        }

        super.renderComponent(writer, cycle);

    }
}

However, I don't see any way to do this. I am probably thinking into a wrong
direction here, so any help would be greatly appreciated.

Thanks!


Mark

-- 
+++ GMX DSL Premiumtarife 3 Monate gratis* + WLAN-Router 0,- EUR* +++
Clevere DSL-Nutzer wechseln jetzt zu GMX: http://www.gmx.net/de/go/dsl


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


Re: informal parameter injection

Posted by Paul Ferraro <pm...@columbia.edu>.
Here's a very similar custom component that I use often:

<component-specification class="com.idtheft.components.PageClassLink">
    <parameter name="page" type="java.lang.String" required="yes" 
property-name="targetPage" direction="in"/>
    <parameter name="namespace" type="org.apache.tapestry.INamespace" 
required="no" property-name="targetNamespace" direction="in"/>
    <parameter name="disabled" type="boolean" direction="in"/>
    <parameter name="anchor" type="java.lang.String" direction="in"/>
    <parameter name="renderer" 
type="org.apache.tapestry.link.ILinkRenderer" direction="in"/>
    <parameter name="currentPage" type="java.lang.String" direction="in" 
required="no" default-value="page.pageName"></parameter>
    <!-- style used if the page used in this link is NOT the current 
page -->
    <parameter name="class" type="java.lang.String" required="yes" 
direction="in" property-name="style"/>
    <!-- style used if the page used in this link is the current page -->
    <parameter name="pageClass" type="java.lang.String" required="yes" 
direction="in" property-name="pageStyle"/>
 
    <reserved-parameter name="href"/>
</component-specification>

public abstract class PageClassLink extends PageLink
{
    public abstract String getStyle();
    public abstract String getPageStyle();
    public abstract String getCurrentPage();

    public void renderAdditionalAttributes(IMarkupWriter writer, 
IRequestCycle cycle)
    {
        writeEventHandlers(writer, cycle);
       
        String style = 
this.getCurrentPage().equals(this.getTargetPage()) ? this.getPageStyle() 
: this.getStyle();
       
        writer.attribute("class", style);
       
        renderInformalParameters(writer, cycle);
    }
}

Mark Lehmacher wrote:

>Hello everyone,
>
>I have been playing with Tapestry the last couple of days and are still
>trying to get my head around it's concepts.
>
>What I want at the moment is to have a custom PageLink component, which adds
>a class="current" to it's informal parameters when the target page equals
>the current page (name). How would I go about that? Namely adding something
>to the informal parameters of a component in code?
>
>I would imagine the code to look something like that:
>
>public abstract class CurrentPageLink extends PageLink {
>
>    public void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
>
>        String pageName = getPage.getPageName();
>        if (pageName.endsWith(getTargetPage()) {
>            addInformalParameter("class", "current");
>        }
>
>        super.renderComponent(writer, cycle);
>
>    }
>}
>
>However, I don't see any way to do this. I am probably thinking into a wrong
>direction here, so any help would be greatly appreciated.
>
>Thanks!
>
>
>Mark
>
>  
>


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


Re: informal parameter injection

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Yer welcome!
On Sep 29, 2004, at 6:33 PM, Mark Lehmacher wrote:

> Thank you Jamie and Paul for your quick and helpful responses. That was
> exactly what I was looking for.
>
> Mark
>
>> Dig down into AbstractLinkComponent and see 
>> renderAdditionalAttributes().
>> Follow that into renderInformalParameters(). That should give you an 
>> idea
>> of
>> how to do this.
>>
>> Jamie
>>
>>
>> ----- Original Message -----
>> From: "Mark Lehmacher" <ma...@gmx.de>
>> To: <ta...@jakarta.apache.org>
>> Sent: Wednesday, September 29, 2004 2:00 PM
>> Subject: informal parameter injection
>>
>>
>>> Hello everyone,
>>>
>>> I have been playing with Tapestry the last couple of days and are 
>>> still
>>> trying to get my head around it's concepts.
>>>
>>> What I want at the moment is to have a custom PageLink component, 
>>> which
>> adds
>>> a class="current" to it's informal parameters when the target page
>> equals
>>> the current page (name). How would I go about that? Namely adding
>> something
>>> to the informal parameters of a component in code?
>>>
>>> I would imagine the code to look something like that:
>>>
>>> public abstract class CurrentPageLink extends PageLink {
>>>
>>>     public void renderComponent(IMarkupWriter writer, IRequestCycle
>> cycle)
>> {
>>>
>>>         String pageName = getPage.getPageName();
>>>         if (pageName.endsWith(getTargetPage()) {
>>>             addInformalParameter("class", "current");
>>>         }
>>>
>>>         super.renderComponent(writer, cycle);
>>>
>>>     }
>>> }
>>>
>>> However, I don't see any way to do this. I am probably thinking into 
>>> a
>> wrong
>>> direction here, so any help would be greatly appreciated.
>>>
>>> Thanks!
>>>
>>>
>>> Mark
>
> -- 
> GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
> +++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++
>
>
> ---------------------------------------------------------------------
> 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: informal parameter injection

Posted by Mark Lehmacher <ma...@gmx.de>.
Thank you Jamie and Paul for your quick and helpful responses. That was
exactly what I was looking for.

Mark

> Dig down into AbstractLinkComponent and see renderAdditionalAttributes().
> Follow that into renderInformalParameters(). That should give you an idea
> of
> how to do this.
> 
> Jamie
> 
> 
> ----- Original Message ----- 
> From: "Mark Lehmacher" <ma...@gmx.de>
> To: <ta...@jakarta.apache.org>
> Sent: Wednesday, September 29, 2004 2:00 PM
> Subject: informal parameter injection
> 
> 
> > Hello everyone,
> >
> > I have been playing with Tapestry the last couple of days and are still
> > trying to get my head around it's concepts.
> >
> > What I want at the moment is to have a custom PageLink component, which
> adds
> > a class="current" to it's informal parameters when the target page
> equals
> > the current page (name). How would I go about that? Namely adding
> something
> > to the informal parameters of a component in code?
> >
> > I would imagine the code to look something like that:
> >
> > public abstract class CurrentPageLink extends PageLink {
> >
> >     public void renderComponent(IMarkupWriter writer, IRequestCycle
> cycle)
> {
> >
> >         String pageName = getPage.getPageName();
> >         if (pageName.endsWith(getTargetPage()) {
> >             addInformalParameter("class", "current");
> >         }
> >
> >         super.renderComponent(writer, cycle);
> >
> >     }
> > }
> >
> > However, I don't see any way to do this. I am probably thinking into a
> wrong
> > direction here, so any help would be greatly appreciated.
> >
> > Thanks!
> >
> >
> > Mark

-- 
GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
+++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++


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


Re: informal parameter injection

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Dig down into AbstractLinkComponent and see renderAdditionalAttributes().
Follow that into renderInformalParameters(). That should give you an idea of
how to do this.

Jamie


----- Original Message ----- 
From: "Mark Lehmacher" <ma...@gmx.de>
To: <ta...@jakarta.apache.org>
Sent: Wednesday, September 29, 2004 2:00 PM
Subject: informal parameter injection


> Hello everyone,
>
> I have been playing with Tapestry the last couple of days and are still
> trying to get my head around it's concepts.
>
> What I want at the moment is to have a custom PageLink component, which
adds
> a class="current" to it's informal parameters when the target page equals
> the current page (name). How would I go about that? Namely adding
something
> to the informal parameters of a component in code?
>
> I would imagine the code to look something like that:
>
> public abstract class CurrentPageLink extends PageLink {
>
>     public void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
>
>         String pageName = getPage.getPageName();
>         if (pageName.endsWith(getTargetPage()) {
>             addInformalParameter("class", "current");
>         }
>
>         super.renderComponent(writer, cycle);
>
>     }
> }
>
> However, I don't see any way to do this. I am probably thinking into a
wrong
> direction here, so any help would be greatly appreciated.
>
> Thanks!
>
>
> Mark
>
> -- 
> +++ GMX DSL Premiumtarife 3 Monate gratis* + WLAN-Router 0,- EUR* +++
> Clevere DSL-Nutzer wechseln jetzt zu GMX: http://www.gmx.net/de/go/dsl
>
>
> ---------------------------------------------------------------------
> 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