I'm working with a simple method that is called by an event of type
"service-multi". I want the simple method to create a variable when the first row is processed, then maintain the value of that variable throughout processing of the rest of the rows. So far I haven't been able to keep the variable's value from one row to the next row. I tried to use a service input of INOUT and pass it to the session. But the value is lost upon the processing of each row. I tried putting the variable in the session using the following code, but the variable is never there after the first row is processed: <field-to-session field-name="newFundRecords"></field-to-session> Does anyone have an idea how I can get this done? Thanks, Rob Riggins Integral Business Solutions _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev |
As mentioned in the docs the various *session and *request operation in the simple-method only do something when the simple-method is called as an event, ie they do nothing when it it called as a service because in that case there is no request or session or other servlet related objects. You should still be able to do this by defining that value to be passed from one row to the next as an INOUT attribute that is optional so it doesn't complain on the first row... When the service multi event handler calls a service it will look for all of the "IN" (and "INOUT") attributes for that service and try to find them in request parameters, and then in request attributes which is where the service OUT and INOUT parameter values are put when a service returns. -David On Jan 5, 2006, at 8:24 AM, Robert Riggins wrote: > I'm working with a simple method that is called by an event of type > "service-multi". I want the simple method to create a variable when > the > first row is processed, then maintain the value of that variable > throughout processing of the rest of the rows. > > So far I haven't been able to keep the variable's value from one > row to > the next row. > > I tried to use a service input of INOUT and pass it to the session. > But > the value is lost upon the processing of each row. > > I tried putting the variable in the session using the following code, > but the variable is never there after the first row is processed: > <field-to-session field-name="newFundRecords"></field-to-session> > > Does anyone have an idea how I can get this done? > > Thanks, > Rob Riggins > Integral Business Solutions > > _______________________________________________ > Dev mailing list > [hidden email] > http://lists.ofbiz.org/mailman/listinfo/dev _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev smime.p7s (3K) Download Attachment |
In reply to this post by Robert Riggins
I've tried INOUT as a parameter value and used the field-to-result
simple- method operation to pass the value to the next iteration, but still with no luck. The value does not appear in the parameters when the next row is being processed. One of my coworkers looked into the service-multi event handler and compared it to the service event handler. He didn't see the code in the service-multi that puts OUT/INOUT parameters back in the request like the service event handler has. Please let me know if you have any others ideas on this. Thanks, Rob Riggins Integral Business Solutions -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of David E. Jones Sent: Thursday, January 05, 2006 12:59 PM To: OFBiz Project Development Discussion Subject: Re: [OFBiz] Dev - Service-multi and a session variable As mentioned in the docs the various *session and *request operation in the simple-method only do something when the simple-method is called as an event, ie they do nothing when it it called as a service because in that case there is no request or session or other servlet related objects. You should still be able to do this by defining that value to be passed from one row to the next as an INOUT attribute that is optional so it doesn't complain on the first row... When the service multi event handler calls a service it will look for all of the "IN" (and "INOUT") attributes for that service and try to find them in request parameters, and then in request attributes which is where the service OUT and INOUT parameter values are put when a service returns. -David On Jan 5, 2006, at 8:24 AM, Robert Riggins wrote: > I'm working with a simple method that is called by an event of type > "service-multi". I want the simple method to create a variable when > the first row is processed, then maintain the value of that variable > throughout processing of the rest of the rows. > > So far I haven't been able to keep the variable's value from one row > to the next row. > > I tried to use a service input of INOUT and pass it to the session. > But > the value is lost upon the processing of each row. > > I tried putting the variable in the session using the following code, > but the variable is never there after the first row is processed: > <field-to-session field-name="newFundRecords"></field-to-session> > > Does anyone have an idea how I can get this done? > > Thanks, > Rob Riggins > Integral Business Solutions > > _______________________________________________ > Dev mailing list > [hidden email] > http://lists.ofbiz.org/mailman/listinfo/dev _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev |
In reply to this post by Robert Riggins
Below is a patch to add OUT/INOUT parameters back into the request for
the service-multi event handler. It didn't seem to break anything in my quick tests. For this to be effective, it needs to be used with the _checkGlobalScope flag. If this patch is acceptable, I'll submit a couple more to add the _checkGlobalScope flag as an attribute to the form element of the form widget. -Chris Index: F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/event/S erviceMultiEventHandler.java =================================================================== --- F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/event/S erviceMultiEventHandler.java (revision 6473) +++ F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/event/S erviceMultiEventHandler.java (working copy) @@ -297,6 +297,20 @@ if (UtilValidate.isNotEmpty(errorMessage)) { errorMessages.add(errorMessage); } + + // set the results in the request + Iterator ri = result.keySet().iterator(); + while (ri.hasNext()) { + String resultKey = (String) ri.next(); + Object resultValue = result.get((Object) resultKey); + + if (!resultKey.equals(ModelService.RESPONSE_MESSAGE) && !resultKey.equals(ModelService.ERROR_MESSAGE) && + !resultKey.equals(ModelService.ERROR_MESSAGE_LIST) && !resultKey.equals(ModelService.ERROR_MESSAGE_MAP) && + !resultKey.equals(ModelService.SUCCESS_MESSAGE) && !resultKey.equals(ModelService.SUCCESS_MESSAGE_LIST)) { + request.setAttribute(resultKey, resultValue); + } + } + } if (errorMessages.size() > 0) { > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On > Behalf Of Robert Riggins > Sent: Friday, January 06, 2006 10:06 AM > To: OFBiz Project Development Discussion > Subject: Re: [OFBiz] Dev - Service-multi and a session variable > > I've tried INOUT as a parameter value and used the field-to-result > simple- method operation to pass the value to the next iteration, but > still with no luck. The value does not appear in the parameters when the > next row is being processed. > > One of my coworkers looked into the service-multi event handler and > compared it to the service event handler. He didn't see the code in the > service-multi that puts OUT/INOUT parameters back in the request like > the service event handler has. > > Please let me know if you have any others ideas on this. > > Thanks, > Rob Riggins > Integral Business Solutions > > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] > On Behalf Of David E. Jones > Sent: Thursday, January 05, 2006 12:59 PM > To: OFBiz Project Development Discussion > Subject: Re: [OFBiz] Dev - Service-multi and a session variable > > > As mentioned in the docs the various *session and *request operation > the simple-method only do something when the simple-method is called as > an event, ie they do nothing when it it called as a service because in > that case there is no request or session or other servlet related > objects. > > You should still be able to do this by defining that value to be passed > from one row to the next as an INOUT attribute that is optional so it > doesn't complain on the first row... When the service multi event > handler calls a service it will look for all of the "IN" (and "INOUT") > attributes for that service and try to find them in request parameters, > and then in request attributes which is where the service OUT and INOUT > parameter values are put when a service returns. > > -David > > > On Jan 5, 2006, at 8:24 AM, Robert Riggins wrote: > > > I'm working with a simple method that is called by an event of type > > "service-multi". I want the simple method to create a variable when > > the first row is processed, then maintain the value of that variable > > throughout processing of the rest of the rows. > > > > So far I haven't been able to keep the variable's value from one row > > to the next row. > > > > I tried to use a service input of INOUT and pass it to the session. > > But > > the value is lost upon the processing of each row. > > > > I tried putting the variable in the session using the following > > but the variable is never there after the first row is processed: > > <field-to-session field-name="newFundRecords"></field-to-session> > > > > Does anyone have an idea how I can get this done? > > > > Thanks, > > Rob Riggins > > Integral Business Solutions > > > > _______________________________________________ > > Dev mailing list > > [hidden email] > > http://lists.ofbiz.org/mailman/listinfo/dev > > > _______________________________________________ > Dev mailing list > [hidden email] > http://lists.ofbiz.org/mailman/listinfo/dev _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev |
Thanks for the details Rob and the proposed fix Chris. I took a peek at this and made some changes, plus cleaned up a few things as I was reviewing the code... The changes are in SVN rev 6475 and here is the commit log comment: "Added code to put output/result of one service call to the next one in a service-multi event; also did some code cleanup for speed and transaction safety; also changed the default for the _checkGlobalScope flag so it is true/Y by default, this could potentially cause problems in some cases but I think it would be pretty rare and this being true is more expected behavior and more consistent with other things" If anyone has any thoughts/objections to this let me know... -David On Jan 6, 2006, at 10:27 PM, Chris Chesney wrote: > Below is a patch to add OUT/INOUT parameters back into the request for > the service-multi event handler. It didn't seem to break anything > in my > quick tests. For this to be effective, it needs to be used with the > _checkGlobalScope flag. If this patch is acceptable, I'll submit a > couple more to add the _checkGlobalScope flag as an attribute to the > form element of the form widget. > > -Chris > > > Index: > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > event/S > erviceMultiEventHandler.java > =================================================================== > --- > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > event/S > erviceMultiEventHandler.java (revision 6473) > +++ > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > event/S > erviceMultiEventHandler.java (working copy) > @@ -297,6 +297,20 @@ > if (UtilValidate.isNotEmpty(errorMessage)) { > errorMessages.add(errorMessage); > } > + > + // set the results in the request > + Iterator ri = result.keySet().iterator(); > + while (ri.hasNext()) { > + String resultKey = (String) ri.next(); > + Object resultValue = result.get((Object) resultKey); > + > + if (!resultKey.equals > (ModelService.RESPONSE_MESSAGE) && > !resultKey.equals(ModelService.ERROR_MESSAGE) && > + > !resultKey.equals(ModelService.ERROR_MESSAGE_LIST) && > !resultKey.equals(ModelService.ERROR_MESSAGE_MAP) && > + !resultKey.equals > (ModelService.SUCCESS_MESSAGE) > && !resultKey.equals(ModelService.SUCCESS_MESSAGE_LIST)) { > + request.setAttribute(resultKey, resultValue); > + } > + } > + > } > > if (errorMessages.size() > 0) { > > > >> -----Original Message----- >> From: [hidden email] [mailto:dev- >> [hidden email]] > On >> Behalf Of Robert Riggins >> Sent: Friday, January 06, 2006 10:06 AM >> To: OFBiz Project Development Discussion >> Subject: Re: [OFBiz] Dev - Service-multi and a session variable >> >> I've tried INOUT as a parameter value and used the field-to-result >> simple- method operation to pass the value to the next iteration, but >> still with no luck. The value does not appear in the parameters when > the >> next row is being processed. >> >> One of my coworkers looked into the service-multi event handler and >> compared it to the service event handler. He didn't see the code in > the >> service-multi that puts OUT/INOUT parameters back in the request like >> the service event handler has. >> >> Please let me know if you have any others ideas on this. >> >> Thanks, >> Rob Riggins >> Integral Business Solutions >> >> -----Original Message----- >> From: [hidden email] [mailto:dev- >> [hidden email]] >> On Behalf Of David E. Jones >> Sent: Thursday, January 05, 2006 12:59 PM >> To: OFBiz Project Development Discussion >> Subject: Re: [OFBiz] Dev - Service-multi and a session variable >> >> >> As mentioned in the docs the various *session and *request operation > in >> the simple-method only do something when the simple-method is called > as >> an event, ie they do nothing when it it called as a service >> because in >> that case there is no request or session or other servlet related >> objects. >> >> You should still be able to do this by defining that value to be > passed >> from one row to the next as an INOUT attribute that is optional so it >> doesn't complain on the first row... When the service multi event >> handler calls a service it will look for all of the "IN" (and >> "INOUT") >> attributes for that service and try to find them in request > parameters, >> and then in request attributes which is where the service OUT and > INOUT >> parameter values are put when a service returns. >> >> -David >> >> >> On Jan 5, 2006, at 8:24 AM, Robert Riggins wrote: >> >>> I'm working with a simple method that is called by an event of type >>> "service-multi". I want the simple method to create a variable when >>> the first row is processed, then maintain the value of that variable >>> throughout processing of the rest of the rows. >>> >>> So far I haven't been able to keep the variable's value from one row >>> to the next row. >>> >>> I tried to use a service input of INOUT and pass it to the session. >>> But >>> the value is lost upon the processing of each row. >>> >>> I tried putting the variable in the session using the following > code, >>> but the variable is never there after the first row is processed: >>> <field-to-session field-name="newFundRecords"></field-to-session> >>> >>> Does anyone have an idea how I can get this done? >>> >>> Thanks, >>> Rob Riggins >>> Integral Business Solutions >>> >>> _______________________________________________ >>> Dev mailing list >>> [hidden email] >>> http://lists.ofbiz.org/mailman/listinfo/dev >> >> >> _______________________________________________ >> Dev mailing list >> [hidden email] >> http://lists.ofbiz.org/mailman/listinfo/dev > > _______________________________________________ > Dev mailing list > [hidden email] > http://lists.ofbiz.org/mailman/listinfo/dev _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev smime.p7s (3K) Download Attachment |
In reply to this post by Robert Riggins
Thanks David. This should take care of it for us.
-Chris > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On > Behalf Of David E. Jones > Sent: Saturday, January 07, 2006 11:59 AM > To: OFBiz Project Development Discussion > Subject: Re: [OFBiz] Dev - Service-multi and a session variable > > > Thanks for the details Rob and the proposed fix Chris. I took a peek > at this and made some changes, plus cleaned up a few things as I was > reviewing the code... The changes are in SVN rev 6475 and here is the > commit log comment: > > "Added code to put output/result of one service call to the next one > in a service-multi event; also did some code cleanup for speed and > transaction safety; also changed the default for the > _checkGlobalScope flag so it is true/Y by default, this could > potentially cause problems in some cases but I think it would be > pretty rare and this being true is more expected behavior and more > consistent with other things" > > If anyone has any thoughts/objections to this let me know... > > -David > > > On Jan 6, 2006, at 10:27 PM, Chris Chesney wrote: > > > Below is a patch to add OUT/INOUT parameters back into the request > > the service-multi event handler. It didn't seem to break anything > > in my > > quick tests. For this to be effective, it needs to be used with the > > _checkGlobalScope flag. If this patch is acceptable, I'll submit a > > couple more to add the _checkGlobalScope flag as an attribute to the > > form element of the form widget. > > > > -Chris > > > > > > Index: > > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > > event/S > > erviceMultiEventHandler.java > > =================================================================== > > --- > > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > > event/S > > erviceMultiEventHandler.java (revision 6473) > > +++ > > F:/eclipse/workspace/ofbiz/framework/webapp/src/org/ofbiz/webapp/ > > event/S > > erviceMultiEventHandler.java (working copy) > > @@ -297,6 +297,20 @@ > > if (UtilValidate.isNotEmpty(errorMessage)) { > > errorMessages.add(errorMessage); > > } > > + > > + // set the results in the request > > + Iterator ri = result.keySet().iterator(); > > + while (ri.hasNext()) { > > + String resultKey = (String) ri.next(); > > + Object resultValue = result.get((Object) > > + > > + if (!resultKey.equals > > (ModelService.RESPONSE_MESSAGE) && > > !resultKey.equals(ModelService.ERROR_MESSAGE) && > > + > > !resultKey.equals(ModelService.ERROR_MESSAGE_LIST) && > > !resultKey.equals(ModelService.ERROR_MESSAGE_MAP) && > > + !resultKey.equals > > (ModelService.SUCCESS_MESSAGE) > > && !resultKey.equals(ModelService.SUCCESS_MESSAGE_LIST)) { > > + request.setAttribute(resultKey, resultValue); > > + } > > + } > > + > > } > > > > if (errorMessages.size() > 0) { > > > > > > > >> -----Original Message----- > >> From: [hidden email] [mailto:dev- > >> [hidden email]] > > On > >> Behalf Of Robert Riggins > >> Sent: Friday, January 06, 2006 10:06 AM > >> To: OFBiz Project Development Discussion > >> Subject: Re: [OFBiz] Dev - Service-multi and a session variable > >> > >> I've tried INOUT as a parameter value and used the field-to-result > >> simple- method operation to pass the value to the next iteration, > >> still with no luck. The value does not appear in the parameters when > > the > >> next row is being processed. > >> > >> One of my coworkers looked into the service-multi event handler and > >> compared it to the service event handler. He didn't see the code in > > the > >> service-multi that puts OUT/INOUT parameters back in the request like > >> the service event handler has. > >> > >> Please let me know if you have any others ideas on this. > >> > >> Thanks, > >> Rob Riggins > >> Integral Business Solutions > >> > >> -----Original Message----- > >> From: [hidden email] [mailto:dev- > >> [hidden email]] > >> On Behalf Of David E. Jones > >> Sent: Thursday, January 05, 2006 12:59 PM > >> To: OFBiz Project Development Discussion > >> Subject: Re: [OFBiz] Dev - Service-multi and a session variable > >> > >> > >> As mentioned in the docs the various *session and *request > > in > >> the simple-method only do something when the simple-method is called > > as > >> an event, ie they do nothing when it it called as a service > >> because in > >> that case there is no request or session or other servlet related > >> objects. > >> > >> You should still be able to do this by defining that value to be > > passed > >> from one row to the next as an INOUT attribute that is optional so it > >> doesn't complain on the first row... When the service multi event > >> handler calls a service it will look for all of the "IN" (and > >> "INOUT") > >> attributes for that service and try to find them in request > > parameters, > >> and then in request attributes which is where the service OUT and > > INOUT > >> parameter values are put when a service returns. > >> > >> -David > >> > >> > >> On Jan 5, 2006, at 8:24 AM, Robert Riggins wrote: > >> > >>> I'm working with a simple method that is called by an event of > >>> "service-multi". I want the simple method to create a variable when > >>> the first row is processed, then maintain the value of that variable > >>> throughout processing of the rest of the rows. > >>> > >>> So far I haven't been able to keep the variable's value from one row > >>> to the next row. > >>> > >>> I tried to use a service input of INOUT and pass it to the session. > >>> But > >>> the value is lost upon the processing of each row. > >>> > >>> I tried putting the variable in the session using the following > > code, > >>> but the variable is never there after the first row is processed: > >>> <field-to-session field-name="newFundRecords"></field-to-session> > >>> > >>> Does anyone have an idea how I can get this done? > >>> > >>> Thanks, > >>> Rob Riggins > >>> Integral Business Solutions > >>> > >>> _______________________________________________ > >>> Dev mailing list > >>> [hidden email] > >>> http://lists.ofbiz.org/mailman/listinfo/dev > >> > >> > >> _______________________________________________ > >> Dev mailing list > >> [hidden email] > >> http://lists.ofbiz.org/mailman/listinfo/dev > > > > _______________________________________________ > > Dev mailing list > > [hidden email] > > http://lists.ofbiz.org/mailman/listinfo/dev _______________________________________________ Dev mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/dev |
Free forum by Nabble | Edit this page |