You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Leon Torres <le...@oss.minimetria.com> on 2007/01/27 01:08:03 UTC

[minilang] how to add a map to a list?

How do I add a map onto a list in minilang?  I tried the following and instead 
of my maps, I get N copies of the last map added,

<!-- loop through GenericValues -->
<iterate list-name="requirementsForSupplier" entry-name="req">
   <map-to-map map-name="req" to-map-name="requirement"/>
   <field-to-list field-name="requirement" list-name="requirements"/>
</iterate>
<field-to-result field-name="requirements" result-name="requirementsForSupplier"/>

If you have to ask why, I'm doing a union of the GenericValue fields with other 
data fields so that the form widget that invokes this service can list them all 
together.

- Leon

Re: [minilang] how to add a map to a list?

Posted by "David E. Jones" <jo...@hotwaxmedia.com>.
It sounds like the problem is that with map-to-map it doesn't create  
a new Map if one exists, it just adds all entries from the one Map to  
the other.

If you need to clone (or rather, shallow copy) the Map then you can  
do the same thing but add a clear-field on the "requirement" field  
before the map-to-map operation. If you don't need to clone the Map,  
just remove the map-to-map and in the field-to-list change it to use  
"req".

-David


On Jan 26, 2007, at 5:08 PM, Leon Torres wrote:

> How do I add a map onto a list in minilang?  I tried the following  
> and instead of my maps, I get N copies of the last map added,
>
> <!-- loop through GenericValues -->
> <iterate list-name="requirementsForSupplier" entry-name="req">
>   <map-to-map map-name="req" to-map-name="requirement"/>
>   <field-to-list field-name="requirement" list-name="requirements"/>
> </iterate>
> <field-to-result field-name="requirements" result- 
> name="requirementsForSupplier"/>
>
> If you have to ask why, I'm doing a union of the GenericValue  
> fields with other data fields so that the form widget that invokes  
> this service can list them all together.
>
> - Leon