|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Trouble calling action methods from FreeMarkerI'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. It
mostly works fine: my templates are retrieving bean information with no problem. However, I can't figure out how to call methods defined in my action classes. If my action class looks like this: public class MyAction extends MyActionSupport { public String getMyValue() { return "hello"; } public String myMethod() { return "world"; } } Then these things work: ${myValue} (indirect access to bean getter) ${myValue.toUpperCase()} (method call on object) <@s.property value="myMethod()"/> (Struts tag calling a method) But these things don't: ${myMethod()} ${getMyValue()} (plain method calls as described in the docs) Are public action methods not included in the data model for Freemarker, for some reason? The Freemarker docs (http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_methodcall) seem to indicate that they ought to be. Thanks for any help, Chris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Trouble calling action methods from FreeMarkerI guess no one recognizes the problem. Next question: Has anyone gotten
this (calling action methods from FreeMarker tags) to work successfully? Just trying to figure out whether the correct approach is to hammer on my configuration somehow, or to file a bug. Thanks, Chris On 11/9/2009 10:13 AM, Christopher Maloof wrote: > I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. It > mostly works fine: my templates are retrieving bean information with > no problem. However, I can't figure out how to call methods defined > in my action classes. > > If my action class looks like this: > > public class MyAction extends MyActionSupport { > public String getMyValue() { > return "hello"; > } > public String myMethod() { > return "world"; > } > } > > Then these things work: > ${myValue} (indirect access to bean getter) > ${myValue.toUpperCase()} (method call on object) > <@s.property value="myMethod()"/> (Struts tag calling a method) > > But these things don't: > ${myMethod()} > ${getMyValue()} (plain method calls as described in the docs) > > Are public action methods not included in the data model for > Freemarker, for some reason? The Freemarker docs > (http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_methodcall) > seem to indicate that they ought to be. > > Thanks for any help, > Chris > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Trouble calling action methods from FreeMarkerHi Chris,
See reply embedded below... On Today at 10:32am, CM=>Christopher Maloof <C_Maloof@...> wrote: CM> I guess no one recognizes the problem. Next question: Has anyone CM> gotten this (calling action methods from FreeMarker tags) to work CM> successfully? Just trying to figure out whether the correct approach CM> is to hammer on my configuration somehow, or to file a bug. CM> CM> Thanks, CM> Chris CM> CM> On 11/9/2009 10:13 AM, Christopher Maloof wrote: CM> > I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. It mostly CM> > works fine: my templates are retrieving bean information with no problem. CM> > However, I can't figure out how to call methods defined in my action CM> > classes. CM> > CM> > If my action class looks like this: CM> > CM> > public class MyAction extends MyActionSupport { CM> > public String getMyValue() { CM> > return "hello"; CM> > } CM> > public String myMethod() { CM> > return "world"; CM> > } CM> > } CM> > CM> > Then these things work: CM> > ${myValue} (indirect access to bean getter) CM> > ${myValue.toUpperCase()} (method call on object) CM> > <@s.property value="myMethod()"/> (Struts tag calling a method) CM> > CM> > But these things don't: CM> > ${myMethod()} CM> > ${getMyValue()} (plain method calls as described in the docs) CM> > Try: ${stack.findValue("getMyValue()")} ${stack.findValue("myMethod()")} Later, -- Haroon Rafique <haroon.rafique@...> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Trouble calling action methods from FreeMarkerThanks! I don't know what that's really doing, but it does work.
Adding parameters to the methods is a bit wonky; it's very difficult to get the syntax right for ${stack.findValue("getScore('${st.name()}')")} as opposed to the expected ${getScore(st.name())} but it's something. Maybe this should be added to http://struts.apache.org/2.x/docs/freemarker.html , assuming it's the intended behavior? The question's been asked of the list at least a couple other times this year: http://markmail.org/message/4ordiw724kvdw5d6 and http://markmail.org/message/jjkic23knjk5tnpx. Best, Chris On 11/10/2009 11:20 AM, Haroon Rafique wrote: > Hi Chris, > > See reply embedded below... > > On Today at 10:32am, CM=>Christopher Maloof<C_Maloof@...> wrote: > > CM> I guess no one recognizes the problem. Next question: Has anyone > CM> gotten this (calling action methods from FreeMarker tags) to work > CM> successfully? Just trying to figure out whether the correct approach > CM> is to hammer on my configuration somehow, or to file a bug. > CM> > CM> Thanks, > CM> Chris > CM> > CM> On 11/9/2009 10:13 AM, Christopher Maloof wrote: > CM> > I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. It mostly > CM> > works fine: my templates are retrieving bean information with no problem. > CM> > However, I can't figure out how to call methods defined in my action > CM> > classes. > CM> > > CM> > If my action class looks like this: > CM> > > CM> > public class MyAction extends MyActionSupport { > CM> > public String getMyValue() { > CM> > return "hello"; > CM> > } > CM> > public String myMethod() { > CM> > return "world"; > CM> > } > CM> > } > CM> > > CM> > Then these things work: > CM> > ${myValue} (indirect access to bean getter) > CM> > ${myValue.toUpperCase()} (method call on object) > CM> > <@s.property value="myMethod()"/> (Struts tag calling a method) > CM> > > CM> > But these things don't: > CM> > ${myMethod()} > CM> > ${getMyValue()} (plain method calls as described in the docs) > CM> > > > > Try: > > ${stack.findValue("getMyValue()")} > ${stack.findValue("myMethod()")} > > Later, > -- > Haroon Rafique > <haroon.rafique@...> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Trouble calling action methods from FreeMarkercan you try "${action.someMethod()} ? I think that should work
musachy On Tue, Nov 10, 2009 at 9:46 AM, Christopher Maloof <C_Maloof@...> wrote: > Thanks! I don't know what that's really doing, but it does work. Adding > parameters to the methods is a bit wonky; it's very difficult to get the > syntax right for > ${stack.findValue("getScore('${st.name()}')")} > as opposed to the expected > ${getScore(st.name())} > > but it's something. > > Maybe this should be added to > http://struts.apache.org/2.x/docs/freemarker.html , assuming it's the > intended behavior? The question's been asked of the list at least a couple > other times this year: http://markmail.org/message/4ordiw724kvdw5d6 and > http://markmail.org/message/jjkic23knjk5tnpx. > > Best, > Chris > > On 11/10/2009 11:20 AM, Haroon Rafique wrote: >> >> Hi Chris, >> >> See reply embedded below... >> >> On Today at 10:32am, CM=>Christopher Maloof<C_Maloof@...> >> wrote: >> >> CM> I guess no one recognizes the problem. Next question: Has anyone >> CM> gotten this (calling action methods from FreeMarker tags) to work >> CM> successfully? Just trying to figure out whether the correct approach >> CM> is to hammer on my configuration somehow, or to file a bug. >> CM> >> CM> Thanks, >> CM> Chris >> CM> >> CM> On 11/9/2009 10:13 AM, Christopher Maloof wrote: >> CM> > I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. >> It mostly >> CM> > works fine: my templates are retrieving bean information with no >> problem. >> CM> > However, I can't figure out how to call methods defined in my >> action >> CM> > classes. >> CM> > >> CM> > If my action class looks like this: >> CM> > >> CM> > public class MyAction extends MyActionSupport { >> CM> > public String getMyValue() { >> CM> > return "hello"; >> CM> > } >> CM> > public String myMethod() { >> CM> > return "world"; >> CM> > } >> CM> > } >> CM> > >> CM> > Then these things work: >> CM> > ${myValue} (indirect access to bean getter) >> CM> > ${myValue.toUpperCase()} (method call on object) >> CM> > <@s.property value="myMethod()"/> (Struts tag calling a method) >> CM> > >> CM> > But these things don't: >> CM> > ${myMethod()} >> CM> > ${getMyValue()} (plain method calls as described in the docs) >> CM> > >> >> >> Try: >> >> ${stack.findValue("getMyValue()")} >> ${stack.findValue("myMethod()")} >> >> Later, >> -- >> Haroon Rafique >> <haroon.rafique@...> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Trouble calling action methods from FreeMarkerOh, that's much nicer! Yes, using the "action" built-in variable works
perfectly. Thank you very much - Chris On 11/10/2009 12:53 PM, Musachy Barroso wrote: > can you try "${action.someMethod()} ? I think that should work > > musachy > > On Tue, Nov 10, 2009 at 9:46 AM, Christopher Maloof > <C_Maloof@...> wrote: > >> Thanks! I don't know what that's really doing, but it does work. Adding >> parameters to the methods is a bit wonky; it's very difficult to get the >> syntax right for >> ${stack.findValue("getScore('${st.name()}')")} >> as opposed to the expected >> ${getScore(st.name())} >> >> but it's something. >> >> Maybe this should be added to >> http://struts.apache.org/2.x/docs/freemarker.html , assuming it's the >> intended behavior? The question's been asked of the list at least a couple >> other times this year: http://markmail.org/message/4ordiw724kvdw5d6 and >> http://markmail.org/message/jjkic23knjk5tnpx. >> >> Best, >> Chris >> >> On 11/10/2009 11:20 AM, Haroon Rafique wrote: >> >>> Hi Chris, >>> >>> See reply embedded below... >>> >>> On Today at 10:32am, CM=>Christopher Maloof<C_Maloof@...> >>> wrote: >>> >>> CM> I guess no one recognizes the problem. Next question: Has anyone >>> CM> gotten this (calling action methods from FreeMarker tags) to work >>> CM> successfully? Just trying to figure out whether the correct approach >>> CM> is to hammer on my configuration somehow, or to file a bug. >>> CM> >>> CM> Thanks, >>> CM> Chris >>> CM> >>> CM> On 11/9/2009 10:13 AM, Christopher Maloof wrote: >>> CM> > I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8. >>> It mostly >>> CM> > works fine: my templates are retrieving bean information with no >>> problem. >>> CM> > However, I can't figure out how to call methods defined in my >>> action >>> CM> > classes. >>> CM> > >>> CM> > If my action class looks like this: >>> CM> > >>> CM> > public class MyAction extends MyActionSupport { >>> CM> > public String getMyValue() { >>> CM> > return "hello"; >>> CM> > } >>> CM> > public String myMethod() { >>> CM> > return "world"; >>> CM> > } >>> CM> > } >>> CM> > >>> CM> > Then these things work: >>> CM> > ${myValue} (indirect access to bean getter) >>> CM> > ${myValue.toUpperCase()} (method call on object) >>> CM> > <@s.property value="myMethod()"/> (Struts tag calling a method) >>> CM> > >>> CM> > But these things don't: >>> CM> > ${myMethod()} >>> CM> > ${getMyValue()} (plain method calls as described in the docs) >>> CM> > >>> >>> >>> Try: >>> >>> ${stack.findValue("getMyValue()")} >>> ${stack.findValue("myMethod()")} >>> >>> Later, >>> -- >>> Haroon Rafique >>> <haroon.rafique@...> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscribe@... >>> For additional commands, e-mail: user-help@... >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |