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...@gmail.com> on 2006/04/04 12:59:36 UTC

using EnhancementWorkers for Specification Inheritance

Hello,

I am using JDK1.4 and for that reason can not use the annotations. However,
I would still like be able to provide for "specification inheritance", i.e.
getting my ASO injected to all classes which derive from my BasePage without
having to specify an inject declaration in each of my page xml specs. I
thought I could do that by using EnhancementWorkers but I still end up
getting a NPE when accessing my  allegedly inserted ASO. My
EnhancementWorker impl looks as follows:

    public void performEnhancement(EnhancementOperation op,
IComponentSpecification spec) {

        if (op.implementsInterface(BasePage.class)) {

            // xml fragment:  <inject property="aso" type="state"
object="aso"/>

            InjectSpecification asoInjSpec = new InjectSpecificationImpl();
            asoInjSpec.setType("state");
            asoInjSpec.setProperty("aso");
            asoInjSpec.setObject("aso");

            spec.addInjectSpecification (asoInjSpec);
        }
}



where BasePage.class is the class of the base page for all my pages. My
hivemind contribution looks as follows:

    <contribution configuration-id="tapestry.enhance.EnhancementWorkers">
        <command id="enhance-basePage-worker"
                object="service:BasePageEnhancementWorker"
                before="tapestry.enhance.abstract-property" />
    </contribution>

    <service-point id="BasePageEnhancementWorker"
        interface="org.apache.tapestry.enhance.EnhancementWorker">
        <invoke-factory>
            <construct
                class="mailadm.web.enhance.BasePageEnhancementWorker">
            </construct>
        </invoke-factory>
    </service-point>

When I add debug statements to my EnhancementWorker I see it gets executed
just fine. Moreover I added debug statements to
org.apache.tapestry.enhance.InjectStateWorker and it works on my aso inject
spec. However, the funny thing is that when using a state inject spec from
my xml page spec, the InjectStateWorker logs two invocations for one
injection, whereas for my EnhancementWorker only one invocation is logged
and I end up with a non-working injection (i.e. the NPE when trying to
access the injected property).

Any help would be greatly appreciated. Thanks!

Re: using EnhancementWorkers for Specification Inheritance

Posted by Raul Cesar Teixeira <ra...@gmail.com>.
Mark,

Did your enhancement worker finally work? I tried to implement your
solution to the same problem I am having, but still no dice. I keep
getting an error saying "Parameter location must not be null."
How are you creating your ASO? I'm trying to create mine like this:

        <contribution configuration-id="tapestry.state.ApplicationObjects">
		<state-object name="aso" scope="session">
			<create-instance  class="xyz.AsoClass" />
		</state-object>
	</contribution>

Any help would be great! I'm stuck on this for 3 days now!!!

On 4/10/06, Mark Lehmacher <ma...@gmx.de> wrote:
>
> For future reference: Solved my problem by simply contributing my
> enhancement worker with before="tapestry.enhance.inject-specification"
> instead of before="tapestry.enhance.abstract-property"!
>
> > --- Ursprüngliche Nachricht ---
> > Von: "Mark Lehmacher" <ma...@gmail.com>
> > An: tapestry-user@jakarta.apache.org
> > Betreff: using EnhancementWorkers for Specification Inheritance
> > Datum: Tue, 4 Apr 2006 12:59:36 +0200
> >
> > Hello,
> >
> > I am using JDK1.4 and for that reason can not use the annotations.
> > However,
> > I would still like be able to provide for "specification inheritance",
> > i.e.
> > getting my ASO injected to all classes which derive from my BasePage
> > without
> > having to specify an inject declaration in each of my page xml specs. I
> > thought I could do that by using EnhancementWorkers but I still end up
> > getting a NPE when accessing my  allegedly inserted ASO. My
> > EnhancementWorker impl looks as follows:
> >
> >     public void performEnhancement(EnhancementOperation op,
> > IComponentSpecification spec) {
> >
> >         if (op.implementsInterface(BasePage.class)) {
> >
> >             // xml fragment:  <inject property="aso" type="state"
> > object="aso"/>
> >
> >             InjectSpecification asoInjSpec = new
> > InjectSpecificationImpl();
> >             asoInjSpec.setType("state");
> >             asoInjSpec.setProperty("aso");
> >             asoInjSpec.setObject("aso");
> >
> >             spec.addInjectSpecification (asoInjSpec);
> >         }
> > }
> >
> >
> >
> > where BasePage.class is the class of the base page for all my pages. My
> > hivemind contribution looks as follows:
> >
> >     <contribution configuration-id="tapestry.enhance.EnhancementWorkers">
> >         <command id="enhance-basePage-worker"
> >                 object="service:BasePageEnhancementWorker"
> >                 before="tapestry.enhance.abstract-property" />
> >     </contribution>
> >
> >     <service-point id="BasePageEnhancementWorker"
> >         interface="org.apache.tapestry.enhance.EnhancementWorker">
> >         <invoke-factory>
> >             <construct
> >                 class="mailadm.web.enhance.BasePageEnhancementWorker">
> >             </construct>
> >         </invoke-factory>
> >     </service-point>
> >
> > When I add debug statements to my EnhancementWorker I see it gets executed
> > just fine. Moreover I added debug statements to
> > org.apache.tapestry.enhance.InjectStateWorker and it works on my aso
> > inject
> > spec. However, the funny thing is that when using a state inject spec from
> > my xml page spec, the InjectStateWorker logs two invocations for one
> > injection, whereas for my EnhancementWorker only one invocation is logged
> > and I end up with a non-working injection (i.e. the NPE when trying to
> > access the injected property).
> >
> > Any help would be greatly appreciated. Thanks!
> >
>
> --
> "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
> Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
>
> ---------------------------------------------------------------------
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: using EnhancementWorkers for Specification Inheritance

