That is a good idea. Thanks. -Al On 6/4/07, Chris Howe <[EMAIL PROTECTED]> wrote:
I wouldn't bother with the service engine, but instead add a method to base.util.StringUtil That seems to be a safe tool that would be beneficial in other places.. --- Al Byers <[EMAIL PROTECTED]> wrote: > I just want to get the first <x> characters in a text string (which > may be > shorter than <x>). Ideally, I want to break at a whitespace - more > reason > for writing a special function. > > I suppose I can just write a service to do it. I was trying to > determine if > this (and maybe other string processing) should be added to the > minilang and > widget functionality. > > -Al > > On 6/4/07, Chris Howe <[EMAIL PROTECTED]> wrote: > > > > I'm having trouble quickly reading how you're hacking it to work > versus > > what you're trying to do... > > > > What are you trying to perform if this were java? > > > > --- Al Byers <[EMAIL PROTECTED]> wrote: > > > > > 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 > > > > > > > > > > > > > > > > > > > > >