You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Vedam B <ve...@gmail.com> on 2008/03/13 06:20:48 UTC
convert list of Generic value to Map
Hi,
Can some one help on "how to convert list of generic values returned using
findByConditionCache to a Map".
Regards
Vedam
Re: convert list of Generic value to Map
Posted by Bilgin Ibryam <bi...@iguanait.com>.
I can not guess any utility class doing this.
However you can iterated the list elements and put them to map one by
one. The key for an element in the Map could be its index of from the
List.
Bilgin
Re: convert list of Generic value to Map
Posted by Vedam B <ve...@gmail.com>.
Thanks for your help.
I started learning ofbiz and trying to display selected fields from an
entity in form
For this, i have written the code like this
1. Use findByConditionCache to get selected fields
-
List fieldUser = FastList.*newInstance*();
fieldUser.add("userId");
fieldUser.add("userName");
EntityCondition userIdCond = *new* EntityExpr("userId",
EntityOperator.*IN*, userIds);
List userList = delegator.findByConditionCache("User",
userIdCond, fieldUser, *null*);
Here i need to retrieve the userList and send as a Map which conains user
records - only userId & userName for matching user ids in userIds List.
Thanks for any help.
Regards
Vedam
On Thu, Mar 13, 2008 at 11:52 AM, skip@thedevers <sk...@thedevers.org>
wrote:
> Here's what I would do assuming the list is called productList and has a
> productId in it and you wanted to map the list by productId:
>
> FastMap returnMap = FastMap.newInstance();
>
> for(int i = 0; i < productList.size(); i++)
> {
> GenericValue product = (GenericValue)productList.get(i);
> returnMap.put(product.getString("productId", product);
> }
>
> Skip
>
> -----Original Message-----
> From: Vedam B [mailto:vedam97@gmail.com]
> Sent: Wednesday, March 12, 2008 10:21 PM
> To: user@ofbiz.apache.org
> Subject: convert list of Generic value to Map
>
>
> Hi,
>
> Can some one help on "how to convert list of generic values returned using
>
> findByConditionCache to a Map".
>
>
>
> Regards
>
> Vedam
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.518 / Virus Database: 269.21.7/1324 - Release Date: 3/10/2008
> 7:27 PM
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.518 / Virus Database: 269.21.7/1324 - Release Date: 3/10/2008
> 7:27 PM
>
>
RE: convert list of Generic value to Map
Posted by "skip@thedevers" <sk...@thedevers.org>.
Here's what I would do assuming the list is called productList and has a
productId in it and you wanted to map the list by productId:
FastMap returnMap = FastMap.newInstance();
for(int i = 0; i < productList.size(); i++)
{
GenericValue product = (GenericValue)productList.get(i);
returnMap.put(product.getString("productId", product);
}
Skip
-----Original Message-----
From: Vedam B [mailto:vedam97@gmail.com]
Sent: Wednesday, March 12, 2008 10:21 PM
To: user@ofbiz.apache.org
Subject: convert list of Generic value to Map
Hi,
Can some one help on "how to convert list of generic values returned using
findByConditionCache to a Map".
Regards
Vedam
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.7/1324 - Release Date: 3/10/2008
7:27 PM
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.7/1324 - Release Date: 3/10/2008
7:27 PM