You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Ashish Repal <as...@gmail.com> on 2015/08/02 16:30:08 UTC
Map operation in ftl
Hi All,
I need to use map like data structure in ftl. I didnt find any in built
functionality in ftl like java where we create an object hashmap and get
access to various methods like put, remove etc.
What i found in ftl is like we need to create a string with : separator as
key value which requires much coding for basic add remove find operations.
Anybody has any idea on this. Please suggest.
Thanks
--
Regards,
Aashish Repal
09623381664
Re: Map operation in ftl
Posted by Ashish Repal <as...@gmail.com>.
Hi All,
Thank you for the inputs. Was really helpful.
On Monday, August 3, 2015, Nicolas Malin <ni...@nereide.fr> wrote:
> More easier :
>
> <#assign findPftMap = {"productFeatureTypeId":productFeatureTypeId,
> "otherKey": otherValue}>
>
> You can see the ftl documentation here :
> http://freemarker.org/docs/index.html
>
> Nicolas
>
> Le 03/08/2015 07:55, Deepak Dixit a écrit :
>
>> Hi Ashish,
>>
>> You can use UtilMisc method to create map in ftl.
>> e.g
>>
>> <#assign findPftMap = Static["org.ofbiz.base.util.UtilMisc"].toMap(
>> "productFeatureTypeId", productFeatureTypeId)>
>>
>> --
>> Thanks & Regards
>> --
>> Deepak Dixit
>> www.hotwaxsystems.com
>>
>> On Sun, Aug 2, 2015 at 8:59 PM, Taher Alkhateeb <
>> slidingfilaments@gmail.com>
>> wrote:
>>
>> Hi Ashish,
>>>
>>> I think your intention to use FreeMarker methods on your data structures
>>> is an indicator of a problematic design. The main purpose of FreeMarker
>>> templates is to spit out your HTML documents with variables replaced. You
>>> should avoid as much as you can having any logic in your templates
>>> because
>>> that would make your code base much harder to maintain.
>>>
>>> I recommend that you do any data manipulation in a groovy script or in
>>> Java and then handover the data you built to FreeMarker which you can
>>> just
>>> extract with a loop over one of the container types. If your purpose on
>>> the
>>> other hand is to have dynamic behavior, then the correct place to support
>>> that is in JavaScript.
>>>
>>> I hope that helps.
>>>
>>> Taher Alkhateeb
>>>
>>> ----- Original Message -----
>>>
>>> From: "Ashish Repal" <as...@gmail.com>
>>> To: user@ofbiz.apache.org
>>> Sent: Sunday, 2 August, 2015 5:30:08 PM
>>> Subject: Map operation in ftl
>>>
>>> Hi All,
>>> I need to use map like data structure in ftl. I didnt find any in built
>>> functionality in ftl like java where we create an object hashmap and get
>>> access to various methods like put, remove etc.
>>> What i found in ftl is like we need to create a string with : separator
>>> as
>>> key value which requires much coding for basic add remove find
>>> operations.
>>> Anybody has any idea on this. Please suggest.
>>>
>>> Thanks
>>>
>>>
>>> --
>>>
>>> Regards,
>>> Aashish Repal
>>> 09623381664
>>>
>>>
>>>
>
--
Regards,
Aashish Repal
09623381664
Re: Map operation in ftl
Posted by Nicolas Malin <ni...@nereide.fr>.
More easier :
<#assign findPftMap = {"productFeatureTypeId":productFeatureTypeId, "otherKey": otherValue}>
You can see the ftl documentation here :
http://freemarker.org/docs/index.html
Nicolas
Le 03/08/2015 07:55, Deepak Dixit a écrit :
> Hi Ashish,
>
> You can use UtilMisc method to create map in ftl.
> e.g
>
> <#assign findPftMap = Static["org.ofbiz.base.util.UtilMisc"].toMap(
> "productFeatureTypeId", productFeatureTypeId)>
>
> --
> Thanks & Regards
> --
> Deepak Dixit
> www.hotwaxsystems.com
>
> On Sun, Aug 2, 2015 at 8:59 PM, Taher Alkhateeb <sl...@gmail.com>
> wrote:
>
>> Hi Ashish,
>>
>> I think your intention to use FreeMarker methods on your data structures
>> is an indicator of a problematic design. The main purpose of FreeMarker
>> templates is to spit out your HTML documents with variables replaced. You
>> should avoid as much as you can having any logic in your templates because
>> that would make your code base much harder to maintain.
>>
>> I recommend that you do any data manipulation in a groovy script or in
>> Java and then handover the data you built to FreeMarker which you can just
>> extract with a loop over one of the container types. If your purpose on the
>> other hand is to have dynamic behavior, then the correct place to support
>> that is in JavaScript.
>>
>> I hope that helps.
>>
>> Taher Alkhateeb
>>
>> ----- Original Message -----
>>
>> From: "Ashish Repal" <as...@gmail.com>
>> To: user@ofbiz.apache.org
>> Sent: Sunday, 2 August, 2015 5:30:08 PM
>> Subject: Map operation in ftl
>>
>> Hi All,
>> I need to use map like data structure in ftl. I didnt find any in built
>> functionality in ftl like java where we create an object hashmap and get
>> access to various methods like put, remove etc.
>> What i found in ftl is like we need to create a string with : separator as
>> key value which requires much coding for basic add remove find operations.
>> Anybody has any idea on this. Please suggest.
>>
>> Thanks
>>
>>
>> --
>>
>> Regards,
>> Aashish Repal
>> 09623381664
>>
>>
Re: Map operation in ftl
Posted by Deepak Dixit <de...@hotwaxsystems.com>.
Hi Ashish,
You can use UtilMisc method to create map in ftl.
e.g
<#assign findPftMap = Static["org.ofbiz.base.util.UtilMisc"].toMap(
"productFeatureTypeId", productFeatureTypeId)>
--
Thanks & Regards
--
Deepak Dixit
www.hotwaxsystems.com
On Sun, Aug 2, 2015 at 8:59 PM, Taher Alkhateeb <sl...@gmail.com>
wrote:
> Hi Ashish,
>
> I think your intention to use FreeMarker methods on your data structures
> is an indicator of a problematic design. The main purpose of FreeMarker
> templates is to spit out your HTML documents with variables replaced. You
> should avoid as much as you can having any logic in your templates because
> that would make your code base much harder to maintain.
>
> I recommend that you do any data manipulation in a groovy script or in
> Java and then handover the data you built to FreeMarker which you can just
> extract with a loop over one of the container types. If your purpose on the
> other hand is to have dynamic behavior, then the correct place to support
> that is in JavaScript.
>
> I hope that helps.
>
> Taher Alkhateeb
>
> ----- Original Message -----
>
> From: "Ashish Repal" <as...@gmail.com>
> To: user@ofbiz.apache.org
> Sent: Sunday, 2 August, 2015 5:30:08 PM
> Subject: Map operation in ftl
>
> Hi All,
> I need to use map like data structure in ftl. I didnt find any in built
> functionality in ftl like java where we create an object hashmap and get
> access to various methods like put, remove etc.
> What i found in ftl is like we need to create a string with : separator as
> key value which requires much coding for basic add remove find operations.
> Anybody has any idea on this. Please suggest.
>
> Thanks
>
>
> --
>
> Regards,
> Aashish Repal
> 09623381664
>
>
Re: Map operation in ftl
Posted by Taher Alkhateeb <sl...@gmail.com>.
Hi Ashish,
I think your intention to use FreeMarker methods on your data structures is an indicator of a problematic design. The main purpose of FreeMarker templates is to spit out your HTML documents with variables replaced. You should avoid as much as you can having any logic in your templates because that would make your code base much harder to maintain.
I recommend that you do any data manipulation in a groovy script or in Java and then handover the data you built to FreeMarker which you can just extract with a loop over one of the container types. If your purpose on the other hand is to have dynamic behavior, then the correct place to support that is in JavaScript.
I hope that helps.
Taher Alkhateeb
----- Original Message -----
From: "Ashish Repal" <as...@gmail.com>
To: user@ofbiz.apache.org
Sent: Sunday, 2 August, 2015 5:30:08 PM
Subject: Map operation in ftl
Hi All,
I need to use map like data structure in ftl. I didnt find any in built
functionality in ftl like java where we create an object hashmap and get
access to various methods like put, remove etc.
What i found in ftl is like we need to create a string with : separator as
key value which requires much coding for basic add remove find operations.
Anybody has any idea on this. Please suggest.
Thanks
--
Regards,
Aashish Repal
09623381664