首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ofbiz服务创建

Ofbiz服务创建
EN

Stack Overflow用户
提问于 2014-02-25 09:36:28
回答 2查看 1.2K关注 0票数 0

开始学习the时,我将遵循以下教程:https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guide#OFBizTutorial-ABeginnersDevelopmentGuide-SecureYourApplicationbyAuthentication

现在,我正在着手使名单形式的人可编辑。在这个步骤中,我需要创建一个用于自动字段服务的服务。下面我给出了我所做的代码。

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

代码语言:javascript
复制
 <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的以下内容:

代码语言:javascript
复制
<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的PracticeForms.xml,我有如下所示:

代码语言:javascript
复制
<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内部,我有以下内容:

代码语言:javascript
复制
 <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>

在the Component.xml文件中的项目根目录中,我拥有:

代码语言:javascript
复制
 <service-resource type="model" loader="main" location="servicedef/services.xml"/>

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

尽管在我看来,上述所有内容都是正确的,但我得到了以下错误:

代码语言:javascript
复制
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)

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

谢谢你,吉安尼斯

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-02-27 10:21:02

最后我自己找到了答案。

在我的file组件根目录的文件中,我有:

代码语言:javascript
复制
<resource-loader   name="personForm" type="component"/>

当我应该:

代码语言:javascript
复制
<resource-loader   name="main" type="component"/>
票数 0
EN

Stack Overflow用户

发布于 2014-02-26 02:59:55

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22010001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档