I have a URL in a controller like this:
<request-map uri="createGenericProductNumber"> <security https="true" auth="true"/> <event type="service" invoke="createGenericProductNumber"/> <response name="success" type="view" value="generatePartNumberForm"/> <response name="error" type="view" value="generatePartNumberForm"/> </request-map> The service is declared like this: <service name="createGenericProductNumber" engine="java" auth="true" default-entity-name="" location="com.fs.inventory.GenerateInventoryPartNumbers" invoke="createGenericProductNumber" use-transaction="true" validate="false" > <description> Create an endmill product id from the required inputs </description> <attribute name="kindId" type="String" mode="INOUT" optional="false"/> <attribute name="tableName" type="String" mode="IN" optional="false"/> <attribute name="encodeIdString" type="String" mode="IN" optional="false"/> <attribute name="partNumber" type="String" mode="OUT" optional="false"/> <attribute name="description" type="String" mode="OUT" optional="true"/> <attribute name="longDesc" type="String" mode="OUT" optional="true"/> </service> Note the "validate=false". This url is called from a screen that has lots of parameters not declared in service above like width, length, etc. None of these parameters are being passed to the createGenericProductNumber service in its context. I rewrote the the url like this: <request-map uri="createGenericProductNumber"> <security https="true" auth="true"/> <event type="java" path="com.fs.inventory.InventoryEvents" invoke="createGenericProductNumber"/> <response name="success" type="view" value="generatePartNumberForm"/> <response name="error" type="view" value="generatePartNumberForm"/> </request-map> In this case, all the parameters from the page are in the parameter map of the HttpServletRequest. Is there any way I can get the service engine to pass all the parameters from request in the context to the service and not just those in the service declaration? Thanks in Advance Skip |
Provided all the form parameters map to certain entity(ies) , you can use <auto-attibutes> on service definition to define all the parameters without explicitly specifying each attribute, of-course you can explicitly override/exclude certain parameters.
Regards Vikas On Apr 18, 2012, at 11:46 PM, Skip wrote: > I have a URL in a controller like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="service" invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > > The service is declared like this: > > <service name="createGenericProductNumber" engine="java" auth="true" > default-entity-name="" > location="com.fs.inventory.GenerateInventoryPartNumbers" > invoke="createGenericProductNumber" > use-transaction="true" validate="false" > > <description> > Create an endmill product id from the required inputs > </description> > <attribute name="kindId" type="String" mode="INOUT" > optional="false"/> > <attribute name="tableName" type="String" mode="IN" > optional="false"/> > <attribute name="encodeIdString" type="String" mode="IN" > optional="false"/> > <attribute name="partNumber" type="String" mode="OUT" > optional="false"/> > <attribute name="description" type="String" mode="OUT" > optional="true"/> > <attribute name="longDesc" type="String" mode="OUT" > optional="true"/> > </service> > > > Note the "validate=false". This url is called from a screen that has lots > of parameters not declared in service above like width, length, etc. None > of these parameters are being passed to the createGenericProductNumber > service in its context. > > > I rewrote the the url like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="java" path="com.fs.inventory.InventoryEvents" > invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > In this case, all the parameters from the page are in the parameter map of > the HttpServletRequest. > > Is there any way I can get the service engine to pass all the parameters > from request in the context to the service and not just those in the service > declaration? > > Thanks in Advance > Skip > |
Vikas
Thank for the response. However, in this case, if you look at the service definition below, the entity is passed in when the service is called. It is not known in advance. In the java code I wrote, I used GenericEntity.getAllFields() to retrieve the fields and map them to the values passed in in the request parameters. This all works fine. I would just like to use a service instead of java code. I could do that if I could convince the service engine to pass all the parameters in the HttpServletRequest in the context to the service. I expected that to happen if I used validate=false, but sadly, that is not the case. Is there perhaps another setting I can use? I scanned the services.xsd file but found no likely attribute. Or perhaps, I can modify the part of the service code where the context is built. I looked all over the service engine to see where it set up the context, but could not find where it happened. Skip -----Original Message----- From: Vikas Mayur [mailto:[hidden email]] Sent: Friday, April 20, 2012 1:59 AM To: [hidden email] Subject: Re: Service with validate=false not getting all parameters Provided all the form parameters map to certain entity(ies) , you can use <auto-attibutes> on service definition to define all the parameters without explicitly specifying each attribute, of-course you can explicitly override/exclude certain parameters. Regards Vikas On Apr 18, 2012, at 11:46 PM, Skip wrote: > I have a URL in a controller like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="service" invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > > The service is declared like this: > > <service name="createGenericProductNumber" engine="java" auth="true" > default-entity-name="" > location="com.fs.inventory.GenerateInventoryPartNumbers" > invoke="createGenericProductNumber" > use-transaction="true" validate="false" > > <description> > Create an endmill product id from the required inputs > </description> > <attribute name="kindId" type="String" mode="INOUT" > optional="false"/> > <attribute name="tableName" type="String" mode="IN" > optional="false"/> > <attribute name="encodeIdString" type="String" mode="IN" > optional="false"/> > <attribute name="partNumber" type="String" mode="OUT" > optional="false"/> > <attribute name="description" type="String" mode="OUT" > optional="true"/> > <attribute name="longDesc" type="String" mode="OUT" > optional="true"/> > </service> > > > Note the "validate=false". This url is called from a screen that has lots > of parameters not declared in service above like width, length, etc. None > of these parameters are being passed to the createGenericProductNumber > service in its context. > > > I rewrote the the url like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="java" path="com.fs.inventory.InventoryEvents" > invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > In this case, all the parameters from the page are in the parameter map of > the HttpServletRequest. > > Is there any way I can get the service engine to pass all the parameters > from request in the context to the service and not just those in the > declaration? > > Thanks in Advance > Skip > |
You can use string-map-prefix to get the random parameter. Please refer updateOrderItems service definition under (applications/order/servicedef/services.xml) Thanks & Regards -- Deepak Dixit ----- Original Message ----- From: "Skip" <[hidden email]> To: [hidden email] Sent: Friday, April 20, 2012 10:41:09 PM Subject: RE: Service with validate=false not getting all parameters Vikas Thank for the response. However, in this case, if you look at the service definition below, the entity is passed in when the service is called. It is not known in advance. In the java code I wrote, I used GenericEntity.getAllFields() to retrieve the fields and map them to the values passed in in the request parameters. This all works fine. I would just like to use a service instead of java code. I could do that if I could convince the service engine to pass all the parameters in the HttpServletRequest in the context to the service. I expected that to happen if I used validate=false, but sadly, that is not the case. Is there perhaps another setting I can use? I scanned the services.xsd file but found no likely attribute. Or perhaps, I can modify the part of the service code where the context is built. I looked all over the service engine to see where it set up the context, but could not find where it happened. Skip -----Original Message----- From: Vikas Mayur [mailto:[hidden email]] Sent: Friday, April 20, 2012 1:59 AM To: [hidden email] Subject: Re: Service with validate=false not getting all parameters Provided all the form parameters map to certain entity(ies) , you can use <auto-attibutes> on service definition to define all the parameters without explicitly specifying each attribute, of-course you can explicitly override/exclude certain parameters. Regards Vikas On Apr 18, 2012, at 11:46 PM, Skip wrote: > I have a URL in a controller like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="service" invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > > The service is declared like this: > > <service name="createGenericProductNumber" engine="java" auth="true" > default-entity-name="" > location="com.fs.inventory.GenerateInventoryPartNumbers" > invoke="createGenericProductNumber" > use-transaction="true" validate="false" > > <description> > Create an endmill product id from the required inputs > </description> > <attribute name="kindId" type="String" mode="INOUT" > optional="false"/> > <attribute name="tableName" type="String" mode="IN" > optional="false"/> > <attribute name="encodeIdString" type="String" mode="IN" > optional="false"/> > <attribute name="partNumber" type="String" mode="OUT" > optional="false"/> > <attribute name="description" type="String" mode="OUT" > optional="true"/> > <attribute name="longDesc" type="String" mode="OUT" > optional="true"/> > </service> > > > Note the "validate=false". This url is called from a screen that has lots > of parameters not declared in service above like width, length, etc. None > of these parameters are being passed to the createGenericProductNumber > service in its context. > > > I rewrote the the url like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="java" path="com.fs.inventory.InventoryEvents" > invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > In this case, all the parameters from the page are in the parameter map of > the HttpServletRequest. > > Is there any way I can get the service engine to pass all the parameters > from request in the context to the service and not just those in the > declaration? > > Thanks in Advance > Skip > |
In reply to this post by SkipDever
The best practice in OFBiz is to define a separate form/screen to perform the CRUD operation on a certain entity and it seems that you are trying to update multiple entities through some generic form & service? You may go with Deepak's suggestion.
Regards Vikas On Apr 20, 2012, at 10:41 PM, Skip wrote: > Vikas > > Thank for the response. However, in this case, if you look at the service > definition below, the entity is passed in when the service is called. It is > not known in advance. In the java code I wrote, I used > GenericEntity.getAllFields() to retrieve the fields and map them to the > values passed in in the request parameters. This all works fine. I would > just like to use a service instead of java code. I could do that if I could > convince the service engine to pass all the parameters in the > HttpServletRequest in the context to the service. I expected that to happen > if I used validate=false, but sadly, that is not the case. > > Is there perhaps another setting I can use? I scanned the services.xsd > file but found no likely attribute. Or perhaps, I can modify the part of > the service code where the context is built. I looked all over the service > engine to see where it set up the context, but could not find where it > happened. > > Skip > > > > -----Original Message----- > From: Vikas Mayur [mailto:[hidden email]] > Sent: Friday, April 20, 2012 1:59 AM > To: [hidden email] > Subject: Re: Service with validate=false not getting all parameters > > > Provided all the form parameters map to certain entity(ies) , you can use > <auto-attibutes> on service definition to define all the parameters without > explicitly specifying each attribute, of-course you can explicitly > override/exclude certain parameters. > > Regards > Vikas > > On Apr 18, 2012, at 11:46 PM, Skip wrote: > >> I have a URL in a controller like this: >> >> <request-map uri="createGenericProductNumber"> >> <security https="true" auth="true"/> >> <event type="service" invoke="createGenericProductNumber"/> >> <response name="success" type="view" >> value="generatePartNumberForm"/> >> <response name="error" type="view" value="generatePartNumberForm"/> >> </request-map> >> >> >> The service is declared like this: >> >> <service name="createGenericProductNumber" engine="java" auth="true" >> default-entity-name="" >> location="com.fs.inventory.GenerateInventoryPartNumbers" >> invoke="createGenericProductNumber" >> use-transaction="true" validate="false" > >> <description> >> Create an endmill product id from the required inputs >> </description> >> <attribute name="kindId" type="String" mode="INOUT" >> optional="false"/> >> <attribute name="tableName" type="String" mode="IN" >> optional="false"/> >> <attribute name="encodeIdString" type="String" mode="IN" >> optional="false"/> >> <attribute name="partNumber" type="String" mode="OUT" >> optional="false"/> >> <attribute name="description" type="String" mode="OUT" >> optional="true"/> >> <attribute name="longDesc" type="String" mode="OUT" >> optional="true"/> >> </service> >> >> >> Note the "validate=false". This url is called from a screen that has lots >> of parameters not declared in service above like width, length, etc. None >> of these parameters are being passed to the createGenericProductNumber >> service in its context. >> >> >> I rewrote the the url like this: >> >> <request-map uri="createGenericProductNumber"> >> <security https="true" auth="true"/> >> <event type="java" path="com.fs.inventory.InventoryEvents" >> invoke="createGenericProductNumber"/> >> <response name="success" type="view" >> value="generatePartNumberForm"/> >> <response name="error" type="view" value="generatePartNumberForm"/> >> </request-map> >> >> In this case, all the parameters from the page are in the parameter map of >> the HttpServletRequest. >> >> Is there any way I can get the service engine to pass all the parameters >> from request in the context to the service and not just those in the > service >> declaration? >> >> Thanks in Advance >> Skip >> > > |
In reply to this post by Deepak Dixit-2
Deepak
Thanks for this, I checked your example and I think this will work fine for me. Skip -----Original Message----- From: Deepak Dixit [mailto:[hidden email]] Sent: Friday, April 20, 2012 10:42 PM To: [hidden email] Subject: Re: Service with validate=false not getting all parameters You can use string-map-prefix to get the random parameter. Please refer updateOrderItems service definition under (applications/order/servicedef/services.xml) Thanks & Regards -- Deepak Dixit ----- Original Message ----- From: "Skip" <[hidden email]> To: [hidden email] Sent: Friday, April 20, 2012 10:41:09 PM Subject: RE: Service with validate=false not getting all parameters Vikas Thank for the response. However, in this case, if you look at the service definition below, the entity is passed in when the service is called. It is not known in advance. In the java code I wrote, I used GenericEntity.getAllFields() to retrieve the fields and map them to the values passed in in the request parameters. This all works fine. I would just like to use a service instead of java code. I could do that if I could convince the service engine to pass all the parameters in the HttpServletRequest in the context to the service. I expected that to happen if I used validate=false, but sadly, that is not the case. Is there perhaps another setting I can use? I scanned the services.xsd file but found no likely attribute. Or perhaps, I can modify the part of the service code where the context is built. I looked all over the service engine to see where it set up the context, but could not find where it happened. Skip -----Original Message----- From: Vikas Mayur [mailto:[hidden email]] Sent: Friday, April 20, 2012 1:59 AM To: [hidden email] Subject: Re: Service with validate=false not getting all parameters Provided all the form parameters map to certain entity(ies) , you can use <auto-attibutes> on service definition to define all the parameters without explicitly specifying each attribute, of-course you can explicitly override/exclude certain parameters. Regards Vikas On Apr 18, 2012, at 11:46 PM, Skip wrote: > I have a URL in a controller like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="service" invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > > The service is declared like this: > > <service name="createGenericProductNumber" engine="java" auth="true" > default-entity-name="" > location="com.fs.inventory.GenerateInventoryPartNumbers" > invoke="createGenericProductNumber" > use-transaction="true" validate="false" > > <description> > Create an endmill product id from the required inputs > </description> > <attribute name="kindId" type="String" mode="INOUT" > optional="false"/> > <attribute name="tableName" type="String" mode="IN" > optional="false"/> > <attribute name="encodeIdString" type="String" mode="IN" > optional="false"/> > <attribute name="partNumber" type="String" mode="OUT" > optional="false"/> > <attribute name="description" type="String" mode="OUT" > optional="true"/> > <attribute name="longDesc" type="String" mode="OUT" > optional="true"/> > </service> > > > Note the "validate=false". This url is called from a screen that has lots > of parameters not declared in service above like width, length, etc. None > of these parameters are being passed to the createGenericProductNumber > service in its context. > > > I rewrote the the url like this: > > <request-map uri="createGenericProductNumber"> > <security https="true" auth="true"/> > <event type="java" path="com.fs.inventory.InventoryEvents" > invoke="createGenericProductNumber"/> > <response name="success" type="view" > value="generatePartNumberForm"/> > <response name="error" type="view" value="generatePartNumberForm"/> > </request-map> > > In this case, all the parameters from the page are in the parameter map of > the HttpServletRequest. > > Is there any way I can get the service engine to pass all the parameters > from request in the context to the service and not just those in the > declaration? > > Thanks in Advance > Skip > |
Free forum by Nabble | Edit this page |