You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nemanja Kostic <n....@youngculture.com> on 2005/01/26 10:48:56 UTC

Tapestry + Spring problem...

Hi all,

  I have this problem that drives me crazy.
In my Tapestry classes I use service beans injected by Spring and it all
works ok, except when I try to call Login page using PageCallback

I always get this runtime exception:
/Unable to initialize property siteServices of 
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]: 
Unable to read expression '<parsed expression>' of 
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].

/Login.page has property:
/<property-specification name="siteServices" 
type="com.aspectcms.service.core.SiteServices">
      global.appContext.getBean("siteServices")
  </property-specification>/

In debug I see that error comes from my ACMSBasePage (which extends 
BasePage and implements PageValidateListener),
where I redirect to Login page if user is not logged in:

/Login login = (Login) getRequestCycle().getPage("Login");
login.setCallback(new PageCallback(this));
throw new PageRedirectException(login);   / 


Am I doing something wrong or there is a problem with calling Spring 
beans when using PageCallback?


10x in advance.
Nemanja.




Re: Tapestry + Spring problem...

Posted by st...@wachovia.com.
One other suggestion is to create a single facade service bean that 
delegates the calls to the other service beans. Then presentation layer 
only has to deal with one service bean.
 



Nemanja Kostic <n....@youngculture.com> 
01/26/2005 01:56 PM

Please respond to
"Tapestry users" <ta...@jakarta.apache.org>


To
Tapestry users <ta...@jakarta.apache.org>
cc

Subject
Re: Tapestry + Spring problem...







Excellent, it works now! :)

I moved definition of Spring service beans out of page properties
and put in Global object, as you said. Not only it works, but it's much 
more
elegant solution than repeating bunch of property specifications 
in .page files. 

Thanks Jonny. 



Quoting Jonny Wray <jo...@yahoo.com>:

> 
> Well, I'm using Spring beans and call backs on my login page, so it can
> work.
> 
> The only difference I can tell from your description is the way I
> access  my Spring beans. I didn't like the "injection" solution given
> in the Spring docs of specifying a page property. I ended up with
> multiple pages with the same page property hardcoding the same bean
> name. So, in my global I have a helper method for each service, eg
> 
> public SiteServices getSiteServices(){
>     return (SiteServices)appContext.getBean("siteServices");
> }
> 
> this allows any page to access services in a type safe manner and I
> only have the bean name hardcoded in one place.
> 
> No idea if that's the cause of you problem though.
> Jonny



-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

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


ForwardSourceID:NT00002DC2 

Re: Tapestry + Spring problem...

Posted by Nemanja Kostic <n....@youngculture.com>.
Excellent, it works now! :)

I moved definition of Spring service beans out of page properties
and put in Global object, as you said. Not only it works, but it's much more
elegant solution than repeating bunch of property specifications 
in .page files. 

Thanks Jonny. 



Quoting Jonny Wray <jo...@yahoo.com>:

> 
> Well, I'm using Spring beans and call backs on my login page, so it can
> work.
> 
> The only difference I can tell from your description is the way I
> access  my Spring beans. I didn't like the "injection" solution given
> in the Spring docs of specifying a page property. I ended up with
> multiple pages with the same page property hardcoding the same bean
> name. So, in my global I have a helper method for each service, eg
> 
> public SiteServices getSiteServices(){
>     return (SiteServices)appContext.getBean("siteServices");
> }
> 
> this allows any page to access services in a type safe manner and I
> only have the bean name hardcoded in one place.
> 
> No idea if that's the cause of you problem though.
> Jonny



-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

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


Re: Tapestry + Spring problem...

Posted by Hugo Palma <hp...@digitalis.pt>.
eheh.....with windows you never know.....

Anyway...finally the correct link: 
http://www.springframework.org/docs/reference/view.html#view-tapestry-exposeappctx


Cheers

Hugo


Jamie Orchard-Hays wrote:

> um, I doubt any of us have access to your C drive! ;-)
>
> Jamie
> ----- Original Message ----- From: "Hugo Palma" <hp...@digitalis.pt>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Friday, February 11, 2005 12:35 PM
> Subject: Re: Tapestry + Spring problem...
>
>
>> eheh, sorry about the link......
>> Here's the correct one 
>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>>
>>
>> Hugo Palma wrote:
>>
>>> Check the spring documentation 
>>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>>>
>>> It's the engine that places the aplication context in the glogal 
>>> object.
>>>
>>>
>>> Cheers
>>>
>>> Hugo
>>>
>>>
>>> Stephen Robinson wrote:
>>>
>>>> That looks like a neat solution, but could you help me with that 
>>>> last step. When you add this function to your global-class object....
>>>>
>>>> >public SiteServices getSiteServices(){
>>>> >    return (SiteServices)appContext.getBean("siteServices");
>>>> >}
>>>>
>>>> How does it know where to get the appContext? From within my java 
>>>> class that extends BasePage I have successfully done the following....
>>>>
>>>> WebApplicationContext appContext =
>>>> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext()); 
>>>>
>>>> SiteServices siteServices = (SiteServices) 
>>>> appContext.getBean("siteServices");
>>>>
>>>> This works because I have access to the SerletContext at that 
>>>> point. When I call the global object do I have to set the 
>>>> appContext? Do I have to do this each call, or is it magically 
>>>> accessible some other way :)
>>>>
>>>> Steve
>>>>
>>>> Jonny Wray wrote:
>>>>
>>>>> Well, I'm using Spring beans and call backs on my login page, so 
>>>>> it can
>>>>> work.
>>>>>
>>>>> The only difference I can tell from your description is the way I
>>>>> access  my Spring beans. I didn't like the "injection" solution given
>>>>> in the Spring docs of specifying a page property. I ended up with
>>>>> multiple pages with the same page property hardcoding the same bean
>>>>> name. So, in my global I have a helper method for each service, eg
>>>>>
>>>>> public SiteServices getSiteServices(){
>>>>>    return (SiteServices)appContext.getBean("siteServices");
>>>>> }
>>>>>
>>>>> this allows any page to access services in a type safe manner and I
>>>>> only have the bean name hardcoded in one place.
>>>>>
>>>>> No idea if that's the cause of you problem though.
>>>>> Jonny
>>>>>
>>>>>
>>>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>>>>
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>>  I have this problem that drives me crazy.
>>>>>> In my Tapestry classes I use service beans injected by Spring and it
>>>>>> all
>>>>>> works ok, except when I try to call Login page using PageCallback
>>>>>>
>>>>>> I always get this runtime exception:
>>>>>> /Unable to initialize property siteServices of
>>>>>>
>>>>>
>>>>>
>>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]: 
>>>>>
>>>>>
>>>>>> Unable to read expression '<parsed expression>' of
>>>>>>
>>>>>
>>>>>
>>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]. 
>>>>>
>>>>>
>>>>>> /Login.page has property:
>>>>>> /<property-specification name="siteServices" 
>>>>>> type="com.aspectcms.service.core.SiteServices">
>>>>>>      global.appContext.getBean("siteServices")
>>>>>>  </property-specification>/
>>>>>>
>>>>>> In debug I see that error comes from my ACMSBasePage (which 
>>>>>> extends BasePage and implements PageValidateListener),
>>>>>> where I redirect to Login page if user is not logged in:
>>>>>>
>>>>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>>>>> login.setCallback(new PageCallback(this));
>>>>>> throw new PageRedirectException(login);   /
>>>>>>
>>>>>> Am I doing something wrong or there is a problem with calling 
>>>>>> Spring beans when using PageCallback?
>>>>>>
>>>>>>
>>>>>> 10x in advance.
>>>>>> Nemanja.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: Tapestry + Spring problem...

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

