You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Matt Raible <mr...@gmail.com> on 2006/02/05 21:35:50 UTC

Tapestry 4.0 and Spring

Does the following wiki page still reflect the current/recommended way
of integrating Tapestry 4.0 with Spring?

http://wiki.apache.org/jakarta-tapestry/Tapestry4Spring

I used something similar in my project.  While it works - it doesn't
seem to be the "built-in support for Spring" that I'd suspect from
Tapestry/Hivemind.  Ideally, no Java code would be needed.

Here's what I did:

package org.appfuse.web;

....

public class SpringFactory extends SpringBeanFactoryHolderImpl
implements RegistryShutdownListener {
    private WebContext context;

    public void setContext(WebContext webcontext) {
        context = webcontext;
    }

    public BeanFactory getBeanFactory() {
        if (super.getBeanFactory() == null) {
            ApplicationContext ctx = (ApplicationContext)
               
context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
            setBeanFactory(ctx);
        }
        return super.getBeanFactory();
    }

    public void registryDidShutdown() {
        ((ConfigurableApplicationContext) getBeanFactory()).close();
    }
}

/WEB-INF/hivemodule.xml:

    <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder">
        <invoke-factory>
            <construct autowire-services="false"
class="org.appfuse.web.SpringFactory">
                <event-listener service-id="hivemind.ShutdownCoordinator"/>
                <set-object property="context"
value="service:tapestry.globals.WebContext"/>
            </construct>
        </invoke-factory>
    </implementation>

Thanks,

Matt

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


RE: Tapestry 4.0 and Spring

Posted by Nanda Firdausi <na...@gmail.com>.
Hello Matt, 

