Simple Method Question

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

Simple Method Question

Adrian Crum
Using minilang, I need to put all of the fields from an entity in the result map. I tried using
<map-to-map> but that doesn't work. Is there a simple way to put all of a map's elements into the
result map?

-Adrian

Reply | Threaded
Open this post in threaded view
|

Re: Simple Method Question

Vikas Mayur-2
<entity-one entity-name="Product" value-name="mapName.product"/>
<field-to-result field-name="mapName" result-name="mapName"/>

or

<entity-one entity-name="Product" value-name="mapName.product"/>
<field-to-result field-name="mapName" />

I have not tried it but hope this works.


On 8/30/07, Adrian Crum <[hidden email]> wrote:

>
> Using minilang, I need to put all of the fields from an entity in the
> result map. I tried using
> <map-to-map> but that doesn't work. Is there a simple way to put all of a
> map's elements into the
> result map?
>
> -Adrian
>
>


--
Vikas Mayur
Reply | Threaded
Open this post in threaded view
|

Re: Simple Method Question

jonwimp
In reply to this post by Adrian Crum
Why doesn't map-to-map work? Did you mean you wanted to copy every field in a GenericValue object
to a new map? Then map-to-map will work. The resultant map is NOT a GenericValue object, but a
plain map.

Oh, the result map.

Don't know any method to do that easily. You could write something like map-to-result. If you want
that and you want it checked into OFBiz SVN, I think I can do that very quickly. You check it in.

I usually just put all the fields I want to return into a map, like <set field="someMap.fieldA"
value="Blah"/>. I then do a <field-to-result field-name="someMap"/>. That way, I am able to return
a large set of values. I think this is the better/best practice. Like in Java functions, you don't
see functions returning a whole chunk of values, but instead return a collection.

Jonathon

Adrian Crum wrote:
> Using minilang, I need to put all of the fields from an entity in the
> result map. I tried using <map-to-map> but that doesn't work. Is there a
> simple way to put all of a map's elements into the result map?
>
> -Adrian
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Simple Method Question

cjhowe
In reply to this post by Adrian Crum
If each field in the map needs to go to the result, then perhaps this would work for you:
<iterate-map map="myMap" key="key" value="value">
  <set field="${key}" from-field="value"/>
  <field-to-result field-name="${key}"/>
  <clear-field field="key"/>
  <clear-field field="value"/>
</iterate-map>

----- Original Message ----
From: Jonathon -- Improov <[hidden email]>
To: [hidden email]
Sent: Thursday, August 30, 2007 12:34:01 AM
Subject: Re: Simple Method Question

Why doesn't map-to-map work? Did you mean you wanted to copy every field in a GenericValue object
to a new map? Then map-to-map will work. The resultant map is NOT a GenericValue object, but a
plain map.

Oh, the result map.

Don't know any method to do that easily. You could write something like map-to-result. If you want
that and you want it checked into OFBiz SVN, I think I can do that very quickly. You check it in.

I usually just put all the fields I want to return into a map, like <set field="someMap.fieldA"
value="Blah"/>. I then do a <field-to-result field-name="someMap"/>. That way, I am able to return
a large set of values. I think this is the better/best practice. Like in Java functions, you don't
see functions returning a whole chunk of values, but instead return a collection.

Jonathon

Adrian Crum wrote:
> Using minilang, I need to put all of the fields from an entity in the
> result map. I tried using <map-to-map> but that doesn't work. Is there a
> simple way to put all of a map's elements into the result map?
>
> -Adrian
>
>