can you try "${action.someMethod()} ? I think that should work

musachy

On Tue, Nov 10, 2009 at 9:46 AM, Christopher Maloof
<c_mal...@mail.jci.tju.edu> 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_mal...@mail.jci.tju.edu>
>>  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.rafi...@utoronto.ca>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to