ofbiz错误通过表单和minilang创建一个新的实体

时间:2014-11-04 12:05:09

标签: ofbiz

我尝试使用MiniLang和表单创建一个新实体。

实体定义是:

<entity entity-name="station" package-name="org.ofbiz.mystations"
    title="Entity for station data">
    <field name="stationId" type="id-ne"></field>
    <field name="Name" type="id"></field>
    <field name="Strasse" type="id"></field>
    <field name="Hausnr" type="id"></field>
    <field name="PLZ" type="id"></field>
    <field name="Ort" type="id"></field>
    <field name="Beschreibung" type="id"></field>
    <prim-key field="stationId" />      
</entity>    

表格是这样的:

<form name="addStation" type="single" target="createStation">
<auto-fields-service service-name="createStation"/>
<auto-fields-entity entity-name="station"/>
<field name="stationId"><hidden/></field> 
<field name="Name"></field>
<field name="Strasse"></field>
<field name="Hausnr"></field>
<field name="Ort"></field>
<field name="Beschreibung"></field>
<field name="submitButton" title="add Station" widget-style="standardSubmit"><submit     button-type="button"/></field>
  </form>
</forms>

并且minilang-service定义是这样的:

<simple-method method-name="createStation" short-description="Create a Station"
  login-required="true">
  <make-value entity-name="station"  value-name="newEntity" />
  <set-nonpk-fields map-name="parameters" value-name="newEntity" />
  <set-pk-fields map-name="parameters" value-name="newEntity" />
  <create-value value-name="newEntity" />
 </simple-method>

现在我得到的错误是: 找不到名称的实体值:Method = createStation,File = file:/home/std/Dokumente/ofbiz/hot-deploy/mystations/script/org/ofbiz/mystations/mystationsServices.xml,Element =,Line 16null

出了什么问题?实体“站”存在。 我可以获得更多信息(错误日志在哪里?)。 如何获取调试信息?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

现在我发现了正确的代码 用于创建新值。 附加简单方法声明 需要一个有序的id语句 自动递增主键(stationId)。

现在有效!

以下是代码:

    <simple-method method-name="createStation" short-description="Create a Station"
      login-required="true">
      <make-value entity-name="station" map-name="parameters" value-field="newEntity" />
        <set-pk-fields map="parameters" value-field="newEntity" />
        <set-nonpk-fields map="parameters" value-field="newEntity" />        
        <if-empty field="newEntity.stationId">
            <sequenced-id sequence-name="station" field="newEntity.stationId" />
            <else>
                <check-id field="newEntity.stationId" />
                <check-errors />
            </else>
        </if-empty>  
      <create-value value-field="newEntity" />
     </simple-method>