[OFBiz] Users - Newbie question: creating a service

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

[OFBiz] Users - Newbie question: creating a service

Christopher Farley
I'm stuck on something really basic and really stupd! I don't know how to
access form data from a service.

>From reading the tutorials and seeing other apps, it looks like the
"parameters" map should contain the input fields, but when I look
at the parameters map, all I get are locale and userLogin fields.

I'm trying to create a screen to automatically generate requirements, and
I'm modifying existing ofbiz files rather than creating a whole new
app.

Here's what I've done:

1) Create a screen in applications/order/widget/ordermgr/RequirementScreens.xml
-------------------------------------------------------------------------------
   <!-- screen for generating requirements -->
    <screen name="GenerateRequirements">
        <section>
            <actions>
                <set field="facilityId" from-field="parameters.facilityId"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonRequirementDecorator">
                    <decorator-section name="body">
                        <include-form name="GenerateRequirements" location="component://order/webapp/ordermgr/requirement/RequirementForms.xml"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>        

2) Create a form in applications/order/webapp/ordermgr/requirement/RequirementForms.xml
-------------------------------------------------------------------------------
    <form name="GenerateRequirements" type="single"
            target="generateRequirements" title=""
            default-title-style="tableheadtext"
            default-widget-style="tabletext" default-tooltip-style="tabletext">
        <field name="facilityId" title="${uiLabelMap.ProductFacilityId}">
            <text/>
        </field>
        <field name="submitButton" widget-style="smallSubmit"><submit/></field>
    </form>        

3) Create a service definition in
applications/order/servicedef/services_requirement.xml
-------------------------------------------------------------------------------
    <service name="autoGenerateRequirements" engine="simple"
            location="org/ofbiz/order/requirement/RequirementServices.xml" invoke="autoGenerateRequirements">
        <description>Automatically generates requirements based on ATP</description>
        <attribute mode="IN" name="facilityId" type="String" optional="false"/>
    </service>

4) Create the service in
applications/order/script/org/ofbiz/order/requirement/RequirementServices.xml  
-------------------------------------------------------------------------------
    <simple-method method-name="autoGenerateRequirements" short-description="Automatically generate requirements based on ATP">
        <set from-field="facilityId" field="searchMap.facilityId"/>
        <find-by-and entity-name="ProductFacility" list-name="allProducts" map-name="searchMap" use-iterator="true"/>
        <log level="always" message="parameters == ${parameters}"/>
        <log level="always" message="searchMap == ${searchMap}"/>
        <log level="always" message="facilityId == ${facilityId}"/>
    </simple-method>        

5) Put the entries in applications/order/webapp/ordermgr/WEB-INF/controller.xml
-------------------------------------------------------------------------------
    <request-map uri="GenerateRequirements">
        <security https="true" auth="true"/>
        <response name="success" type="view" value="GenerateRequirements"/>
    </request-map>
    <request-map uri="generateRequirements">
        <security https="true" auth="true"/>
        <event type="service" invoke="autoGenerateRequirements"/>
        <response name="success" type="view" value="ReviewRequirements"/>
        <response name="error" type="view" value="GenerateRequirements"/>
    </request-map>          

    <view-map name="GenerateRequirements" type="screen" page="component://order/widget/ordermgr/RequirementScreens.xml#GenerateRequirements"/>  

-------------------------------------------------------------------------------
Here's what's getting logged:

59855607 (http-0.0.0.0-8443-Processor2) [                Log.java:103:INFO ] parameters == {locale=en_US, userLogin=[GenericEntity:UserLogin][createdStamp,2005-11-01 19:36:41.975(java.sql.Timestamp)][createdTxStamp,2005-11-01 19:36:41.622(java.sql.Timestamp)][currentPassword,47ca69ebb4bdc9ae0adec130880165d2cc05db1a(java.lang.String)][disabledDateTime,null()][enabled,Y(java.lang.String)][hasLoggedOut,N(java.lang.String)][isSystem,null()][lastCurrencyUom,null()][lastLocale,null()][lastUpdatedStamp,2005-11-12 00:07:09.613(java.sql.Timestamp)][lastUpdatedTxStamp,2005-11-12 00:07:09.611(java.sql.Timestamp)][partyId,admin(java.lang.String)][passwordHint,null()][successiveFailedLogins,null()][userLoginId,admin(java.lang.String)]}
59855621 (http-0.0.0.0-8443-Processor2) [                Log.java:103:INFO ] searchMap ==
59855643 (http-0.0.0.0-8443-Processor2) [                Log.java:103:INFO ] facilityId ==          

I'm sure I'm missing something quite basic. Can anyone help?? Thanks!
--
Christopher Farley
www.northernbrewer.com
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - Newbie question: creating a service

Si Chen-2
Kind of hard to figure it out just from looking at this, but this
doesn't look right:

>    <simple-method method-name="autoGenerateRequirements" short-description="Automatically generate requirements based on ATP">
>        <set from-field="facilityId" field="searchMap.facilityId"/>
>  
>
doesn't look right. It probably should be:
<set from-field="parameters.facilityId" .... >

because facilityId should be a part of your parameters Map.

If you're new to OFBiz, you might want to try writing your first
services in Java, if that's easier for you. Once you get familiar with
the concepts of OFBiz services, the minilang will be more intuitive.

Si
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - Newbie question: creating a service

Christopher Farley
Si Chen ([hidden email]) wrote:

> Kind of hard to figure it out just from looking at this, but this
> doesn't look right:
>
> >   <simple-method method-name="autoGenerateRequirements"
> >   short-description="Automatically generate requirements based on ATP">
> >       <set from-field="facilityId" field="searchMap.facilityId"/>
> >
> >
> doesn't look right. It probably should be:
> <set from-field="parameters.facilityId" .... >
>
> because facilityId should be a part of your parameters Map.

Ah, but when I inspect the values of the parameters map via a log
statement, the only parameter values in there are locale and userLogin.
The form fields do not get properly embedded in the parameters map.

I figure I've misconfigured something else that links the form or the
screen to the simple-method... maybe.  

I'll go through tutorial #3 again and see what I might be missing...
Thanks for looking.

--
Christopher Farley
www.northernbrewer.com
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

[OFBiz] Users - Re: [OFBiz] SOLVED: Users - Newbie question: creating a service

Christopher Farley
Christopher Farley ([hidden email]) wrote:

> Ah, but when I inspect the values of the parameters map via a log
> statement, the only parameter values in there are locale and userLogin.
> The form fields do not get properly embedded in the parameters map.

I restarted the ofbiz server and all of the sudden everything worked
as expected. So, let me guess: the servicedef file is loaded only when
the server starts, and my modifications to it (setting up the input
parameters to the service) were being ignored.

Am I warm?

--
Christopher Farley
www.northernbrewer.com
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - Re: [OFBiz] SOLVED: Users - Newbie question: creating a service

Jacopo Cappellato
Yes.


Christopher Farley wrote:

> Christopher Farley ([hidden email]) wrote:
>
>
>>Ah, but when I inspect the values of the parameters map via a log
>>statement, the only parameter values in there are locale and userLogin.
>>The form fields do not get properly embedded in the parameters map.
>
>
> I restarted the ofbiz server and all of the sudden everything worked
> as expected. So, let me guess: the servicedef file is loaded only when
> the server starts, and my modifications to it (setting up the input
> parameters to the service) were being ignored.
>
> Am I warm?
>

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users