如何从 ofbiz 中的简单方法调用 java 方法
How to call java method from a simple method in 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>
当我尝试获取描述字段的值时,它返回相同的描述值,但未更新编码值。
我还需要做什么吗?
您没有使用 return 字符串设置描述值。
<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 方法将 return 编码字符串并将其设置为
return 字段 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 方法
<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>
当我尝试获取描述字段的值时,它返回相同的描述值,但未更新编码值。
我还需要做什么吗?
您没有使用 return 字符串设置描述值。
<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 方法将 return 编码字符串并将其设置为
return 字段 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}"/>