[OFBiz] Users - BSH help?
David E. Jones
jonesde at ofbiz.org
Mon Apr 4 19:13:37 EDT 2005
In other words: get rid of the UtilMisc.toMap.
Do you have experience with Java? If so, look at the definitions of the
method in question, namely the "put" method on the java.util.Map
interface. The definition of the method must be followed or yes, it
will certainly have problems.
-David
On Apr 4, 2005, at 5:05 PM, Chris Howe wrote:
> Si,
> That eliminates the error but only results in the last iteration
>
> David,
> I changed it to
> while (accountListIter.hasNext()){
> orderLists = accountListIter.next();
> billingAccountId = orderLists.get("billingAccountId");
> orderList = delegator.findByAnd("OrderHeader",
> UtilMisc.toMap("billingAccountId", billingAccountId, "statusId",
> "ORDER_CREATED"));
> order.put(UtilMisc.toMap("billingAccountId",
> billingAccountId, "orderList", orderList));
> }
> and still get the same error.
>
> >Chris,
>
> >Why are you trying to add to a HashMap? .add is usually a method for
> >List-like types. If you're trying to add a new key-value pair:
> >orderList -> orderList
> >then just do:
> >order.put("orderList", orderList);
>
> >Si
>
> >David E. Jones wrote:
>
> >
> > put requires a name, value pair as 2 arguments, NOT as a single entry
> > in a Map which is what yo!
> u are
> doing here... So, yeah, it won't work,
> > and I wouldn't ever expect it to...
> >
> > -David
> >
> >
> > On Apr 4, 2005, at 4:24 PM, Chris Howe wrote:
> >
> >> Both add and put give errors.
> >>
> >> put gives
> >>
> >> order.put (UtilMisc.toMap("orderList", orderList))
> >> Sourced file (file location) Error in method
> >> invocation: Method put
> >> (org.ofbiz.base.util.utilMisc$SimpleMap) not found in
> >> class'java.util.HashMap
> >>
> >> add gives
> >>
> >> order.add (UtilMisc.toMap("orderList", orderList))
> >> Sourced file (file location) Error in method
> >> invocation: Method put
> >> (org.ofbiz.base.util.utilMisc$SimpleMap) not found in
> >>
> class'java.util.HashMap
> >> ===========================================
> >> Good catch Jacopo...
> >>
> >> Chris: this should have resulted in an error message,
> >> was there one?
> >>
> >> -David
> >>
> >>
> >> On Apr 4, 2005, at 11:31 AM, Jacopo Cappellato wrote:
> >>
> >>> Chris,
> >>>
> >>> In the last line, use 'put' instead of 'add':
> >>>
> >>> order.put(UtilMisc.toMap("orderList", orderList));
> >>>
> >>> Jacopo
> >>>
> >>> Chris Howe wrote:
> >>>
> >>>> I am having the toughest time getting the syntax
> >>>> correct on this. for orderList, I can't get the
> >>>> iterated result to add!
> to the
> Hashmap.
> >>>> import org.ofbiz.base.util.*;
> >>>> import org.ofbiz.entity.*;
> >>>> import org.ofbiz.entity.util.*;
> >>>> import org.ofbiz.accounting.payment.*;
> >>>> import org.ofbiz.party.contact.*;
> >>>> import org.ofbiz.product.store.*;
> >>>> requestParams = UtilHttp.getParameterMap(request);
> >>>> delegator = request.getAttribute("delegator");
> >>>> userLogin = session.getAttribute("userLogin");
> >>>> if (userLogin != null && userLogin != "") {
> >>>> billingAccountRoleList =
> >>>> delegator.findByAnd("BillingAccountRole",
> >>>> UtilMisc.toMap("partyId",
> >>>> userLogin.getString("partyId"), "roleTypeId",
> >>>> "APPROVING_CUSTOMER"));
> >>&g!
> t;>
> billingAccountRoleList =
> >>>> EntityUtil.filterByDate(billingAccountRoleList);
> >>>> if (billingAccountRoleList != null &&
> >>>> billingAccountRoleList.size() > 0) {
> >>>> totalAvailable = 0.00;
> >>>> sortedAccounts = new TreeMap();
> >>>> billingAcctIter =
> >>>> billingAccountRoleList.iterator();
> >>>> while (billingAcctIter.hasNext()) {
> >>>> billingAccountRole =
> >>>
> >> billingAcctIter.next();
> >>
> >>>> billingAccountVO =
> >>>> billingAccountRole.getRelatedOne("BillingAccount");
> >>>> accountBalance =
> >>>>
> >>
> BillingAccountWorker.getBillingAccountBalance(billingAccountVO);
> >>
> >>>>
> >>>> billingAccount = new
> >>>> HashMap(billingAccountVO);
> >>>> accountLimit =
> >>>>
> >> billingAccountVO.getDouble("accountLimit").doubleValue();
> >>
> >>>>
> >> billingAccount.put("accountBalance", new
> >>
> >>>> Double(accountBalance));
> >>>
> >> accountAvailable = accountLimit -
> >>
> >>>> accountBalance;
> >>>> totalAvailable += accountAvailable;
> >>>
> >>
> >>>> sortedAccounts.put(new
> >>>> Double(accountAvailable), billingAccount);
> >>>>
> }
> >>>> billingAccountList = new
> >>>> ArrayList(sortedAccounts.values());
> >>>> context.put("billingAccountList",
> >>>> billingAccountList); }
> >>>> if (billingAccountList.size() > 0){
> >>>> accountListIter = billingAccountList.iterator();
> >>>> order = new HashMap();
> >>>> while (accountListIter.hasNext()){
> >>>> orderLists = accountListIter.next();
> >>>> billingAccountId =
> >>>> orderLists.get("billingAccountId");
> >>>> orderList = delegator.findByAnd("OrderHeader",
> >>>> UtilMisc.toMap("billingAccountId",
> >>>
> >> billingAccountId,
> >>
> >>>> "statusId",
> "ORDER_CREATED"));
> >>>> context.put("orderList", orderList);
> >>>> order.add(UtilMisc.toMap("orderList",
> >>>
> >> orderList));
> >>
> >>>> }
> >>>> }
> >>>> }
> >>>> }
> >>>> ===========================
> >>>> any help would be greatly apprciated
> >>>>
> >>>> __________________________________ Yahoo! Messenger
> >>>
> >> Show us what our
> >>
> >>>> next emoticon should look like. Join the fun.
> >>>>
> >> http://www.advision.webevents.yahoo.com/emoticontest
> >>
> >>>>
> _______________________________________________
> >>>> Users mailing list
> >>>> Users at lists.ofbiz.org
> >>>> http://lists.ofbiz.org/mailman/listinfo/users
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Users mailing list
> >>> Users at lists.ofbiz.org
> >>> http://lists.ofbiz.org/mailman/listinfo/users
> >>
> >> -------------- next part --------------
> >> A non-text attachment was scrubbed...
> >> Name: smime.p7s
> >> Type: application/pkcs7-signature
> >> Size: 2363 bytes
> >> Desc: not available
> >>
> >>
> >>!
> ;
>
> >> __________________________________
> >> Do you Yahoo!?
> >> Yahoo! Personals - Better first dates. More second dates.
> >> http://personals.yahoo.com
> >>
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.ofbiz.org
> >> http://lists.ofbiz.org/mailman/listinfo/users
> >
> >----------------------------------------------------------------------
> --
> >
> >
> >_______________________________________________
> >Users mailing list
> >Users at lists.ofbiz.org
> >http://lists.ofbiz.org/mailman/listinfo/users
> >
>
> Do you Yahoo!?
> Better first dates. More second dates. Yahoo! Personals
> _______________________________________________
> Users mailing list
> Users at lists.ofbiz.org
> http://lists.ofbiz.org/mailman/listinfo/users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2363 bytes
Desc: not available
Url : http://lists.ofbiz.org/pipermail/users/attachments/20050404/c2281518/smime.bin
More information about the Users
mailing list