Components.getSingleton(FreemarkerConfig.class).getObjectWrapper();

should do the trick ... but please see also Gregory's comments about need of 
access to the said object at all.

Cheers,
Jan

On Jun 2, 2011, at 10:19 AM, Unger, Richard wrote:

> Hi Jan!
> 
> Thanks for your answer. Maybe I’m doing something „unusual” – basically I 
> have an object that I am setting as a freemarker variable, to make it 
> available to the templates. I was wrapping the object using BeanWrapper, but 
> fields of the object of type “Content” were being returned as beans, not 
> ContentModels.
> I now wrap the object using MagnoliaObjectWrapper, like this:
>  
>                   ObjectWrapper w = 
> FreemarkerConfig.getInstance().getObjectWrapper();
>                   env.setVariable(varStatus, w.wrap(status));
>  
> This is working, but it would be nice to have a non-deprecated way to get at 
> the MagnoliaObjectWrapper… (FreemarkerConfig.getInstance() is deprecated). 
> Any hints how I can get at the ObjectWrapper?
>  
> Thanks,
>  
> Regards from Vienna,
> 
> Richard
>  
>  
>  
>  
>  
> Von: [email protected] 
> [mailto:[email protected]] Im Auftrag von Jan Haderka
> Gesendet: Mittwoch, 01. Juni 2011 16:19
> An: Magnolia User-List
> Betreff: Re: [magnolia-user] Quick Question
>  
> the "content" in your template is actually instance of ContentModel class ... 
> does it answer the question?
>  
> or is it that you want to return ContentModel from some method in your model 
> rather then Content?
>  
> Jan
>  
> On Jun 1, 2011, at 3:59 PM, Unger, Richard wrote:
> 
> 
> Hi Magnolians!
>  
> A quick question:
>  
> Given a Content, what is the code for getting a ContentModel for passing to 
> freemarker?
> eg:
>  
>  
> public ContentModel getModelForContent(Content c){
>        ???
> }
>  
>  
> I can’t find an example anywhere, and as usual, it isn’t documented…
>  
> Thanks!
>  
> Regards from Vienna,
> 
> Richard
>  
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
>  
> 
>  
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to