Re: TemplateModelException when unwrapping SimpleMethodModel

Rebecca Younes <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <CA5F3E4F.8174%[email protected]>
Now I see that as long as I'm working within the freemarker.ext.beans package, I can call SimpleMethodModel.getMember() to get its member method. This may be the only option, given the issues with the unwrap method.

From: Rebecca Younes <[email protected]<mailto:[email protected]>>
Date: Wed, 3 Aug 2011 17:22:01 -0400
To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Subject: Re: TemplateModelException when unwrapping SimpleMethodModel

OK, I see that SimpleMethodModel.size() throws an exception, which seems to me an indication that SimpleMethodModel shouldn't implement TemplateSequenceModel in the first place. However, given that it does, what can I do to get the underlying method?

Thanks.

From: Rebecca Younes <[email protected]<mailto:[email protected]>>
Date: Wed, 3 Aug 2011 17:10:30 -0400
To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Subject: TemplateModelException when unwrapping SimpleMethodModel

Hello,

I'm getting a TemplateModelException when I try to do DeepUnwrap.permissiveUnwrap() or DeepUnwrap.unwrap() on a SimpleMethodModel. The error is generated in the following code block, with the message "?size is unsupported for: freemarker.ext.beans.SimpleMethodModel". However, size() is defined for this class. What is going wrong, and is there a workaround so that I can get at the wrapped method?


        if(model instanceof TemplateSequenceModel) {

            TemplateSequenceModel seq = (TemplateSequenceModel)model;

            ArrayList list = new ArrayList(seq.size());

            for(int i = 0; i < seq.size(); ++i) {

                list.add(unwrap(seq.get(i), nullModel, permissive));

            }

            return list;

}


Thank you.


Rebecca Younes

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.