eh - just have to declare the following:
<property-specification name="hugo" type="windows.harddrive"
~                         initial-value="c:\"/>

talk about geek humor.... *sigh*

Jamie Orchard-Hays wrote:
| um, I doubt any of us have access to your C drive! ;-)
|
| Jamie
| ----- Original Message ----- From: "Hugo Palma" <hp...@digitalis.pt>
| To: "Tapestry users" <ta...@jakarta.apache.org>
| Sent: Friday, February 11, 2005 12:35 PM
| Subject: Re: Tapestry + Spring problem...
|
|
|> eheh, sorry about the link......
|> Here's the correct one
|>
file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx

|>
|>
|> Hugo Palma wrote:
|>
|>> Check the spring documentation
|>>
file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx

|>>
|>> It's the engine that places the aplication context in the glogal object.
|>>
|>>
|>> Cheers
|>>
|>> Hugo
|>>
|>>
|>> Stephen Robinson wrote:
|>>
|>>> That looks like a neat solution, but could you help me with that
|>>> last step. When you add this function to your global-class object....
|>>>
|>>> >public SiteServices getSiteServices(){
|>>> >    return (SiteServices)appContext.getBean("siteServices");
|>>> >}
|>>>
|>>> How does it know where to get the appContext? From within my java
|>>> class that extends BasePage I have successfully done the following....
|>>>
|>>> WebApplicationContext appContext =
|>>>
WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext());

|>>>
|>>> SiteServices siteServices = (SiteServices)
|>>> appContext.getBean("siteServices");
|>>>
|>>> This works because I have access to the SerletContext at that point.
|>>> When I call the global object do I have to set the appContext? Do I
|>>> have to do this each call, or is it magically accessible some other
|>>> way :)
|>>>
|>>> Steve
|>>>
|>>> Jonny Wray wrote:
|>>>
|>>>> Well, I'm using Spring beans and call backs on my login page, so it
|>>>> can
|>>>> work.
|>>>>
|>>>> The only difference I can tell from your description is the way I
|>>>> access  my Spring beans. I didn't like the "injection" solution given
|>>>> in the Spring docs of specifying a page property. I ended up with
|>>>> multiple pages with the same page property hardcoding the same bean
|>>>> name. So, in my global I have a helper method for each service, eg
|>>>>
|>>>> public SiteServices getSiteServices(){
|>>>>    return (SiteServices)appContext.getBean("siteServices");
|>>>> }
|>>>>
|>>>> this allows any page to access services in a type safe manner and I
|>>>> only have the bean name hardcoded in one place.
|>>>>
|>>>> No idea if that's the cause of you problem though.
|>>>> Jonny
|>>>>
|>>>>
|>>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
|>>>>
|>>>>
|>>>>> Hi all,
|>>>>>
|>>>>>  I have this problem that drives me crazy.
|>>>>> In my Tapestry classes I use service beans injected by Spring and it
|>>>>> all
|>>>>> works ok, except when I try to call Login page using PageCallback
|>>>>>
|>>>>> I always get this runtime exception:
|>>>>> /Unable to initialize property siteServices of
|>>>>>
|>>>>
|>>>>
|>>>>
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
|>>>>
|>>>>
|>>>>> Unable to read expression '<parsed expression>' of
|>>>>>
|>>>>
|>>>>
|>>>>
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
|>>>>
|>>>>
|>>>>> /Login.page has property:
|>>>>> /<property-specification name="siteServices"
|>>>>> type="com.aspectcms.service.core.SiteServices">
|>>>>>      global.appContext.getBean("siteServices")
|>>>>>  </property-specification>/
|>>>>>
|>>>>> In debug I see that error comes from my ACMSBasePage (which
|>>>>> extends BasePage and implements PageValidateListener),
|>>>>> where I redirect to Login page if user is not logged in:
|>>>>>
|>>>>> /Login login = (Login) getRequestCycle().getPage("Login");
|>>>>> login.setCallback(new PageCallback(this));
|>>>>> throw new PageRedirectException(login);   /
|>>>>>
|>>>>> Am I doing something wrong or there is a problem with calling
|>>>>> Spring beans when using PageCallback?
|>>>>>
|>>>>>
|>>>>> 10x in advance.
|>>>>> Nemanja.
|>>>>>
|>>>>>
|>>>>>
|>>>>>
|>>>>>
|>>>>
|>>>>
|>>>>
|>>>>
|>>>> ---------------------------------------------------------------------
|>>>> 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
|>
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFCDPmzaCoPKRow/gARAjSvAKDlOi+bWtF/+mywwmLGkYsCF63J0QCgyJkN
AOvYdeiyPvD3ODBt7rfGNyk=
=gsXX
-----END PGP SIGNATURE-----

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


Re: Tapestry + Spring problem...

Posted by Jamie Orchard-Hays <ja...@dang.com>.
um, I doubt any of us have access to your C drive! ;-)

Jamie
----- Original Message ----- 
From: "Hugo Palma" <hp...@digitalis.pt>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, February 11, 2005 12:35 PM
Subject: Re: Tapestry + Spring problem...


> eheh, sorry about the link......
> Here's the correct one 
> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx
>
> Hugo Palma wrote:
>
>> Check the spring documentation 
>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx
>> It's the engine that places the aplication context in the glogal object.
>>
>>
>> Cheers
>>
>> Hugo
>>
>>
>> Stephen Robinson wrote:
>>
>>> That looks like a neat solution, but could you help me with that last 
>>> step. When you add this function to your global-class object....
>>>
>>> >public SiteServices getSiteServices(){
>>> >    return (SiteServices)appContext.getBean("siteServices");
>>> >}
>>>
>>> How does it know where to get the appContext? From within my java class 
>>> that extends BasePage I have successfully done the following....
>>>
>>> WebApplicationContext appContext =
>>> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext());
>>> SiteServices siteServices = (SiteServices) 
>>> appContext.getBean("siteServices");
>>>
>>> This works because I have access to the SerletContext at that point. 
>>> When I call the global object do I have to set the appContext? Do I have 
>>> to do this each call, or is it magically accessible some other way :)
>>>
>>> Steve
>>>
>>> Jonny Wray wrote:
>>>
>>>> Well, I'm using Spring beans and call backs on my login page, so it can
>>>> work.
>>>>
>>>> The only difference I can tell from your description is the way I
>>>> access  my Spring beans. I didn't like the "injection" solution given
>>>> in the Spring docs of specifying a page property. I ended up with
>>>> multiple pages with the same page property hardcoding the same bean
>>>> name. So, in my global I have a helper method for each service, eg
>>>>
>>>> public SiteServices getSiteServices(){
>>>>    return (SiteServices)appContext.getBean("siteServices");
>>>> }
>>>>
>>>> this allows any page to access services in a type safe manner and I
>>>> only have the bean name hardcoded in one place.
>>>>
>>>> No idea if that's the cause of you problem though.
>>>> Jonny
>>>>
>>>>
>>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>>>
>>>>
>>>>> Hi all,
>>>>>
>>>>>  I have this problem that drives me crazy.
>>>>> In my Tapestry classes I use service beans injected by Spring and it
>>>>> all
>>>>> works ok, except when I try to call Login page using PageCallback
>>>>>
>>>>> I always get this runtime exception:
>>>>> /Unable to initialize property siteServices of
>>>>>
>>>>
>>>>
>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
>>>>
>>>>> Unable to read expression '<parsed expression>' of
>>>>>
>>>>
>>>>
>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
>>>>
>>>>> /Login.page has property:
>>>>> /<property-specification name="siteServices" 
>>>>> type="com.aspectcms.service.core.SiteServices">
>>>>>      global.appContext.getBean("siteServices")
>>>>>  </property-specification>/
>>>>>
>>>>> In debug I see that error comes from my ACMSBasePage (which extends 
>>>>> BasePage and implements PageValidateListener),
>>>>> where I redirect to Login page if user is not logged in:
>>>>>
>>>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>>>> login.setCallback(new PageCallback(this));
>>>>> throw new PageRedirectException(login);   /
>>>>>
>>>>> Am I doing something wrong or there is a problem with calling Spring 
>>>>> beans when using PageCallback?
>>>>>
>>>>>
>>>>> 10x in advance.
>>>>> Nemanja.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
> 


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


Re: Tapestry + Spring problem...

Posted by Hugo Palma <hp...@digitalis.pt>.
You don't have to create your own Global object, and you don't have to 
have page properties.
I have these 3 methods in my Engine class:

public final ApplicationContext getApplicationContext()
   {
      return (ApplicationContext) ((Map) 
getGlobal()).get(APPLICATION_CONTEXT_KEY);
   }

   public final Object getBean(String id)
   {
      return getApplicationContext().getBean(id);
   }

   protected final void setupForRequest(RequestContext context)
   {
      super.setupForRequest(context);

      Map global = (Map) getGlobal();
      ApplicationContext ac = (ApplicationContext) 
global.get(APPLICATION_CONTEXT_KEY);
      if (ac == null)
      {
         ac = 
WebApplicationContextUtils.getWebApplicationContext(context.getServlet().getServletContext());
         global.put(APPLICATION_CONTEXT_KEY, ac);
      }
   }


when i'm in a page and want to access a bean in a generic way i just do:

(((MyBeansInterface)((MyEngine)getEngine()).getBean(MyBeansInterface.BEAN_ID)).someMethodFromMyBean();


or you can implement accessor methods in the engine class like:

public MyBeansInterface getMyBean()
{
      
(MyBeansInterface)getApplicationContext().getBean(MyBeansInterface.BEAN_ID);
}


Cheers

Hugo

Stephen Robinson wrote:

> Is this the link?
> http://www.springframework.org/docs/reference/view.html#view-tapestry
>
> I've already implemented the engine that places the application 
> context in the global object - however I was hoping that I wouldn't 
> have to add the property hardcoding to each page as described in their 
> previous emails. The problem with creating my own global object was 
> that it would conflict with the MyEngine example. Here's something 
> that seems to be working for me now - although because it doesn't 
> implement the Map you can access from within the actual pages but 
> that's not a problem for my app (at the moment).
>
> In the spirit of plowing back any knowledge that I may or may not have 
> learned, here's my very basic solution :)
>
> ************ Web.xml ****************
>    <context-param>
>        <param-name>contextConfigLocation</param-name>
>        
> <param-value>classpath:/com/mybiz/objects/spring/applicationContext.xml</param-value> 
>
>    </context-param>
>
>    <!-- Spring Open Session In View Pattern filter -->      <filter>
>        <filter-name>hibernateFilter</filter-name>
>        
> <filter-class>org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class> 
>
>    </filter>
>    <!-- Spring/Hibernate filter mappings -->
>    <filter-mapping>
>        <filter-name>hibernateFilter</filter-name>
>        <url-pattern>/app/*</url-pattern>
>    </filter-mapping>
>
>    <!-- Listeners -->
>    <listener>
>        
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
>
>    </listener>
>
> ************ MyApp.application ****************
> <application name="mybiz" 
> engine-class="com.mybiz.objects.spring.MyEngine">
>    <description>My Application</description>
>    <property name="org.apache.tapestry.global-class" 
> value="com.mybiz.tapestry.MyGlobal"/>
> ....
>
> ************ MyGlobal ****************
> public class MyGlobal implements Serializable{
>    private ApplicationContext appContext;
>      public SiteServicesDAO SiteServicesDAO (){
>        SiteServicesDAO siteServicesDAO = (SiteServicesDAO) 
> getApplicationContext().getBean("siteServicesDAO ");
>        return siteServicesDAO ;
>    }
>    public ApplicationContext getApplicationContext(){
>        return appContext;
>    }
>    public void setApplicationContext(ApplicationContext appContext){
>        this.appContext = appContext;
>    }
> }
>
> ************ MyEngine ****************
> public class MyEngine extends BaseEngine {
>
>    /**
>     * @see 
> org.apache.tapestry.engine.AbstractEngine#setupForRequest(org.apache.tapestry.request.RequestContext) 
>
>     */
>    protected void setupForRequest(RequestContext context) {
>        super.setupForRequest(context);
>           // insert ApplicationContext in global, if not there
>        MyGlobal myGlobal = (MyGlobal) getGlobal();
>        ApplicationContext ac = (ApplicationContext) 
> myGlobal.getApplicationContext();
>        if (ac == null) {
>            ac = WebApplicationContextUtils.getWebApplicationContext(
>                context.getServlet().getServletContext()
>            );
>            myGlobal.setApplicationContext(ac);
>        }
>    }
> }
>
> ************ In The Java Code for MyPage I can do the 
> following****************
>            MyGlobal myGlobal = (MyGlobal) getGlobal();
>            member = 
> myGlobal.siteServicesDAO().findSomeObjectByName(name);
>
>
> Hugo Palma wrote:
>
>> eheh, sorry about the link......
>> Here's the correct one 
>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>>
>>
>> Hugo Palma wrote:
>>
>>> Check the spring documentation 
>>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>>>
>>> It's the engine that places the aplication context in the glogal 
>>> object.
>>>
>>>
>>> Cheers
>>>
>>> Hugo
>>>
>>>
>>> Stephen Robinson wrote:
>>>
>>>> That looks like a neat solution, but could you help me with that 
>>>> last step. When you add this function to your global-class object....
>>>>
>>>> >public SiteServices getSiteServices(){
>>>> >    return (SiteServices)appContext.getBean("siteServices");
>>>> >}
>>>>
>>>> How does it know where to get the appContext? From within my java 
>>>> class that extends BasePage I have successfully done the following....
>>>>
>>>> WebApplicationContext appContext =
>>>> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext()); 
>>>>
>>>> SiteServices siteServices = (SiteServices) 
>>>> appContext.getBean("siteServices");
>>>>
>>>> This works because I have access to the SerletContext at that 
>>>> point. When I call the global object do I have to set the 
>>>> appContext? Do I have to do this each call, or is it magically 
>>>> accessible some other way :)
>>>>
>>>> Steve
>>>>
>>>> Jonny Wray wrote:
>>>>
>>>>> Well, I'm using Spring beans and call backs on my login page, so 
>>>>> it can
>>>>> work.
>>>>>
>>>>> The only difference I can tell from your description is the way I
>>>>> access  my Spring beans. I didn't like the "injection" solution given
>>>>> in the Spring docs of specifying a page property. I ended up with
>>>>> multiple pages with the same page property hardcoding the same bean
>>>>> name. So, in my global I have a helper method for each service, eg
>>>>>
>>>>> public SiteServices getSiteServices(){
>>>>>    return (SiteServices)appContext.getBean("siteServices");
>>>>> }
>>>>>
>>>>> this allows any page to access services in a type safe manner and I
>>>>> only have the bean name hardcoded in one place.
>>>>>
>>>>> No idea if that's the cause of you problem though.
>>>>> Jonny
>>>>>
>>>>>
>>>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>>>>
>>>>>  
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>>  I have this problem that drives me crazy.
>>>>>> In my Tapestry classes I use service beans injected by Spring and it
>>>>>> all
>>>>>> works ok, except when I try to call Login page using PageCallback
>>>>>>
>>>>>> I always get this runtime exception:
>>>>>> /Unable to initialize property siteServices of
>>>>>>   
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]: 
>>>>>
>>>>>  
>>>>>
>>>>>> Unable to read expression '<parsed expression>' of
>>>>>>   
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]. 
>>>>>
>>>>>  
>>>>>
>>>>>> /Login.page has property:
>>>>>> /<property-specification name="siteServices" 
>>>>>> type="com.aspectcms.service.core.SiteServices">
>>>>>>      global.appContext.getBean("siteServices")
>>>>>>  </property-specification>/
>>>>>>
>>>>>> In debug I see that error comes from my ACMSBasePage (which 
>>>>>> extends BasePage and implements PageValidateListener),
>>>>>> where I redirect to Login page if user is not logged in:
>>>>>>
>>>>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>>>>> login.setCallback(new PageCallback(this));
>>>>>> throw new PageRedirectException(login);   /
>>>>>>
>>>>>> Am I doing something wrong or there is a problem with calling 
>>>>>> Spring beans when using PageCallback?
>>>>>>
>>>>>>
>>>>>> 10x in advance.
>>>>>> Nemanja.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>   
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>
>>
>> .
>>
>
>
> ---------------------------------------------------------------------
> 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: Tapestry + Spring problem...

Posted by Damian Krzeminski <dk...@pingtel.com>.
Daniel Serodio wrote:

> Damian, I'm a beginner on both Tapestry and Spring, but your solution 
> seems better than Spring's recommendation. Have you contacted the 
> Spring folks about it?
>
No I have not.
I am not sure if there is a "best" or "correct" way of integrating 
Tapestry and Spring. The method that we implemented seems to work quite 
well, especially if you want to access Spring beans as easily as 
Tapestry page beans.
The way I see it, it's just one more option. I am glad that you like it.
D.

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


Re: Tapestry + Spring problem...

Posted by Daniel Serodio <ds...@mandic.com.br>.
Damian, I'm a beginner on both Tapestry and Spring, but your solution 
seems better than Spring's recommendation. Have you contacted the Spring 
folks about it?

TIA,
Daniel Serodio

Damian Krzeminski wrote:

> Stephen Robinson wrote:
>
>> Is this the link?
>> http://www.springframework.org/docs/reference/view.html#view-tapestry
>>
>> I've already implemented the engine that places the application 
>> context in the global object - however I was hoping that I wouldn't 
>> have to add the property hardcoding to each page as described in 
>> their previous emails. The problem with creating my own global object 
>> was that it would conflict with the MyEngine example. Here's 
>> something that seems to be working for me now - although because it 
>> doesn't implement the Map you can access from within the actual pages 
>> but that's not a problem for my app (at the moment).
>>
>
> We actually went a step further and did implement Map interface in our 
> "Globals" class:
>
> public class BeanFactoryGlobals implements Map {
>     private WebApplicationContext m_applicationContext;
>
>     public WebApplicationContext getApplicationContext() {
>         return m_applicationContext;
>     }
>
>     public void setApplicationContext(WebApplicationContext 
> applicationContext) {
>         m_applicationContext = applicationContext;
>     }
>
>     public Object get(Object key) {
>         return m_applicationContext.getBean((String) key);
>     }
>
> //.... removed
> }
>
> If you only using globals to access your spring beans it allows you to 
> use OGNL expressions
>
> global.beanName
>
> instead of
>
> global.applicationContext.getBean("beanName")
>
>
> Also instead of overwriting setupForRequest as Spring doc suggests you 
> can just overwrite
> createGlobal in your engine to insert applicationContext in the 
> "globals" object.
>
> Full examples are on http://www.sipfoundry.org - sipXconfig project.
> engine:
> http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/SipxconfigEngine.java 
>
>
> globals:
> http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/BeanFactoryGlobals.java 
>
>
> Feel free to adjust to your needs.
> Damian
>

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


