Hello Skip,

My piece of code is :

itelim = elim.iterator();               //where elim = findByCond(........);
  elimList = new ArrayList();

          while(itelim.hasNext())
          {
              elimList = itelim.next();
              elimList.toString();

              String a1 =  elimList.getString("grandTotal");
              a =  Double.parseDouble(a1);

          }
Now this does give me some result at the o/p : which is last entry in the
grandTotal column(a double value) say for eg: 350.30

I also used the piece of code that you provided.....it works for sure but
gives "void" at the o/p.......

Also wanted to ask as to how can i iterate over the grandTotal entries. for
eg: if i have to get grandTotal for all products and sum it up.

Thanks

On 9/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> You can't type cast the GenericValue.  You possibly can type cast one of
> the
> objects it holds depending on the type.  Each GenericValue holds different
> types if information depending on what it represents.  For example,
>
> GenericValue existingOrderHeader = delegator.findByPrimaryKey
> ("OrderHeader",
> UtilMisc.toMap("orderId", orderId));
> String customerId = externalOrderHeader.getString("customerPartyId");
>
> if OrderHeader had a Double value in it, say "grandTotal", you could
>
> double grandTotal =
> externalOrderHeader.getDouble("grandTotal").doubleValue();
>
>
> or
>
> double grandTotal =
> ((Double)externalOrderHeader.get("grandTotal")).doubleValue();
>
> Both of these will throw a ClassCastException if "grandTotal" is not a
> double.
>
> Everything in a GenericValue object is an object itself, i.e double is
> wrapped in Double, etc.
>
> Hope that helps
>
> Skip
>
> -----Original Message-----
> From: vijay Si [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 24, 2007 11:12 PM
> To: [email protected]
> Subject: TypeCasting GenericValue object.
>
>
> Hi,
> I have been trying to type cast a generic value object to double and
> string,
> but i get an error
>
> "java.lang.ClassCastException: Cannot cast org.ofbiz.entity.GenericValueto
> java.lang.xx"
>
> Is there any particular way in ofbiz to work around this?
>
> Regards
>
>

Reply via email to