Posted by Mark Lehmacher <ma...@gmx.de>.
For future reference: Solved my problem by simply contributing my
enhancement worker with before="tapestry.enhance.inject-specification"
instead of before="tapestry.enhance.abstract-property"!

> --- Ursprüngliche Nachricht ---
> Von: "Mark Lehmacher" <ma...@gmail.com>
> An: tapestry-user@jakarta.apache.org
> Betreff: using EnhancementWorkers for Specification Inheritance
> Datum: Tue, 4 Apr 2006 12:59:36 +0200
> 
> Hello,
> 
> I am using JDK1.4 and for that reason can not use the annotations.
> However,
> I would still like be able to provide for "specification inheritance",
> i.e.
> getting my ASO injected to all classes which derive from my BasePage
> without
> having to specify an inject declaration in each of my page xml specs. I
> thought I could do that by using EnhancementWorkers but I still end up
> getting a NPE when accessing my  allegedly inserted ASO. My
> EnhancementWorker impl looks as follows:
> 
>     public void performEnhancement(EnhancementOperation op,
> IComponentSpecification spec) {
> 
>         if (op.implementsInterface(BasePage.class)) {
> 
>             // xml fragment:  <inject property="aso" type="state"
> object="aso"/>
> 
>             InjectSpecification asoInjSpec = new
> InjectSpecificationImpl();
>             asoInjSpec.setType("state");
>             asoInjSpec.setProperty("aso");
>             asoInjSpec.setObject("aso");
> 
>             spec.addInjectSpecification (asoInjSpec);
>         }
> }
> 
> 
> 
> where BasePage.class is the class of the base page for all my pages. My
> hivemind contribution looks as follows:
> 
>     <contribution configuration-id="tapestry.enhance.EnhancementWorkers">
>         <command id="enhance-basePage-worker"
>                 object="service:BasePageEnhancementWorker"
>                 before="tapestry.enhance.abstract-property" />
>     </contribution>
> 
>     <service-point id="BasePageEnhancementWorker"
>         interface="org.apache.tapestry.enhance.EnhancementWorker">
>         <invoke-factory>
>             <construct
>                 class="mailadm.web.enhance.BasePageEnhancementWorker">
>             </construct>
>         </invoke-factory>
>     </service-point>
> 
> When I add debug statements to my EnhancementWorker I see it gets executed
> just fine. Moreover I added debug statements to
> org.apache.tapestry.enhance.InjectStateWorker and it works on my aso
> inject
> spec. However, the funny thing is that when using a state inject spec from
> my xml page spec, the InjectStateWorker logs two invocations for one
> injection, whereas for my EnhancementWorker only one invocation is logged
> and I end up with a non-working injection (i.e. the NPE when trying to
> access the injected property).
> 
> Any help would be greatly appreciated. Thanks!
> 

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail

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