Re: Tapestry + Spring problem...

Posted by Damian Krzeminski <dk...@pingtel.com>.
Stephen Robinson wrote:
> Is this the link?
> http://www.springframework.org/docs/reference/view.html#view-tapestry
> 
> I've already implemented the engine that places the application context 
> in the global object - however I was hoping that I wouldn't have to add 
> the property hardcoding to each page as described in their previous 
> emails. The problem with creating my own global object was that it would 
> conflict with the MyEngine example. Here's something that seems to be 
> working for me now - although because it doesn't implement the Map you 
> can access from within the actual pages but that's not a problem for my 
> app (at the moment).
> 

We actually went a step further and did implement Map interface in our "Globals" class:

public class BeanFactoryGlobals implements Map {
     private WebApplicationContext m_applicationContext;

     public WebApplicationContext getApplicationContext() {
         return m_applicationContext;
     }

     public void setApplicationContext(WebApplicationContext applicationContext) {
         m_applicationContext = applicationContext;
     }

     public Object get(Object key) {
         return m_applicationContext.getBean((String) key);
     }

//.... removed
}

If you only using globals to access your spring beans it allows you to use OGNL expressions

global.beanName

instead of

global.applicationContext.getBean("beanName")


Also instead of overwriting setupForRequest as Spring doc suggests you can just overwrite
createGlobal in your engine to insert applicationContext in the "globals" object.

Full examples are on http://www.sipfoundry.org - sipXconfig project.
engine:
http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/SipxconfigEngine.java

globals:
http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/BeanFactoryGlobals.java

Feel free to adjust to your needs.
Damian














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


Re: Tapestry + Spring problem...

Posted by Damian Krzeminski <dk...@pingtel.com>.
Stephen Robinson wrote:
> Is this the link?
> http://www.springframework.org/docs/reference/view.html#view-tapestry
> 
> I've already implemented the engine that places the application context 
> in the global object - however I was hoping that I wouldn't have to add 
> the property hardcoding to each page as described in their previous 
> emails. The problem with creating my own global object was that it would 
> conflict with the MyEngine example. Here's something that seems to be 
> working for me now - although because it doesn't implement the Map you 
> can access from within the actual pages but that's not a problem for my 
> app (at the moment).
> 

We actually went a step further and implemented Map interface in our "Globals" class:

public class BeanFactoryGlobals implements Map {
     private WebApplicationContext m_applicationContext;

     public WebApplicationContext getApplicationContext() {
         return m_applicationContext;
     }

     public void setApplicationContext(WebApplicationContext applicationContext) {
         m_applicationContext = applicationContext;
     }

     public Object get(Object key) {
         return m_applicationContext.getBean((String) key);
     }

//.... removed
}

If you only using globals to access your spring beans it allows you to use OGNL expressions

global.beanName

instead of

global.applicationContext.getBean("beanName")


Also instead of overwriting setupForRequest as Spring doc suggests you can just overwrite 
createGlobal in your engine to insert applicationContext in the "globals" object.

Full examples are on http://www.sipfoundry.org - sipXconfig project.
engine: 
http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/SipxconfigEngine.java

globals:
http://scm.sipfoundry.org/rep/sipXconfig/main/web/src/org/sipfoundry/sipxconfig/site/BeanFactoryGlobals.java

Feel free to adjust to your needs.
Damian













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


Re: Tapestry + Spring problem...

Posted by Stephen Robinson <ro...@yellowpen.com>.
Is this the link?
http://www.springframework.org/docs/reference/view.html#view-tapestry

I've already implemented the engine that places the application context 
in the global object - however I was hoping that I wouldn't have to add 
the property hardcoding to each page as described in their previous 
emails. The problem with creating my own global object was that it would 
conflict with the MyEngine example. Here's something that seems to be 
working for me now - although because it doesn't implement the Map you 
can access from within the actual pages but that's not a problem for my 
app (at the moment).

In the spirit of plowing back any knowledge that I may or may not have 
learned, here's my very basic solution :)

************ Web.xml ****************
    <context-param>
        <param-name>contextConfigLocation</param-name>
        
<param-value>classpath:/com/mybiz/objects/spring/applicationContext.xml</param-value>
    </context-param>

    <!-- Spring Open Session In View Pattern filter -->   
    <filter>
        <filter-name>hibernateFilter</filter-name>
        
<filter-class>org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <!-- Spring/Hibernate filter mappings -->
    <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <!-- Listeners -->
    <listener>
        
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

************ MyApp.application ****************
<application name="mybiz" engine-class="com.mybiz.objects.spring.MyEngine">
    <description>My Application</description>
    <property name="org.apache.tapestry.global-class" 
value="com.mybiz.tapestry.MyGlobal"/>
....

************ MyGlobal ****************
public class MyGlobal implements Serializable{
    private ApplicationContext appContext;
   
    public SiteServicesDAO SiteServicesDAO (){
        SiteServicesDAO siteServicesDAO = (SiteServicesDAO) 
getApplicationContext().getBean("siteServicesDAO ");
        return siteServicesDAO ;
    }
    public ApplicationContext getApplicationContext(){
        return appContext;
    }
    public void setApplicationContext(ApplicationContext appContext){
        this.appContext = appContext;
    }
}

************ MyEngine ****************
public class MyEngine extends BaseEngine {
 
    /**
     * @see 
org.apache.tapestry.engine.AbstractEngine#setupForRequest(org.apache.tapestry.request.RequestContext)
     */
    protected void setupForRequest(RequestContext context) {
        super.setupForRequest(context);
    
        // insert ApplicationContext in global, if not there
        MyGlobal myGlobal = (MyGlobal) getGlobal();
        ApplicationContext ac = (ApplicationContext) 
myGlobal.getApplicationContext();
        if (ac == null) {
            ac = WebApplicationContextUtils.getWebApplicationContext(
                context.getServlet().getServletContext()
            );
            myGlobal.setApplicationContext(ac);
        }
    }
}

************ In The Java Code for MyPage I can do the 
following****************
            MyGlobal myGlobal = (MyGlobal) getGlobal();
            member = myGlobal.siteServicesDAO().findSomeObjectByName(name);


Hugo Palma wrote:

> eheh, sorry about the link......
> Here's the correct one 
> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>
>
> Hugo Palma wrote:
>
>> Check the spring documentation 
>> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>>
>> It's the engine that places the aplication context in the glogal object.
>>
>>
>> Cheers
>>
>> Hugo
>>
>>
>> Stephen Robinson wrote:
>>
>>> That looks like a neat solution, but could you help me with that 
>>> last step. When you add this function to your global-class object....
>>>
>>> >public SiteServices getSiteServices(){
>>> >    return (SiteServices)appContext.getBean("siteServices");
>>> >}
>>>
>>> How does it know where to get the appContext? From within my java 
>>> class that extends BasePage I have successfully done the following....
>>>
>>> WebApplicationContext appContext =
>>> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext()); 
>>>
>>> SiteServices siteServices = (SiteServices) 
>>> appContext.getBean("siteServices");
>>>
>>> This works because I have access to the SerletContext at that point. 
>>> When I call the global object do I have to set the appContext? Do I 
>>> have to do this each call, or is it magically accessible some other 
>>> way :)
>>>
>>> Steve
>>>
>>> Jonny Wray wrote:
>>>
>>>> Well, I'm using Spring beans and call backs on my login page, so it 
>>>> can
>>>> work.
>>>>
>>>> The only difference I can tell from your description is the way I
>>>> access  my Spring beans. I didn't like the "injection" solution given
>>>> in the Spring docs of specifying a page property. I ended up with
>>>> multiple pages with the same page property hardcoding the same bean
>>>> name. So, in my global I have a helper method for each service, eg
>>>>
>>>> public SiteServices getSiteServices(){
>>>>    return (SiteServices)appContext.getBean("siteServices");
>>>> }
>>>>
>>>> this allows any page to access services in a type safe manner and I
>>>> only have the bean name hardcoded in one place.
>>>>
>>>> No idea if that's the cause of you problem though.
>>>> Jonny
>>>>
>>>>
>>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>>>
>>>>  
>>>>
>>>>> Hi all,
>>>>>
>>>>>  I have this problem that drives me crazy.
>>>>> In my Tapestry classes I use service beans injected by Spring and it
>>>>> all
>>>>> works ok, except when I try to call Login page using PageCallback
>>>>>
>>>>> I always get this runtime exception:
>>>>> /Unable to initialize property siteServices of
>>>>>   
>>>>
>>>>
>>>>
>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]: 
>>>>
>>>>  
>>>>
>>>>> Unable to read expression '<parsed expression>' of
>>>>>   
>>>>
>>>>
>>>>
>>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]. 
>>>>
>>>>  
>>>>
>>>>> /Login.page has property:
>>>>> /<property-specification name="siteServices" 
>>>>> type="com.aspectcms.service.core.SiteServices">
>>>>>      global.appContext.getBean("siteServices")
>>>>>  </property-specification>/
>>>>>
>>>>> In debug I see that error comes from my ACMSBasePage (which 
>>>>> extends BasePage and implements PageValidateListener),
>>>>> where I redirect to Login page if user is not logged in:
>>>>>
>>>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>>>> login.setCallback(new PageCallback(this));
>>>>> throw new PageRedirectException(login);   /
>>>>>
>>>>> Am I doing something wrong or there is a problem with calling 
>>>>> Spring beans when using PageCallback?
>>>>>
>>>>>
>>>>> 10x in advance.
>>>>> Nemanja.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>
>
> .
>


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


Re: Tapestry + Spring problem...

Posted by Hugo Palma <hp...@digitalis.pt>.
eheh, sorry about the link......
Here's the correct one 
file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx

Hugo Palma wrote:

> Check the spring documentation 
> file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx 
>
> It's the engine that places the aplication context in the glogal object.
>
>
> Cheers
>
> Hugo
>
>
> Stephen Robinson wrote:
>
>> That looks like a neat solution, but could you help me with that last 
>> step. When you add this function to your global-class object....
>>
>> >public SiteServices getSiteServices(){
>> >    return (SiteServices)appContext.getBean("siteServices");
>> >}
>>
>> How does it know where to get the appContext? From within my java 
>> class that extends BasePage I have successfully done the following....
>>
>> WebApplicationContext appContext =
>> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext()); 
>>
>> SiteServices siteServices = (SiteServices) 
>> appContext.getBean("siteServices");
>>
>> This works because I have access to the SerletContext at that point. 
>> When I call the global object do I have to set the appContext? Do I 
>> have to do this each call, or is it magically accessible some other 
>> way :)
>>
>> Steve
>>
>> Jonny Wray wrote:
>>
>>> Well, I'm using Spring beans and call backs on my login page, so it can
>>> work.
>>>
>>> The only difference I can tell from your description is the way I
>>> access  my Spring beans. I didn't like the "injection" solution given
>>> in the Spring docs of specifying a page property. I ended up with
>>> multiple pages with the same page property hardcoding the same bean
>>> name. So, in my global I have a helper method for each service, eg
>>>
>>> public SiteServices getSiteServices(){
>>>    return (SiteServices)appContext.getBean("siteServices");
>>> }
>>>
>>> this allows any page to access services in a type safe manner and I
>>> only have the bean name hardcoded in one place.
>>>
>>> No idea if that's the cause of you problem though.
>>> Jonny
>>>
>>>
>>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>>
>>>  
>>>
>>>> Hi all,
>>>>
>>>>  I have this problem that drives me crazy.
>>>> In my Tapestry classes I use service beans injected by Spring and it
>>>> all
>>>> works ok, except when I try to call Login page using PageCallback
>>>>
>>>> I always get this runtime exception:
>>>> /Unable to initialize property siteServices of
>>>>   
>>>
>>>
>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
>>>  
>>>
>>>> Unable to read expression '<parsed expression>' of
>>>>   
>>>
>>>
>>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
>>>  
>>>
>>>> /Login.page has property:
>>>> /<property-specification name="siteServices" 
>>>> type="com.aspectcms.service.core.SiteServices">
>>>>      global.appContext.getBean("siteServices")
>>>>  </property-specification>/
>>>>
>>>> In debug I see that error comes from my ACMSBasePage (which extends 
>>>> BasePage and implements PageValidateListener),
>>>> where I redirect to Login page if user is not logged in:
>>>>
>>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>>> login.setCallback(new PageCallback(this));
>>>> throw new PageRedirectException(login);   /
>>>>
>>>> Am I doing something wrong or there is a problem with calling 
>>>> Spring beans when using PageCallback?
>>>>
>>>>
>>>> 10x in advance.
>>>> Nemanja.
>>>>
>>>>
>>>>
>>>>
>>>>   
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: Tapestry + Spring problem...

Posted by Hugo Palma <hp...@digitalis.pt>.
Check the spring documentation 
file:///c:/java/spring-framework-1.1.4/docs/reference/html_single/index.html#view-tapestry-exposeappctx
It's the engine that places the aplication context in the glogal object.