Actually Howard has create almost all for Tapestry-Spring integration (well,
it's not quite right, actually it is Hivemind-Spring integration). What is
missing is how to connect the application context of spring to the parameter
in hivemind. You can do this connection in java by extending BaseEngine of
course, but using hivemind module looks more elegant for me. 

If this class is distributed in Tapestry, you still have to write the
hivemind xml code (which in my opinion still harder than to drop the jar in
your library).

My $0.02... 

--
Nanda Firdausi
http://www.satukubik.net

> -----Original Message-----
> From: Matt Raible [mailto:mraible@gmail.com] 
> Sent: Monday, February 06, 2006 5:11 PM
> To: Tapestry users
> Subject: Re: Tapestry 4.0 and Spring
> 
> Yeah, I realize you can just download a 3rd party JAR and 
> make it work.  But from a philisophical standpoint, I find 
> this strange.  For one, the JAR is released as "alpha" and 
> 2ndly, Tapestry is the one-of-the-few Java Web Frameworks 
> that doesn't provide support for Spring out-of-the-box. Of 
> course, you can write the .java file(s) yourself - but that's 
> not out-of-the-box support.
> 
> The Spring project supports many of the frameworks by having 
> classes in their distribution (for Struts and JSF in 
> particular).  I think it'd be valuable to either include the 
> necessary classes in Tapestry or as part of Spring.
> 
> My $0.02.
> 
> Matt
> 


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


Re: Tapestry 4.0 and Spring

Posted by Matt Raible <mr...@gmail.com>.
Yeah, I realize you can just download a 3rd party JAR and make it
work.  But from a philisophical standpoint, I find this strange.  For
one, the JAR is released as "alpha" and 2ndly, Tapestry is the
one-of-the-few Java Web Frameworks that doesn't provide support for
Spring out-of-the-box. Of course, you can write the .java file(s)
yourself - but that's not out-of-the-box support.

The Spring project supports many of the frameworks by having classes
in their distribution (for Struts and JSF in particular).  I think
it'd be valuable to either include the necessary classes in Tapestry
or as part of Spring.

My $0.02.

Matt

On 2/6/06, Jabbar <aj...@gmail.com> wrote:
> Hello Matt,
>
> Just download the jar file from
> http://sourceforge.net/projects/diaphragma  and place it your
> classpath.
>
> To use the spring objects you need to inject them into your page using
> the following format
>
> @InjectObject("spring:compositeTableColumnsGenerator")
>     public abstract CompositeTableColumnsGenerator
> getCompositeTableColumnsGenerator();
>
> Hope this helps.
>
> On 05/02/06, Matt Raible <mr...@gmail.com> wrote:
> > Does the following wiki page still reflect the current/recommended way
> > of integrating Tapestry 4.0 with Spring?
> >
> > http://wiki.apache.org/jakarta-tapestry/Tapestry4Spring
> >
> > I used something similar in my project.  While it works - it doesn't
> > seem to be the "built-in support for Spring" that I'd suspect from
> > Tapestry/Hivemind.  Ideally, no Java code would be needed.
> >
> > Here's what I did:
> >
> > package org.appfuse.web;
> >
> > ....
> >
> > public class SpringFactory extends SpringBeanFactoryHolderImpl
> > implements RegistryShutdownListener {
> >    private WebContext context;
> >
> >    public void setContext(WebContext webcontext) {
> >        context = webcontext;
> >    }
> >
> >    public BeanFactory getBeanFactory() {
> >        if (super.getBeanFactory() == null) {
> >            ApplicationContext ctx = (ApplicationContext)
> >
> > context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
> >            setBeanFactory(ctx);
> >        }
> >        return super.getBeanFactory();
> >    }
> >
> >    public void registryDidShutdown() {
> >        ((ConfigurableApplicationContext) getBeanFactory()).close();
> >    }
> > }
> >
> > /WEB-INF/hivemodule.xml:
> >
> >    <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder">
> >        <invoke-factory>
> >            <construct autowire-services="false"
> > class="org.appfuse.web.SpringFactory">
> >                <event-listener service-id="hivemind.ShutdownCoordinator"/>
> >                <set-object property="context"
> > value="service:tapestry.globals.WebContext"/>
> >            </construct>
> >        </invoke-factory>
> >    </implementation>
> >
> > Thanks,
> >
> > Matt
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Thanks
>
> Jabbar Azam
>

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


Re: Tapestry 4.0 and Spring

Posted by Jabbar <aj...@gmail.com>.
Matt,

I'm using spring 1.2.5 and tapestry 4.0.

On 06/02/06, Jabbar <aj...@gmail.com> wrote:
> Hello Matt,
>
> Just download the jar file from
> http://sourceforge.net/projects/diaphragma  and place it your
> classpath.
>
> To use the spring objects you need to inject them into your page using
> the following format
>
> @InjectObject("spring:compositeTableColumnsGenerator")
>    public abstract CompositeTableColumnsGenerator
> getCompositeTableColumnsGenerator();
>
> Hope this helps.
>
> On 05/02/06, Matt Raible <mr...@gmail.com> wrote:
> > Does the following wiki page still reflect the current/recommended way
> > of integrating Tapestry 4.0 with Spring?
> >
> > http://wiki.apache.org/jakarta-tapestry/Tapestry4Spring
> >
> > I used something similar in my project.  While it works - it doesn't
> > seem to be the "built-in support for Spring" that I'd suspect from
> > Tapestry/Hivemind.  Ideally, no Java code would be needed.
> >
> > Here's what I did:
> >
> > package org.appfuse.web;
> >
> > ....
> >
> > public class SpringFactory extends SpringBeanFactoryHolderImpl
> > implements RegistryShutdownListener {
> >    private WebContext context;
> >
> >    public void setContext(WebContext webcontext) {
> >        context = webcontext;
> >    }
> >
> >    public BeanFactory getBeanFactory() {
> >        if (super.getBeanFactory() == null) {
> >            ApplicationContext ctx = (ApplicationContext)
> >
> > context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
> >            setBeanFactory(ctx);
> >        }
> >        return super.getBeanFactory();
> >    }
> >
> >    public void registryDidShutdown() {
> >        ((ConfigurableApplicationContext) getBeanFactory()).close();
> >    }
> > }
> >
> > /WEB-INF/hivemodule.xml:
> >
> >    <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder">
> >        <invoke-factory>
> >            <construct autowire-services="false"
> > class="org.appfuse.web.SpringFactory">
> >                <event-listener service-id="hivemind.ShutdownCoordinator"/>
> >                <set-object property="context"
> > value="service:tapestry.globals.WebContext"/>
> >            </construct>
> >        </invoke-factory>
> >    </implementation>
> >
> > Thanks,
> >
> > Matt
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Thanks
>
> Jabbar Azam
>


--
Thanks

Jabbar Azam

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


Re: Tapestry 4.0 and Spring

Posted by Jabbar <aj...@gmail.com>.
Hello Matt,

Just download the jar file from 
http://sourceforge.net/projects/diaphragma  and place it your
classpath.

To use the spring objects you need to inject them into your page using
the following format

@InjectObject("spring:compositeTableColumnsGenerator")
    public abstract CompositeTableColumnsGenerator
getCompositeTableColumnsGenerator();

Hope this helps.

On 05/02/06, Matt Raible <mr...@gmail.com> wrote:
> Does the following wiki page still reflect the current/recommended way
> of integrating Tapestry 4.0 with Spring?
>
> http://wiki.apache.org/jakarta-tapestry/Tapestry4Spring
>
> I used something similar in my project.  While it works - it doesn't
> seem to be the "built-in support for Spring" that I'd suspect from
> Tapestry/Hivemind.  Ideally, no Java code would be needed.
>
> Here's what I did:
>
> package org.appfuse.web;
>
> ....
>
> public class SpringFactory extends SpringBeanFactoryHolderImpl
> implements RegistryShutdownListener {
>    private WebContext context;
>
>    public void setContext(WebContext webcontext) {
>        context = webcontext;
>    }
>
>    public BeanFactory getBeanFactory() {
>        if (super.getBeanFactory() == null) {
>            ApplicationContext ctx = (ApplicationContext)
>
> context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
>            setBeanFactory(ctx);
>        }
>        return super.getBeanFactory();
>    }
>
>    public void registryDidShutdown() {
>        ((ConfigurableApplicationContext) getBeanFactory()).close();
>    }
> }
>
> /WEB-INF/hivemodule.xml:
>
>    <implementation service-id="hivemind.lib.DefaultSpringBeanFactoryHolder">
>        <invoke-factory>
>            <construct autowire-services="false"
> class="org.appfuse.web.SpringFactory">
>                <event-listener service-id="hivemind.ShutdownCoordinator"/>
>                <set-object property="context"
> value="service:tapestry.globals.WebContext"/>
>            </construct>
>        </invoke-factory>
>    </implementation>
>
> Thanks,
>
> Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Thanks

Jabbar Azam

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