我正在尝试从这样的简单方法调用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/