Cheers

Hugo


Stephen Robinson wrote:

> That looks like a neat solution, but could you help me with that last 
> step. When you add this function to your global-class object....
>
> >public SiteServices getSiteServices(){
> >    return (SiteServices)appContext.getBean("siteServices");
> >}
>
> How does it know where to get the appContext? From within my java 
> class that extends BasePage I have successfully done the following....
>
> WebApplicationContext appContext =
> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext()); 
>
> SiteServices siteServices = (SiteServices) 
> appContext.getBean("siteServices");
>
> This works because I have access to the SerletContext at that point. 
> When I call the global object do I have to set the appContext? Do I 
> have to do this each call, or is it magically accessible some other 
> way :)
>
> Steve
>
> Jonny Wray wrote:
>
>> Well, I'm using Spring beans and call backs on my login page, so it can
>> work.
>>
>> The only difference I can tell from your description is the way I
>> access  my Spring beans. I didn't like the "injection" solution given
>> in the Spring docs of specifying a page property. I ended up with
>> multiple pages with the same page property hardcoding the same bean
>> name. So, in my global I have a helper method for each service, eg
>>
>> public SiteServices getSiteServices(){
>>    return (SiteServices)appContext.getBean("siteServices");
>> }
>>
>> this allows any page to access services in a type safe manner and I
>> only have the bean name hardcoded in one place.
>>
>> No idea if that's the cause of you problem though.
>> Jonny
>>
>>
>> --- Nemanja Kostic <n....@youngculture.com> wrote:
>>
>>  
>>
>>> Hi all,
>>>
>>>  I have this problem that drives me crazy.
>>> In my Tapestry classes I use service beans injected by Spring and it
>>> all
>>> works ok, except when I try to call Login page using PageCallback
>>>
>>> I always get this runtime exception:
>>> /Unable to initialize property siteServices of
>>>   
>>
>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
>>  
>>
>>> Unable to read expression '<parsed expression>' of
>>>   
>>
>> com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
>>  
>>
>>> /Login.page has property:
>>> /<property-specification name="siteServices" 
>>> type="com.aspectcms.service.core.SiteServices">
>>>      global.appContext.getBean("siteServices")
>>>  </property-specification>/
>>>
>>> In debug I see that error comes from my ACMSBasePage (which extends 
>>> BasePage and implements PageValidateListener),
>>> where I redirect to Login page if user is not logged in:
>>>
>>> /Login login = (Login) getRequestCycle().getPage("Login");
>>> login.setCallback(new PageCallback(this));
>>> throw new PageRedirectException(login);   /
>>>
>>> Am I doing something wrong or there is a problem with calling Spring 
>>> beans when using PageCallback?
>>>
>>>
>>> 10x in advance.
>>> Nemanja.
>>>
>>>
>>>
>>>
>>>   
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Tapestry + Spring problem...

Posted by Ashish Raniwala <ar...@gmail.com>.
Yes this makes perfect sense.
Thanks,
Ashish

----- Original Message ----- 
From: "Maik Dobryn" <ma...@dobryn.de>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, February 13, 2005 1:15 PM
Subject: Re: Tapestry + Spring problem...


> Hi Ashish,
>
> Provide all utility classes as Spring beans connected through the 
> dependency
> injection mechanism. So no utility class has to "call" another service.
>
> In your case the component would call the TreeDataModel service from the
> servlet contex. In this way the Tapestry view layer stands thin upon the
> Spring service layer.
>
> Regards
>
> Maik
>
>
> On Friday 11 February 2005 20:05, Ashish Raniwala wrote:
>> Guys,
>> This might be very basic question but I am stuck on this from long time.
>> I can access Spring beans by injection solution but if I want to access
>> these beans in simple utility classes which does not have access to
>> ServletContext or BasePage or any tapestry global objects how to do it? 
>> One
>> quick and dirty solution could be caller set servletcontext as the 
>> property
>> of these utility classes but I guess its not the right way to do it.
>>
>> I need this for tapestry tree component where data model, which is not a
>> tapestry component, need to call service methods.
>>
>> Thanks,
>> Ashish
>>
>
>
> -- 
>
>  Maik  D o b r y n
> ____________________________________________
>
>  Email : maik@dobryn.de
> ____________________________________________
>
>
> ---------------------------------------------------------------------
> 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: Tapestry + Spring problem...

Posted by Maik Dobryn <ma...@dobryn.de>.
Hi Ashish,

Provide all utility classes as Spring beans connected through the dependency 
injection mechanism. So no utility class has to "call" another service.

In your case the component would call the TreeDataModel service from the 
servlet contex. In this way the Tapestry view layer stands thin upon the 
Spring service layer.

Regards

Maik


On Friday 11 February 2005 20:05, Ashish Raniwala wrote:
> Guys,
> This might be very basic question but I am stuck on this from long time.
> I can access Spring beans by injection solution but if I want to access
> these beans in simple utility classes which does not have access to
> ServletContext or BasePage or any tapestry global objects how to do it? One
> quick and dirty solution could be caller set servletcontext as the property
> of these utility classes but I guess its not the right way to do it.
>
> I need this for tapestry tree component where data model, which is not a
> tapestry component, need to call service methods.
>
> Thanks,
> Ashish
>


-- 

  Maik  D o b r y n
____________________________________________

  Email : maik@dobryn.de
____________________________________________


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


Re: Tapestry + Spring problem...

Posted by Ashish Raniwala <ar...@gmail.com>.
Guys,
This might be very basic question but I am stuck on this from long time.
I can access Spring beans by injection solution but if I want to access 
these beans in simple utility classes which does not have access to 
ServletContext or BasePage or any tapestry global objects how to do it? One 
quick and dirty solution could be caller set servletcontext as the property 
of these utility classes but I guess its not the right way to do it.

I need this for tapestry tree component where data model, which is not a 
tapestry component, need to call service methods.

Thanks,
Ashish

----- Original Message ----- 
From: "Stephen Robinson" <ro...@yellowpen.com>
To: <jo...@yahoo.com>
Cc: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, February 11, 2005 9:04 AM
Subject: Re: Tapestry + Spring problem...


