Grabbing Static Content in an ftl file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grabbing Static Content in an ftl file

Tim Ruppert
All, in my ftl file, I'm trying to grab a small piece of content thru the ContentWorker renderContentAsTextCache method.  I found an example where this sort of thing is being done in applications/content/webapp/content/cms/CMSContentEdit.ftl , but when I follow that style I get an error.

Here is how it is done in that file:

<#assign currentTextData=Static["org.ofbiz.content.data.DataResourceWorker"].renderDataResourceAsTextCache(delegator, dataResourceId, (Map)null, (GenericValue)null, (Locale)null, (String)null) />

Here is how I do it:

<#assign textdata = Static["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(delegator, contentId, (Map)null, (GenericValue)null, (Locale)null, "text/html")>

I am getting an error that is slightly unexplainable:

freemarker.template.TemplateModelException: No signature of method renderContentAsTextCache accepts 9 arguments

So, when I remove the casting of the nulls, and the signature look like this:

<#assign textdata = Static["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(delegator, contentId, null, null, null, "text/html")>

I no longer get that error - I get the following error:

freemarker.template.TemplateModelException: No signature of method renderContentAsTextCache matches (org.ofbiz.entity.GenericDelegator,java.lang.String,org.ofbiz.entity.GenericEntity$NullField,org.ofbiz.entity.GenericEntity$NullField,org.ofbiz.entity.GenericEntity$NullField,java.lang.String)

Does anyone have any insight on this one?

Cheers,
Tim
--
Tim Ruppert
HotWax Media

o:801.649.6594
f:801.649.6595



smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Static Content in an ftl file

Tim Ruppert
I was able to get past it by adding another delegating method to ContentWorker, but boy does that seem like a hack.  I added the method that doesn't need the templateContext (map) or the view (GenericValue) - and just delegated in the java code.

Anybody who has any other ideas that might fix this the right way - please let me know.

Cheers,
Tim
--
Tim Ruppert
HotWax Media

o:801.649.6594
f:801.649.6595


On Jan 14, 2007, at 9:08 AM, Tim Ruppert wrote:

All, in my ftl file, I'm trying to grab a small piece of content thru the ContentWorker renderContentAsTextCache method.  I found an example where this sort of thing is being done in applications/content/webapp/content/cms/CMSContentEdit.ftl , but when I follow that style I get an error.

Here is how it is done in that file:

<#assign currentTextData=Static["org.ofbiz.content.data.DataResourceWorker"].renderDataResourceAsTextCache(delegator, dataResourceId, (Map)null, (GenericValue)null, (Locale)null, (String)null) />

Here is how I do it:

<#assign textdata = Static["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(delegator, contentId, (Map)null, (GenericValue)null, (Locale)null, "text/html")>

I am getting an error that is slightly unexplainable:

freemarker.template.TemplateModelException: No signature of method renderContentAsTextCache accepts 9 arguments

So, when I remove the casting of the nulls, and the signature look like this:

<#assign textdata = Static["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(delegator, contentId, null, null, null, "text/html")>

I no longer get that error - I get the following error:

freemarker.template.TemplateModelException: No signature of method renderContentAsTextCache matches (org.ofbiz.entity.GenericDelegator,java.lang.String,org.ofbiz.entity.GenericEntity$NullField,org.ofbiz.entity.GenericEntity$NullField,org.ofbiz.entity.GenericEntity$NullField,java.lang.String)

Does anyone have any insight on this one?

Cheers,
Tim
--
Tim Ruppert
HotWax Media

o:801.649.6594
f:801.649.6595




smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Static Content in an ftl file

David E Jones

Tim,

I just spent a few minutes looking at this... I think this is still a  
problem because this sort of operation is usually run from a bsh  
script, or from the screen def with the content or sub-content tags.

What appears to be happening is that FTL isn't treating "null" as a  
keyword, which is a problem for OFBiz because we actually put a  
variable called "null" in the context to use in simple-method files  
and such. If you look at the error you got it mentions the  
"org.ofbiz.entity.GenericEntity$NullField" object which is what the  
"null" field in the context is set to so we can use easily use  
conditions like foo equals null.

For now one solution is to do this in a bsh script, or in a screen  
included from the FTL file.

This is something we should probably fix at some point though...

-David


On Jan 14, 2007, at 10:07 AM, Tim Ruppert wrote:

> I was able to get past it by adding another delegating method to  
> ContentWorker, but boy does that seem like a hack.  I added the  
> method that doesn't need the templateContext (map) or the view  
> (GenericValue) - and just delegated in the java code.
>
> Anybody who has any other ideas that might fix this the right way -  
> please let me know.
>
> Cheers,
> Tim
> --
> Tim Ruppert
> HotWax Media
> http://www.hotwaxmedia.com
>
> o:801.649.6594
> f:801.649.6595
>
>
> On Jan 14, 2007, at 9:08 AM, Tim Ruppert wrote:
>
>> All, in my ftl file, I'm trying to grab a small piece of content  
>> thru the ContentWorker renderContentAsTextCache method.  I found  
>> an example where this sort of thing is being done in applications/
>> content/webapp/content/cms/CMSContentEdit.ftl , but when I follow  
>> that style I get an error.
>>
>> Here is how it is done in that file:
>>
>> <#assign currentTextData=Static
>> ["org.ofbiz.content.data.DataResourceWorker"].renderDataResourceAsTex
>> tCache(delegator, dataResourceId, (Map)null, (GenericValue)null,  
>> (Locale)null, (String)null) />
>>
>> Here is how I do it:
>>
>> <#assign textdata = Static
>> ["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(
>> delegator, contentId, (Map)null, (GenericValue)null, (Locale)null,  
>> "text/html")>
>>
>> I am getting an error that is slightly unexplainable:
>>
>> freemarker.template.TemplateModelException: No signature of method  
>> renderContentAsTextCache accepts 9 arguments
>>
>> So, when I remove the casting of the nulls, and the signature look  
>> like this:
>>
>> <#assign textdata = Static
>> ["org.ofbiz.content.content.ContentWorker"].renderContentAsTextCache(
>> delegator, contentId, null, null, null, "text/html")>
>>
>> I no longer get that error - I get the following error:
>>
>> freemarker.template.TemplateModelException: No signature of method  
>> renderContentAsTextCache matches  
>> (org.ofbiz.entity.GenericDelegator,java.lang.String,org.ofbiz.entity.
>> GenericEntity$NullField,org.ofbiz.entity.GenericEntity
>> $NullField,org.ofbiz.entity.GenericEntity$NullField,java.lang.String)
>>
>> Does anyone have any insight on this one?
>>
>> Cheers,
>> Tim
>> --
>> Tim Ruppert
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> o:801.649.6594
>> f:801.649.6595
>>
>>
>


smime.p7s (3K) Download Attachment