problem while returning list object

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

problem while returning list object

prasanthi_ofbiz
Hi
I have created my own service which is created for returning a list. So I have added below code in the services_ledger.xml
<service name="getFinAccountType" engine="java" export="true"
    location="org.ofbiz.accounting.finaccount.FinAccountServices" invoke="getFinAccountType" auth="true">
    <description>parameterizing Financial Account Type</description>
    <log level="info" message="Entered into  getFinAccountType service of services_ledger....."/>
    <attribute type="String" mode="IN" name="finAccountTypeId" optional="true" />
    <attribute type="String" mode="IN" name="parentTypeId" optional="true" />
    <attribute type="String" mode="IN" name="isRefundable" optional="true" />
    <attribute type="String" mode="IN" name="replenishEnumId" optional="true" />
    <attribute type="String" mode="IN" name="hasTable" optional="true" />
    <attribute type="String" mode="IN" name="description" optional="true" />
    <attribute name="FinAccountTypeList" type="List" mode="OUT" optional="true"/>
    </service> 

and getFinAccountType functionis written in FinAccountServices.java file

public static List getFinAccountType(DispatchContext dctx, Map context) {
           LocalDispatcher dispatcher = dctx.getDispatcher();
        GenericDelegator delegator = dctx.getDelegator();

        GenericValue userLogin = (GenericValue) context.get("userLogin");
        String finAccountTypeId = (String) context.get("finAccountTypeId");
        String parentTypeId = (String) context.get("parentTypeId");
        String replenishEnumId = (String) context.get("replenishEnumId");
        String isRefundable = (String) context.get("isRefundable");
        String hasTable = (String) context.get("hasTable");
        String description = (String) context.get("description");
        GenericValue finAccount=null;
        Map finAcctg = UtilMisc.toMap("finAccountTypeId", finAccountTypeId,"description", description,"hasTable", hasTable,"isRefundable", isRefundable,"replenishEnumId", replenishEnumId,"parentTypeId", parentTypeId);
       
        List exprs = FastList.newInstance();
       
        if(finAccountTypeId!=null)
        {
        Debug.log("finAccountTypeId Added as a serach parameter");
        exprs.add(EntityCondition.makeCondition("finAccountTypeId", EntityOperator.EQUALS, finAccountTypeId));
        }
        if(parentTypeId!=null)
        {
        Debug.log("parentTypeId Added as a serach parameter");
         exprs.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, parentTypeId));
        }
        if(replenishEnumId!=null)
        {
        Debug.log("replenishEnumId Added as a serach parameter");
        exprs.add(EntityCondition.makeCondition("replenishEnumId", EntityOperator.EQUALS, replenishEnumId));
        }
        if(isRefundable!=null)
        {
        Debug.log("isRefundable Added as a serach parameter");
        exprs.add(EntityCondition.makeCondition("isRefundable", EntityOperator.EQUALS, isRefundable));
        }
        if(hasTable!=null)
        {
        Debug.log("hasTable Added as a serach parameter");
        exprs.add(EntityCondition.makeCondition("hasTable", EntityOperator.EQUALS, hasTable));
        }
        if(description!=null)
        {
        Debug.log("description Added as a serach parameter");
        exprs.add(EntityCondition.makeCondition("description", EntityOperator.EQUALS, description));
        }
       
        List orderBy = UtilMisc.toList("-finAccountTypeId");
        List FinAccountTypeList = null;
        try {
        FinAccountTypeList = delegator.findList("FinAccountType", EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy, null, false);
            Debug.log("FinAccountTypeList SIZEE........  "+FinAccountTypeList.size());
            Debug.log("FinAccountTypeList+++++++++++++++++"+FinAccountTypeList);
        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }      
        return FinAccountTypeList;
    }


But its giving error as


The Following Errors Occurred:

Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service invocation error (Service [getFinAccountType] did not return a Map object)


Please let me know the am I missed anything.
Reply | Threaded
Open this post in threaded view
|

Re: problem while returning list object

Santosh Malviya-3
Hi Prasanthi,

Service returns a map, so  your return type should be Map and in this map
you have to put the list which will be also your OUT parameter and then you
can use the map wherever by accessing its key/value field.  Have a look on
performFindList service.

Thanks and Regards
Santosh Malviya

On Thu, Jul 15, 2010 at 3:24 PM, prasanthi_ofbiz <
[hidden email]> wrote:

