java - 如何从ofbiz中的简单方法调用java方法

标签 java ofbiz

我正在尝试从这样的简单方法调用java方法

<simple-method method-name="getProduct">
    <entity-one entity-name="Product" value-field="product">
      <field-map field-name="productId" from-field="parameters.productId" />
    </entity-one>
    <log message="productView=${product.uom}" level="info"/>
    <entity-one value-field="uomInfo" entity-name="Uom">
      <field-map field-name="uomId" from-field="product.uom" />
    </entity-one>
    <if-compare operator="equals" value="1001" field="product.priceTypeId">
    <entity-one value-field="category" entity-name="ProductCategory">
      <field-map field-name="productCategoryId" from-field="product.priceTypeCategoryId" />
    </entity-one>
    <else>
     <entity-one value-field="category" entity-name="ProductCategory">
      <field-map field-name="productCategoryId" from-field="product.productCategoryId" />
     </entity-one>
    </else>
    </if-compare>
    <set field="product.productCategoryId" from-field="category.categoryName" default-value="all"/>
    <call-class-method method-name="encodeString" ret-field="encodedDescription" class-name="org.ofbiz.base.util.StringUtil">  
    <field field="product.description" type="String" /> 
    </call-class-method> 
    <field-to-result field="product" />
    <field-to-result field="uomInfo" />
  </simple-method>
</simple-methods>

当我尝试获取描述字段的值时,它返回相同的描述值,而没有使用编码值进行更新。

我还需要做其他事情吗?

最佳答案

您没有使用返回字符串设置描述值。

<call-class-method method-name="encodeString" ret-field="encodedDescription" class-name="org.ofbiz.base.util.StringUtil">  
    <field field="product.description" type="String" /> 
    </call-class-method> 

您的encodeString方法将返回一个编码字符串并将其设置为

返回字段 ret-field="encodedDescription"。

所以你需要这样设置你的描述

    <call-class-method method-name="encodeString" ret-field="encodedDescription" class-name="org.ofbiz.base.util.StringUtil">  
    <field field="product.description" type="String" /> 
    </call-class-method> 
    <set field="product.description" value="${encodedDescription}"/>

关于java - 如何从ofbiz中的简单方法调用java方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30859654/

相关文章:

categories - Ofbiz 中产品目录和类别之间的区别是什么?

caching - 如何在 Ofbiz 中实现 "Distributed cache clearing"?

java - setContentView(R.layout.main);错误

java - 初始化一个 ArrayList

java - Navigation Drawer Activity 在 Drawers Item 中设置点击事件

java - Apache Ofbiz 安装问题

Java:从父对象数组访问子类方法

java - Java中如何根据另一个数组的值对一个数组进行排序?

mysql - 如何更改依赖于表中字段的 date_add 间隔类型?

java - Apache ofbiz : include existing service in own component