Thanks Chris,
I was aware of the "call" methods, but here is the code that I wrote in
order to get the first x characters of the text body to use as a
description:
<call-object-method method-name="length" obj-field-name="
parameters.textData" ret-field-name="textDataLen"/>
<log level="info" message="textDataLen:${textDataLen}"/>
<property-to-field resource="forum" property="descriptLen"
field-name="descriptLen" />
<log level="info" message="descriptLen:${descriptLen}"/>
<set field="dblTextDataLen" from-field="textDataLen" type="Double"/>
<set field="dblDescriptLen" from-field="descriptLen" type="Double"/>
<call-class-method method-name="min" class-name="java.lang.Math"
ret-field-name="subStringLen">
<field field-name="dblTextDataLen" type="double"/>
<field field-name="dblDescriptLen" type="double"/>
</call-class-method>
<set field="intSubStringLen" from-field="subStringLen"
type="Integer"/>
<log level="info" message="subStringLen:${subStringLen}"/>
<set field="zeroValue" value="0" type="Integer"/>
<call-object-method method-name="substring" obj-field-name="
parameters.textData" ret-field-name="subDescript">
<field field-name="zeroValue" type="int"/>
<field field-name="intSubStringLen" type="int"/>
</call-object-method>
<log level="info" message="subDescript:${subDescript}"/>
As you can see there is a lot of code just to get the variables into the
right type for calling the class and object methods. Does anyone see a
better way to do this?
I agree that it would make sense to put any added functionality in the map
processor, but then you have to create a file ( don't you? ) just to do one
little thing.
Thanks,
-Al
On 6/4/07, Chris Howe <[EMAIL PROTECTED]> wrote:
remember that simple methods have the method <call-class-method> so
that you can call any method that exists in java, just be sure to use
type that is part of the method signature, not a subtype. As far as
adding the function more natively, if necessary, it might be best as
one of the map processor functions.
--- Al Byers <[EMAIL PROTECTED]> wrote:
> I cannot figure out how to safely get a substring value in minilang.
> I don't
> even see an OFBiz utility for doing it. The String method will blow
> up if
> the cutoff value is greater than the length of the string, so it
> seems like
> I need to do a bunch of String and Math functions to get it and I am
> wondering if we need a safe substring method in minilang (and widget
> for
> that matter).
>
> I will be glad to add it if it looks like it is needed.
>
> -Al
>