>
> Hi
> I have created my own service which is created for returning a list. So I
> have added below code in the services_ledger.xml
> <service name="getFinAccountType" engine="java" export="true"
>        location="org.ofbiz.accounting.finaccount.FinAccountServices"
> invoke="getFinAccountType" auth="true">
>        <description>parameterizing Financial Account Type</description>
>        <log level="info" message="Entered into  getFinAccountType service
> of
> services_ledger....."/>
>        <attribute type="String" mode="IN" name="finAccountTypeId"
> optional="true" />
>        <attribute type="String" mode="IN" name="parentTypeId"
> optional="true"
> />
>        <attribute type="String" mode="IN" name="isRefundable"
> optional="true"
> />
>        <attribute type="String" mode="IN" name="replenishEnumId"
> optional="true" />
>        <attribute type="String" mode="IN" name="hasTable" optional="true"
> />
>        <attribute type="String" mode="IN" name="description"
> optional="true"
> />
>        <attribute name="FinAccountTypeList" type="List" mode="OUT"
> optional="true"/>
>    </service>
>
> and getFinAccountType functionis written in FinAccountServices.java file
>
> public static List getFinAccountType(DispatchContext dctx, Map context) {
>                LocalDispatcher dispatcher = dctx.getDispatcher();
>        GenericDelegator delegator = dctx.getDelegator();
>
>        GenericValue userLogin = (GenericValue) context.get("userLogin");
>        String finAccountTypeId = (String) context.get("finAccountTypeId");
>        String parentTypeId = (String) context.get("parentTypeId");
>        String replenishEnumId = (String) context.get("replenishEnumId");
>        String isRefundable = (String) context.get("isRefundable");
>        String hasTable = (String) context.get("hasTable");
>        String description = (String) context.get("description");
>        GenericValue finAccount=null;
>        Map finAcctg = UtilMisc.toMap("finAccountTypeId",
> finAccountTypeId,"description", description,"hasTable",
> hasTable,"isRefundable", isRefundable,"replenishEnumId",
> replenishEnumId,"parentTypeId", parentTypeId);
>
>        List exprs = FastList.newInstance();
>
>        if(finAccountTypeId!=null)
>        {
>                Debug.log("finAccountTypeId Added as a serach parameter");
>                 exprs.add(EntityCondition.makeCondition("finAccountTypeId",
> EntityOperator.EQUALS, finAccountTypeId));
>        }
>        if(parentTypeId!=null)
>        {
>                Debug.log("parentTypeId Added as a serach parameter");
>                  exprs.add(EntityCondition.makeCondition("parentTypeId",
> EntityOperator.EQUALS, parentTypeId));
>        }
>        if(replenishEnumId!=null)
>        {
>                Debug.log("replenishEnumId Added as a serach parameter");
>                exprs.add(EntityCondition.makeCondition("replenishEnumId",
> EntityOperator.EQUALS, replenishEnumId));
>        }
>        if(isRefundable!=null)
>        {
>                Debug.log("isRefundable Added as a serach parameter");
>                 exprs.add(EntityCondition.makeCondition("isRefundable",
> EntityOperator.EQUALS, isRefundable));
>        }
>        if(hasTable!=null)
>        {
>                Debug.log("hasTable Added as a serach parameter");
>                exprs.add(EntityCondition.makeCondition("hasTable",
> EntityOperator.EQUALS, hasTable));
>        }
>        if(description!=null)
>        {
>                Debug.log("description Added as a serach parameter");
>                 exprs.add(EntityCondition.makeCondition("description",
> EntityOperator.EQUALS, description));
>        }
>
>        List orderBy = UtilMisc.toList("-finAccountTypeId");
>        List FinAccountTypeList = null;
>        try {
>                FinAccountTypeList = delegator.findList("FinAccountType",
> EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy,
> null, false);
>            Debug.log("FinAccountTypeList SIZEE........
> "+FinAccountTypeList.size());
>
> Debug.log("FinAccountTypeList+++++++++++++++++"+FinAccountTypeList);
>        } catch (GenericEntityException e) {
>            Debug.logError(e, module);
>        }
>        return FinAccountTypeList;
>    }
>
>
> But its giving error as
>
>
> The Following Errors Occurred:
>
> Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service
> invocation error (Service [getFinAccountType] did not return a Map object)
>
>
> Please let me know the am I missed anything.
>
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/problem-while-returning-list-object-tp2289908p2289908.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: problem while returning list object

Brajesh Patel-2
In reply to this post by prasanthi_ofbiz
Hi,
Need to return map from java service that you have implemented like

    Map<String, Object> result = ServiceUtil.returnSuccess();
    result.put("FinAccountTypeList", FinAccountTypeList);
    return result;

refer ShoppingCartServices.java or any other *Service*.java.

--
Brajesh Patel


prasanthi_ofbiz wrote:

> Hi
> I have created my own service which is created for returning a list. So I
> have added below code in the services_ledger.xml
> <service name="getFinAccountType" engine="java" export="true"
>     location="org.ofbiz.accounting.finaccount.FinAccountServices"
> invoke="getFinAccountType" auth="true">
>     <description>parameterizing Financial Account Type</description>
>     <log level="info" message="Entered into  getFinAccountType service of
> services_ledger....."/>
>     <attribute type="String" mode="IN" name="finAccountTypeId"
> optional="true" />
>     <attribute type="String" mode="IN" name="parentTypeId" optional="true"
> />
>     <attribute type="String" mode="IN" name="isRefundable" optional="true"
> />
>     <attribute type="String" mode="IN" name="replenishEnumId"
> optional="true" />
>     <attribute type="String" mode="IN" name="hasTable" optional="true" />
>     <attribute type="String" mode="IN" name="description" optional="true"
> />
>     <attribute name="FinAccountTypeList" type="List" mode="OUT"
> optional="true"/>
>     </service>  
>
> and getFinAccountType functionis written in FinAccountServices.java file
>
> public static List getFinAccountType(DispatchContext dctx, Map context) {
>            LocalDispatcher dispatcher = dctx.getDispatcher();
>         GenericDelegator delegator = dctx.getDelegator();
>
>         GenericValue userLogin = (GenericValue) context.get("userLogin");
>         String finAccountTypeId = (String) context.get("finAccountTypeId");
>         String parentTypeId = (String) context.get("parentTypeId");
>         String replenishEnumId = (String) context.get("replenishEnumId");
>         String isRefundable = (String) context.get("isRefundable");
>         String hasTable = (String) context.get("hasTable");
>         String description = (String) context.get("description");
>         GenericValue finAccount=null;
>         Map finAcctg = UtilMisc.toMap("finAccountTypeId",
> finAccountTypeId,"description", description,"hasTable",
> hasTable,"isRefundable", isRefundable,"replenishEnumId",
> replenishEnumId,"parentTypeId", parentTypeId);
>        
>         List exprs = FastList.newInstance();
>        
>         if(finAccountTypeId!=null)
>         {
>         Debug.log("finAccountTypeId Added as a serach parameter");
>         exprs.add(EntityCondition.makeCondition("finAccountTypeId",
> EntityOperator.EQUALS, finAccountTypeId));
>         }
>         if(parentTypeId!=null)
>         {
>         Debug.log("parentTypeId Added as a serach parameter");
>          exprs.add(EntityCondition.makeCondition("parentTypeId",
> EntityOperator.EQUALS, parentTypeId));
>         }
>         if(replenishEnumId!=null)
>         {
>         Debug.log("replenishEnumId Added as a serach parameter");
>         exprs.add(EntityCondition.makeCondition("replenishEnumId",
> EntityOperator.EQUALS, replenishEnumId));
>         }
>         if(isRefundable!=null)
>         {
>         Debug.log("isRefundable Added as a serach parameter");
>         exprs.add(EntityCondition.makeCondition("isRefundable",
> EntityOperator.EQUALS, isRefundable));
>         }
>         if(hasTable!=null)
>         {
>         Debug.log("hasTable Added as a serach parameter");
>         exprs.add(EntityCondition.makeCondition("hasTable",
> EntityOperator.EQUALS, hasTable));
>         }
>         if(description!=null)
>         {
>         Debug.log("description Added as a serach parameter");
>         exprs.add(EntityCondition.makeCondition("description",
> EntityOperator.EQUALS, description));
>         }
>        
>         List orderBy = UtilMisc.toList("-finAccountTypeId");
>         List FinAccountTypeList = null;
>         try {
>         FinAccountTypeList = delegator.findList("FinAccountType",
> EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy,
> null, false);
>             Debug.log("FinAccountTypeList SIZEE........
> "+FinAccountTypeList.size());
>            
> Debug.log("FinAccountTypeList+++++++++++++++++"+FinAccountTypeList);
>         } catch (GenericEntityException e) {
>             Debug.logError(e, module);
>         }      
>         return FinAccountTypeList;
>     }
>
>
> But its giving error as
>
>
> The Following Errors Occurred:
>
> Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service
> invocation error (Service [getFinAccountType] did not return a Map object)
>
>
> Please let me know the am I missed anything.
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: problem while returning list object

BJ Freeman
In reply to this post by prasanthi_ofbiz
not sure this may lend to the problem but found a bug in the javalution
libray for fastmap and list.
was discusssed on the devlist.
changed to arraylist

prasanthi_ofbiz sent the following on 7/15/2010 2:54 AM:

>
> Hi
> I have created my own service which is created for returning a list. So I
> have added below code in the services_ledger.xml
> <service name="getFinAccountType" engine="java" export="true"
>       location="org.ofbiz.accounting.finaccount.FinAccountServices"
> invoke="getFinAccountType" auth="true">
>       <description>parameterizing Financial Account Type</description>
>       <log level="info" message="Entered into  getFinAccountType service of
> services_ledger....."/>
>       <attribute type="String" mode="IN" name="finAccountTypeId"
> optional="true" />
>       <attribute type="String" mode="IN" name="parentTypeId" optional="true"
> />
>       <attribute type="String" mode="IN" name="isRefundable" optional="true"
> />
>       <attribute type="String" mode="IN" name="replenishEnumId"
> optional="true" />
>       <attribute type="String" mode="IN" name="hasTable" optional="true" />
>       <attribute type="String" mode="IN" name="description" optional="true"
> />
>       <attribute name="FinAccountTypeList" type="List" mode="OUT"
> optional="true"/>
>      </service>
>
> and getFinAccountType functionis written in FinAccountServices.java file
>
> public static List getFinAccountType(DispatchContext dctx, Map context) {
>              LocalDispatcher dispatcher = dctx.getDispatcher();
>          GenericDelegator delegator = dctx.getDelegator();
>
>          GenericValue userLogin = (GenericValue) context.get("userLogin");
>          String finAccountTypeId = (String) context.get("finAccountTypeId");
>          String parentTypeId = (String) context.get("parentTypeId");
>          String replenishEnumId = (String) context.get("replenishEnumId");
>          String isRefundable = (String) context.get("isRefundable");
>          String hasTable = (String) context.get("hasTable");
>          String description = (String) context.get("description");
>          GenericValue finAccount=null;
>          Map finAcctg = UtilMisc.toMap("finAccountTypeId",
> finAccountTypeId,"description", description,"hasTable",
> hasTable,"isRefundable", isRefundable,"replenishEnumId",
> replenishEnumId,"parentTypeId", parentTypeId);
>
>          List exprs = FastList.newInstance();
>
>          if(finAccountTypeId!=null)
>          {
>           Debug.log("finAccountTypeId Added as a serach parameter");
>           exprs.add(EntityCondition.makeCondition("finAccountTypeId",
> EntityOperator.EQUALS, finAccountTypeId));
>          }
>          if(parentTypeId!=null)
>          {
>           Debug.log("parentTypeId Added as a serach parameter");
>            exprs.add(EntityCondition.makeCondition("parentTypeId",
> EntityOperator.EQUALS, parentTypeId));
>          }
>          if(replenishEnumId!=null)
>          {
>           Debug.log("replenishEnumId Added as a serach parameter");
>           exprs.add(EntityCondition.makeCondition("replenishEnumId",
> EntityOperator.EQUALS, replenishEnumId));
>          }
>          if(isRefundable!=null)
>          {
>           Debug.log("isRefundable Added as a serach parameter");
>           exprs.add(EntityCondition.makeCondition("isRefundable",
> EntityOperator.EQUALS, isRefundable));
>          }
>          if(hasTable!=null)
>          {
>           Debug.log("hasTable Added as a serach parameter");
>           exprs.add(EntityCondition.makeCondition("hasTable",
> EntityOperator.EQUALS, hasTable));
>          }
>          if(description!=null)
>          {
>           Debug.log("description Added as a serach parameter");
>           exprs.add(EntityCondition.makeCondition("description",
> EntityOperator.EQUALS, description));
>          }
>
>          List orderBy = UtilMisc.toList("-finAccountTypeId");
>          List FinAccountTypeList = null;
>          try {
>           FinAccountTypeList = delegator.findList("FinAccountType",
> EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy,
> null, false);
>              Debug.log("FinAccountTypeList SIZEE........
> "+FinAccountTypeList.size());
>
> Debug.log("FinAccountTypeList+++++++++++++++++"+FinAccountTypeList);
>          } catch (GenericEntityException e) {
>              Debug.logError(e, module);
>          }
>          return FinAccountTypeList;
>      }
>
>
> But its giving error as
>
>
> The Following Errors Occurred:
>
> Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service
> invocation error (Service [getFinAccountType] did not return a Map object)
>
>
> Please let me know the am I missed anything.
>