Login  Register

[OFBiz] Users - Newbie question: creating a service

Posted by Christopher Farley on Nov 14, 2005; 7:00pm
URL: http://ofbiz.116.s1.nabble.com/OFBiz-Users-Newbie-question-creating-a-service-tp136477.html

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