|
From: Keith D. <ke...@in...> - 2005-06-01 00:30:40
|
Is there an easy way to invoke methods on a bean exported in the Spring application context from a view? It'd be quite useful for this app I'm building. I reckon I could just stick the service I want to expose into the model but it'd be cool to have the whole context in there in this case.. I know we also want this capability in web flow definitions as well. Keith |
|
From: Juergen H. <ju...@in...> - 2005-06-01 18:58:33
|
Keith, If you define your View instances as beans (using XmlViewResolver or ResourceBundleViewResolver), you can wire them with anything you want, using standard Spring bean references. However, if you're using a UrlBasedViewResolver, this is not available because of the different View instantiation model there. You can do ApplicationContext lookups in an ApplicationContextAware view, though. What concretely do you want to pass to a View instance? Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Keith Donald Sent: Wednesday, June 01, 2005 2:31 AM To: spr...@li... Subject: [Springframework-developer] am I missing something Is there an easy way to invoke methods on a bean exported in the Spring application context from a view? It'd be quite useful for this app I'm building. I reckon I could just stick the service I want to expose into the model but it'd be cool to have the whole context in there in this case.. I know we also want this capability in web flow definitions as well. Keith |
|
From: Keith D. <ke...@in...> - 2005-06-02 07:49:15
|
Juergen,
I should clarify: I meant from a view template like a .jsp, not a mvc View
instance. Basically I have some beans in a flow-scoped application context.
Because the AC is in flow scope, I can access it like this from view
resources participating in the flow. Ideally I'd like to be able to invoke
arbitrary methods on certain beans, like this:
${transactionContext.transactionCoordinator.amountDeposited}, which would
translate to: ac.getBean("transactionCoordinator").getAmountDeposited().
Keith
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...] On Behalf Of
Juergen Hoeller
Sent: Wednesday, June 01, 2005 2:58 PM
To: spr...@li...
Subject: Re: [Springframework-developer] am I missing something
Keith,
If you define your View instances as beans (using XmlViewResolver or
ResourceBundleViewResolver), you can wire them with anything you want, using
standard Spring bean references.
However, if you're using a UrlBasedViewResolver, this is not available
because of the different View instantiation model there. You can do
ApplicationContext lookups in an ApplicationContextAware view, though.
What concretely do you want to pass to a View instance?
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf Of
Keith Donald
Sent: Wednesday, June 01, 2005 2:31 AM
To: spr...@li...
Subject: [Springframework-developer] am I missing something
Is there an easy way to invoke methods on a bean exported in the Spring
application context from a view? It'd be quite useful for this app I'm
building. I reckon I could just stick the service I want to expose into the
model but it'd be cool to have the whole context in there in this case.. I
know we also want this capability in web flow definitions as well.
Keith
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Colin S. <col...@ex...> - 2005-06-02 08:07:49
|
Well here you're getting into view templating technology. JSTL simply won't let you do arbitrary method invocations in expressions. This is a fundamental limitation you can't get around short of switching to another view technology (Velocity or FreeMarker for example will let you do method invocations in their expression language. In a JSP page you'll have to use a scriptlet instead (ughh!). The new JSP 2.1/JSTL also allow you to define accessor methods of some sort. It's still quite clunky and way to much work. I've had this argument (about how useless JSTL is) a number of times with people, most recently here: http://www.theserverside.com/news/thread.tss?thread_id=33990#171263 Keith Donald wrote: >Juergen, > >I should clarify: I meant from a view template like a .jsp, not a mvc View >instance. Basically I have some beans in a flow-scoped application context. >Because the AC is in flow scope, I can access it like this from view >resources participating in the flow. Ideally I'd like to be able to invoke >arbitrary methods on certain beans, like this: > >${transactionContext.transactionCoordinator.amountDeposited}, which would >translate to: ac.getBean("transactionCoordinator").getAmountDeposited(). > >Keith > >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...] On Behalf Of >Juergen Hoeller >Sent: Wednesday, June 01, 2005 2:58 PM >To: spr...@li... >Subject: Re: [Springframework-developer] am I missing something > >Keith, > >If you define your View instances as beans (using XmlViewResolver or >ResourceBundleViewResolver), you can wire them with anything you want, using >standard Spring bean references. > >However, if you're using a UrlBasedViewResolver, this is not available >because of the different View instantiation model there. You can do >ApplicationContext lookups in an ApplicationContextAware view, though. > >What concretely do you want to pass to a View instance? > >Juergen > > >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf Of >Keith Donald >Sent: Wednesday, June 01, 2005 2:31 AM >To: spr...@li... >Subject: [Springframework-developer] am I missing something > > >Is there an easy way to invoke methods on a bean exported in the Spring >application context from a view? It'd be quite useful for this app I'm >building. I reckon I could just stick the service I want to expose into the >model but it'd be cool to have the whole context in there in this case.. I >know we also want this capability in web flow definitions as well. > >Keith > > > > > >------------------------------------------------------- >This SF.Net email is sponsored by Yahoo. >Introducing Yahoo! Search Developer Network - Create apps using Yahoo! >Search APIs Find out how you can build Yahoo! directly into your own >Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > >------------------------------------------------------- >This SF.Net email is sponsored by Yahoo. >Introducing Yahoo! Search Developer Network - Create apps using Yahoo! >Search APIs Find out how you can build Yahoo! directly into your own >Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > > |
|
From: Erwin V. <erw...@er...> - 2005-06-02 09:08:19
|
You could write a simple custom tag that takes an OGNL expression and does
what you want to do. Something like:
<keith:out
value="${transactionContext.transactionCoordinator.amountDeposited}"/>
Erwin Vervaet
erw...@er...
----- Original Message -----
From: "Keith Donald" <ke...@in...>
To: <spr...@li...>
Sent: Thursday, June 02, 2005 9:49 AM
Subject: RE: [Springframework-developer] am I missing something
> Juergen,
>
> I should clarify: I meant from a view template like a .jsp, not a mvc View
> instance. Basically I have some beans in a flow-scoped application
> context.
> Because the AC is in flow scope, I can access it like this from view
> resources participating in the flow. Ideally I'd like to be able to
> invoke
> arbitrary methods on certain beans, like this:
>
> ${transactionContext.transactionCoordinator.amountDeposited}, which would
> translate to: ac.getBean("transactionCoordinator").getAmountDeposited().
>
> Keith
>
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...] On Behalf
> Of
> Juergen Hoeller
> Sent: Wednesday, June 01, 2005 2:58 PM
> To: spr...@li...
> Subject: Re: [Springframework-developer] am I missing something
>
> Keith,
>
> If you define your View instances as beans (using XmlViewResolver or
> ResourceBundleViewResolver), you can wire them with anything you want,
> using
> standard Spring bean references.
>
> However, if you're using a UrlBasedViewResolver, this is not available
> because of the different View instantiation model there. You can do
> ApplicationContext lookups in an ApplicationContextAware view, though.
>
> What concretely do you want to pass to a View instance?
>
> Juergen
>
>
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...]On Behalf Of
> Keith Donald
> Sent: Wednesday, June 01, 2005 2:31 AM
> To: spr...@li...
> Subject: [Springframework-developer] am I missing something
>
>
> Is there an easy way to invoke methods on a bean exported in the Spring
> application context from a view? It'd be quite useful for this app I'm
> building. I reckon I could just stick the service I want to expose into
> the
> model but it'd be cool to have the whole context in there in this case..
> I
> know we also want this capability in web flow definitions as well.
>
> Keith
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
|
|
From: J.Enrique Ruiz-V. <er...@di...> - 2005-06-02 09:35:12
Attachments:
DefineBeanTag.java
|
Hi Keith, we have developed a tag to put a bean in one scope of the
view. I have attached it, and I hope it will be what you need.
Usage example:
ApplicationContext:
<bean id="myBean" class="...">
...
</bean>
JSP View:
<%@ taglib prefix="dco" uri="http://www.disid.com/tags/dco" %>
<dco:defineBean name="myBean" var="mb" />
<c:out value="${mb.property}" />
>Juergen,
>
>I should clarify: I meant from a view template like a .jsp, not a mvc View
>instance. Basically I have some beans in a flow-scoped application context.
>Because the AC is in flow scope, I can access it like this from view
>resources participating in the flow. Ideally I'd like to be able to invoke
>arbitrary methods on certain beans, like this:
>
>${transactionContext.transactionCoordinator.amountDeposited}, which would
>translate to: ac.getBean("transactionCoordinator").getAmountDeposited().
>
>Keith
>
>-----Original Message-----
>From: spr...@li...
>[mailto:spr...@li...] On Behalf Of
>Juergen Hoeller
>Sent: Wednesday, June 01, 2005 2:58 PM
>To: spr...@li...
>Subject: Re: [Springframework-developer] am I missing something
>
>Keith,
>
>If you define your View instances as beans (using XmlViewResolver or
>ResourceBundleViewResolver), you can wire them with anything you want, using
>standard Spring bean references.
>
>However, if you're using a UrlBasedViewResolver, this is not available
>because of the different View instantiation model there. You can do
>ApplicationContext lookups in an ApplicationContextAware view, though.
>
>What concretely do you want to pass to a View instance?
>
>Juergen
>
>
>-----Original Message-----
>From: spr...@li...
>[mailto:spr...@li...]On Behalf Of
>Keith Donald
>Sent: Wednesday, June 01, 2005 2:31 AM
>To: spr...@li...
>Subject: [Springframework-developer] am I missing something
>
>
>Is there an easy way to invoke methods on a bean exported in the Spring
>application context from a view? It'd be quite useful for this app I'm
>building. I reckon I could just stick the service I want to expose into the
>model but it'd be cool to have the whole context in there in this case.. I
>know we also want this capability in web flow definitions as well.
>
>Keith
>
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by Yahoo.
>Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
>Search APIs Find out how you can build Yahoo! directly into your own
>Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by Yahoo.
>Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
>Search APIs Find out how you can build Yahoo! directly into your own
>Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
--
J.Enrique Ruiz-Valenciano
CIO, DiSiD S.L.L. (http://www.disid.com)
Email: er...@di...
|