Map operation in ftl

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

Map operation in ftl

Ashish Repal
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
Reply | Threaded
Open this post in threaded view
|

Re: Map operation in ftl

taher
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" <[hidden email]>
To: [hidden email]
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

Reply | Threaded
Open this post in threaded view
|

Re: Map operation in ftl

Deepak Dixit-3
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 <[hidden email]>
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" <[hidden email]>
> To: [hidden email]
> 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
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Map operation in ftl

Nicolas Malin-2
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 <[hidden email]>
> 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" <[hidden email]>
>> To: [hidden email]
>> 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
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Map operation in ftl

Ashish Repal
Hi All,
Thank you for the inputs. Was really helpful.

On Monday, August 3, 2015, Nicolas Malin <[hidden email]> 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 <
>> [hidden email]>
>> 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" <[hidden email]>
>>> To: [hidden email]
>>> 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