Ofbiz服务创建

时间:2014-02-25 09:36:28

标签: java ofbiz

开始学习ofbiz,我在这里按照教程: https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guide#OFBizTutorial-ABeginnersDevelopmentGuide-SecureYourApplicationbyAuthentication

现在我正在努力使人员的列表形式可编辑。在此步骤中,我需要创建一个用于自动字段服务的服务。下面我给出了我已经完成的代码。

在我的组件的controller.xml中,我创建了一个requestMaps,如下所示:

 <request-map uri="updatePracticePerson">
    <security https="true" auth="true"/>
    <event type="service" invoke="updatePracticePerson"/>
    <response name="success" type="view" value="personForm"/>
    <response name="error" type="view" value="personForm"/>
</request-map>

现在转到PracticeScreens.xml我对personForm有以下内容:

<screen name="personForm">
    <section>
        <actions>
            <set field="headerItem" value="personForm"/>
            <set field="titleProperty" value="PageTitlePracticePersonForm"/>
            <entity-condition entity-name="Person" list="persons"/>
        </actions>
        <widgets>
            <decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}">
                <decorator-section name="body">
                    <label text="Person List" style="h2"/>
                    <include-form name="ListPersons" location="component://practice/widget/PracticeForms.xml"></include-form>
                </decorator-section>
            </decorator-screen>       
        </widgets>
    </section>

以上内容包括来自PracticeForms.xml的ListPersons,我将其作为:

<form name="ListPersons" type="list" list-name="persons" list-entry-name="person" target="updatePracticePerson" paginate-target="personForm">
    <auto-fields-service service-name="updatePracticePerson" default-field-type="edit" map-name="person"/>
    <field name="partyId"><hidden/></field>
    <field name="submitButton" title="Update" widget-style="smallSubmit"><submit button-type="button"/></field>
    <field name="deletePracticePerson" title="Delete Person" widget-style="buttontext">
        <hyperlink target="deletePracticePerson?partyId=${person.partyId}" description="${uiLabelMap.CommonDelete}" also-hidden="false"/>
    </field>
    <field name="submitButton" title="${uiLabelMap.CommonUpdate}"><submit button-type="button"/></field>
</form>

如果您在上面看到ListPersons调用服务updatePracticePerson。

在servicedef / services.xml中我有以下内容:

 <service name="updatePracticePerson" default-entity-name="Person" engine="simple"
        location="component://practice/script/org/hotwax/practice/PracticeServices.xml" invoke="updatePracticePerson" auth="true">
    <description>Create a Person</description>
    <auto-attributes include="pk" mode="IN" optional="false"/>
    <attribute name="salutation" mode="IN" type="String" optional="true"/>
    <attribute name="firstName" mode="IN" type="String" optional="false"/>
    <attribute name="middleName" mode="IN" type="String" optional="true"/>
    <attribute name="lastName" mode="IN" type="String" optional="false"/>
    <attribute name="suffix" mode="IN" type="String" optional="true"/>
</service>

在mybiz-component.xml文件的项目根目录中,我有:

 <service-resource type="model" loader="main" location="servicedef/services.xml"/>

这是为了确保我的服务已加载。

虽然以上所有内容对我来说都是正确的,但我收到以下错误:

org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen [component://common/widget/CommonScreens.xml#GlobalDecorator]: java.lang.RuntimeException: Error rendering included form named [ListPersons] at location [component://practice/widget/PracticeForms.xml]: java.lang.IllegalArgumentException: Error finding Service with name updatePracticePerson for auto-fields-service in a form widget (Error rendering included form named [ListPersons] at location [component://practice/widget/PracticeForms.xml]: java.lang.IllegalArgumentException: Error finding Service with name updatePracticePerson for auto-fields-service in a form widget)

这显然意味着一切都不好,我的服务有问题。你能帮忙吗?

提前致谢, gianis

2 个答案:

答案 0 :(得分:0)

重新启动OFBiz并检查日志。在启动期间,它将显示您加载组件,然后显示组件中定义的服务。您应该能够在日志中看到问题

答案 1 :(得分:0)

最后我自己找到了答案。

在mybiz-component.xml组件根目录下的文件中我有:

<resource-loader   name="personForm" type="component"/>

我什么时候应该:

<resource-loader   name="main" type="component"/>