> That looks like a neat solution, but could you help me with that last 
> step. When you add this function to your global-class object....
>
> >public SiteServices getSiteServices(){
> >    return (SiteServices)appContext.getBean("siteServices");
> >}
>
> How does it know where to get the appContext? From within my java class 
> that extends BasePage I have successfully done the following....
>
> WebApplicationContext appContext =
> WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext());
> SiteServices siteServices = (SiteServices) 
> appContext.getBean("siteServices");
>
> This works because I have access to the SerletContext at that point. When 
> I call the global object do I have to set the appContext? Do I have to do 
> this each call, or is it magically accessible some other way :)
>
> Steve
>
> Jonny Wray wrote:
>
>>Well, I'm using Spring beans and call backs on my login page, so it can
>>work.
>>
>>The only difference I can tell from your description is the way I
>>access  my Spring beans. I didn't like the "injection" solution given
>>in the Spring docs of specifying a page property. I ended up with
>>multiple pages with the same page property hardcoding the same bean
>>name. So, in my global I have a helper method for each service, eg
>>
>>public SiteServices getSiteServices(){
>>    return (SiteServices)appContext.getBean("siteServices");
>>}
>>
>>this allows any page to access services in a type safe manner and I
>>only have the bean name hardcoded in one place.
>>
>>No idea if that's the cause of you problem though.
>>Jonny
>>
>>
>>--- Nemanja Kostic <n....@youngculture.com> wrote:
>>
>>
>>>Hi all,
>>>
>>>  I have this problem that drives me crazy.
>>>In my Tapestry classes I use service beans injected by Spring and it
>>>all
>>>works ok, except when I try to call Login page using PageCallback
>>>
>>>I always get this runtime exception:
>>>/Unable to initialize property siteServices of
>>>
>>com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
>>
>>>Unable to read expression '<parsed expression>' of
>>>
>>com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
>>
>>>/Login.page has property:
>>>/<property-specification name="siteServices" 
>>>type="com.aspectcms.service.core.SiteServices">
>>>      global.appContext.getBean("siteServices")
>>>  </property-specification>/
>>>
>>>In debug I see that error comes from my ACMSBasePage (which extends 
>>>BasePage and implements PageValidateListener),
>>>where I redirect to Login page if user is not logged in:
>>>
>>>/Login login = (Login) getRequestCycle().getPage("Login");
>>>login.setCallback(new PageCallback(this));
>>>throw new PageRedirectException(login);   /
>>>
>>>Am I doing something wrong or there is a problem with calling Spring 
>>>beans when using PageCallback?
>>>
>>>
>>>10x in advance.
>>>Nemanja.
>>>
>>>
>>>
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>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: Tapestry + Spring problem...

Posted by Stephen Robinson <ro...@yellowpen.com>.
That looks like a neat solution, but could you help me with that last 
step. When you add this function to your global-class object....

 >public SiteServices getSiteServices(){
 >    return (SiteServices)appContext.getBean("siteServices");
 >}

How does it know where to get the appContext? From within my java class 
that extends BasePage I have successfully done the following....

WebApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(getRequestCycle().getRequestContext().getServlet().getServletContext());
SiteServices siteServices = (SiteServices) 
appContext.getBean("siteServices");

This works because I have access to the SerletContext at that point. 
When I call the global object do I have to set the appContext? Do I have 
to do this each call, or is it magically accessible some other way :)

Steve

Jonny Wray wrote:

>Well, I'm using Spring beans and call backs on my login page, so it can
>work.
>
>The only difference I can tell from your description is the way I
>access  my Spring beans. I didn't like the "injection" solution given
>in the Spring docs of specifying a page property. I ended up with
>multiple pages with the same page property hardcoding the same bean
>name. So, in my global I have a helper method for each service, eg
>
>public SiteServices getSiteServices(){
>    return (SiteServices)appContext.getBean("siteServices");
>}
>
>this allows any page to access services in a type safe manner and I
>only have the bean name hardcoded in one place.
>
>No idea if that's the cause of you problem though.
>Jonny
>
>
>--- Nemanja Kostic <n....@youngculture.com> wrote:
>
>  
>
>>Hi all,
>>
>>  I have this problem that drives me crazy.
>>In my Tapestry classes I use service beans injected by Spring and it
>>all
>>works ok, except when I try to call Login page using PageCallback
>>
>>I always get this runtime exception:
>>/Unable to initialize property siteServices of 
>>
>>    
>>
>com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
>  
>
>>Unable to read expression '<parsed expression>' of 
>>
>>    
>>
>com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
>  
>
>>/Login.page has property:
>>/<property-specification name="siteServices" 
>>type="com.aspectcms.service.core.SiteServices">
>>      global.appContext.getBean("siteServices")
>>  </property-specification>/
>>
>>In debug I see that error comes from my ACMSBasePage (which extends 
>>BasePage and implements PageValidateListener),
>>where I redirect to Login page if user is not logged in:
>>
>>/Login login = (Login) getRequestCycle().getPage("Login");
>>login.setCallback(new PageCallback(this));
>>throw new PageRedirectException(login);   / 
>>
>>
>>Am I doing something wrong or there is a problem with calling Spring 
>>beans when using PageCallback?
>>
>>
>>10x in advance.
>>Nemanja.
>>
>>
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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: Tapestry + Spring problem...

Posted by Jonny Wray <jo...@yahoo.com>.
Well, I'm using Spring beans and call backs on my login page, so it can
work.

The only difference I can tell from your description is the way I
access  my Spring beans. I didn't like the "injection" solution given
in the Spring docs of specifying a page property. I ended up with
multiple pages with the same page property hardcoding the same bean
name. So, in my global I have a helper method for each service, eg

public SiteServices getSiteServices(){
    return (SiteServices)appContext.getBean("siteServices");
}

this allows any page to access services in a type safe manner and I
only have the bean name hardcoded in one place.

No idea if that's the cause of you problem though.
Jonny


--- Nemanja Kostic <n....@youngculture.com> wrote:

> Hi all,
> 
>   I have this problem that drives me crazy.
> In my Tapestry classes I use service beans injected by Spring and it
> all
> works ok, except when I try to call Login page using PageCallback
> 
> I always get this runtime exception:
> /Unable to initialize property siteServices of 
>
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login]:
> 
> Unable to read expression '<parsed expression>' of 
>
com.aspectcms.view.tapestry.pages.login.Login$Enhance_0@1108727[Login].
> 
> /Login.page has property:
> /<property-specification name="siteServices" 
> type="com.aspectcms.service.core.SiteServices">
>       global.appContext.getBean("siteServices")
>   </property-specification>/
> 
> In debug I see that error comes from my ACMSBasePage (which extends 
> BasePage and implements PageValidateListener),
> where I redirect to Login page if user is not logged in:
> 
> /Login login = (Login) getRequestCycle().getPage("Login");
> login.setCallback(new PageCallback(this));
> throw new PageRedirectException(login);   / 
> 
> 
> Am I doing something wrong or there is a problem with calling Spring 
> beans when using PageCallback?
> 
> 
> 10x in advance.
> Nemanja.
> 
> 
> 
> 


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