New Syntax to preserve String for 000 value using FlexibleString expander

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

New Syntax to preserve String for 000 value using FlexibleString expander

Brett
I saw some posts on this earlier but not sure of the exact syntax.  We have
some SimpleMethod that use index keys like "000", "001", etc.  This are
being converted to longs and no longer work in our Maps.  What is the
SimpleMethod syntax to preserve the String value "000" instead of changes to
a long.


Brett
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum
Brett,

Could you provide a code snippet?

-Adrian

Brett Palmer wrote:
> I saw some posts on this earlier but not sure of the exact syntax.  We have
> some SimpleMethod that use index keys like "000", "001", etc.  This are
> being converted to longs and no longer work in our Maps.  What is the
> SimpleMethod syntax to preserve the String value "000" instead of changes to
> a long.
>
>
> Brett
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Brett
Here is an example:

<Set field="passedVal"
from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
/>


Where surveyOptionSeqId is 000 but translates to 0.  Then doesn't
match the key value in the map.

Brett


On 1/20/09, Adrian Crum <[hidden email]> wrote:

> Brett,
>
> Could you provide a code snippet?
>
> -Adrian
>
> Brett Palmer wrote:
>> I saw some posts on this earlier but not sure of the exact syntax.  We
>> have
>> some SimpleMethod that use index keys like "000", "001", etc.  This are
>> being converted to longs and no longer work in our Maps.  What is the
>> SimpleMethod syntax to preserve the String value "000" instead of changes
>> to
>> a long.
>>
>>
>> Brett
>>
>

--
Sent from my mobile device
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum
Try

<Set field="passedVal">
from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>

or

<Set field="passedVal"> from-field="someMap["_" +
surveyResponseOptionAnswer.surveyOptionSeqId]"/>

The idea is to make the key something other than numeric.

If keys like "_000" cause a problem elsewhere in the code, then try

<Set field="passedVal">
from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>

-Adrian


Brett Palmer wrote:

> Here is an example:
>
> <Set field="passedVal"
> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
> />
>
>
> Where surveyOptionSeqId is 000 but translates to 0.  Then doesn't
> match the key value in the map.
>
> Brett
>
>
> On 1/20/09, Adrian Crum <[hidden email]> wrote:
>> Brett,
>>
>> Could you provide a code snippet?
>>
>> -Adrian
>>
>> Brett Palmer wrote:
>>> I saw some posts on this earlier but not sure of the exact syntax.  We
>>> have
>>> some SimpleMethod that use index keys like "000", "001", etc.  This are
>>> being converted to longs and no longer work in our Maps.  What is the
>>> SimpleMethod syntax to preserve the String value "000" instead of changes
>>> to
>>> a long.
>>>
>>>
>>> Brett
>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum
<Set field="passedVal">

should be

<Set field="passedVal"

of course. I missed deleting the > after hitting Reply.


Adrian Crum wrote:

> Try
>
> <Set field="passedVal">
> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>
> or
>
> <Set field="passedVal"> from-field="someMap["_" +
> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>
> The idea is to make the key something other than numeric.
>
> If keys like "_000" cause a problem elsewhere in the code, then try
>
> <Set field="passedVal">
> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>
>
> -Adrian
>
>
> Brett Palmer wrote:
>> Here is an example:
>>
>> <Set field="passedVal"
>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>> />
>>
>>
>> Where surveyOptionSeqId is 000 but translates to 0.  Then doesn't
>> match the key value in the map.
>>
>> Brett
>>
>>
>> On 1/20/09, Adrian Crum <[hidden email]> wrote:
>>> Brett,
>>>
>>> Could you provide a code snippet?
>>>
>>> -Adrian
>>>
>>> Brett Palmer wrote:
>>>> I saw some posts on this earlier but not sure of the exact syntax.  We
>>>> have
>>>> some SimpleMethod that use index keys like "000", "001", etc.  This are
>>>> being converted to longs and no longer work in our Maps.  What is the
>>>> SimpleMethod syntax to preserve the String value "000" instead of
>>>> changes
>>>> to
>>>> a long.
>>>>
>>>>
>>>> Brett
>>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Brett
In reply to this post by Adrian Crum
Adrian,

Thanks for the reply.

Is there a reason we default to converting from a String to a Long?  The
example I gave is reading records from a VARCHAR field in a database.  It
seems like that should be a String be default.  I'm probably not
understanding the benefit for the automatic cast.


Brett

On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum <[hidden email]> wrote:

> Try
>
> <Set field="passedVal">
> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>
> or
>
> <Set field="passedVal"> from-field="someMap["_" +
> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>
> The idea is to make the key something other than numeric.
>
> If keys like "_000" cause a problem elsewhere in the code, then try
>
> <Set field="passedVal">
> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>
> -Adrian
>
>
>
> Brett Palmer wrote:
>
>> Here is an example:
>>
>> <Set field="passedVal"
>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>> />
>>
>>
>> Where surveyOptionSeqId is 000 but translates to 0.  Then doesn't
>> match the key value in the map.
>>
>> Brett
>>
>>
>> On 1/20/09, Adrian Crum <[hidden email]> wrote:
>>
>>> Brett,
>>>
>>> Could you provide a code snippet?
>>>
>>> -Adrian
>>>
>>> Brett Palmer wrote:
>>>
>>>> I saw some posts on this earlier but not sure of the exact syntax.  We
>>>> have
>>>> some SimpleMethod that use index keys like "000", "001", etc.  This are
>>>> being converted to longs and no longer work in our Maps.  What is the
>>>> SimpleMethod syntax to preserve the String value "000" instead of
>>>> changes
>>>> to
>>>> a long.
>>>>
>>>>
>>>> Brett
>>>>
>>>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum-2
Brett,

In the past, the OFBiz scripting languages (screen widgets and minilang) used a home-grown expression parser that only recognized and manipulated strings. We have converted the home-grown expression parser over to the Unified Expression Language so that more powerful expressions can be used. So, you have to look at it from an expression standpoint, not a Map or database or String standpoint.

Identifiers in UEL expressions must follow Java naming conventions. Your example:

<set field="passedVal" from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>

which evaluates to:

<set field="passedVal" from-field="someMap.000"/>

would be similar to:

String passedVal = someObject.000;

in Java. Try creating a class property in Java named "000" - it won't let you.

The benefit of using the UEL is we can create expressions like:

<set field="extendedCost" value="${orderItem.cost * orderItem.quantity}"/>

which is something we couldn't do before.

-Adrian


--- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:

> From: Brett Palmer <[hidden email]>
> Subject: Re: New Syntax to preserve String for 000 value using FlexibleString  expander
> To: [hidden email]
> Date: Tuesday, January 20, 2009, 9:47 PM
> Adrian,
>
> Thanks for the reply.
>
> Is there a reason we default to converting from a String to
> a Long?  The
> example I gave is reading records from a VARCHAR field in a
> database.  It
> seems like that should be a String be default.  I'm
> probably not
> understanding the benefit for the automatic cast.
>
>
> Brett
>
> On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
> <[hidden email]> wrote:
>
> > Try
> >
> > <Set field="passedVal">
> >
> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
> >
> > or
> >
> > <Set field="passedVal">
> from-field="someMap["_" +
> >
> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
> >
> > The idea is to make the key something other than
> numeric.
> >
> > If keys like "_000" cause a problem
> elsewhere in the code, then try
> >
> > <Set field="passedVal">
> >
> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
> >
> > -Adrian
> >
> >
> >
> > Brett Palmer wrote:
> >
> >> Here is an example:
> >>
> >> <Set field="passedVal"
> >>
> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
> >> />
> >>
> >>
> >> Where surveyOptionSeqId is 000 but translates to
> 0.  Then doesn't
> >> match the key value in the map.
> >>
> >> Brett
> >>
> >>
> >> On 1/20/09, Adrian Crum <[hidden email]>
> wrote:
> >>
> >>> Brett,
> >>>
> >>> Could you provide a code snippet?
> >>>
> >>> -Adrian
> >>>
> >>> Brett Palmer wrote:
> >>>
> >>>> I saw some posts on this earlier but not
> sure of the exact syntax.  We
> >>>> have
> >>>> some SimpleMethod that use index keys like
> "000", "001", etc.  This are
> >>>> being converted to longs and no longer
> work in our Maps.  What is the
> >>>> SimpleMethod syntax to preserve the String
> value "000" instead of
> >>>> changes
> >>>> to
> >>>> a long.
> >>>>
> >>>>
> >>>> Brett
> >>>>
> >>>>
> >>


     
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Jacques Le Roux
Administrator
Adiran,

Could we have a page somewhere in the Wiki ? With links to official UEL expressions maybe, and our specificities if any. My
apologies if it aready exists :o)

Jacques

From: "Adrian Crum" <[hidden email]>

> Brett,
>
> In the past, the OFBiz scripting languages (screen widgets and minilang) used a home-grown expression parser that only recognized
> and manipulated strings. We have converted the home-grown expression parser over to the Unified Expression Language so that more
> powerful expressions can be used. So, you have to look at it from an expression standpoint, not a Map or database or String
> standpoint.
>
> Identifiers in UEL expressions must follow Java naming conventions. Your example:
>
> <set field="passedVal" from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>
> which evaluates to:
>
> <set field="passedVal" from-field="someMap.000"/>
>
> would be similar to:
>
> String passedVal = someObject.000;
>
> in Java. Try creating a class property in Java named "000" - it won't let you.
>
> The benefit of using the UEL is we can create expressions like:
>
> <set field="extendedCost" value="${orderItem.cost * orderItem.quantity}"/>
>
> which is something we couldn't do before.
>
> -Adrian
>
>
> --- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:
>
>> From: Brett Palmer <[hidden email]>
>> Subject: Re: New Syntax to preserve String for 000 value using FlexibleString  expander
>> To: [hidden email]
>> Date: Tuesday, January 20, 2009, 9:47 PM
>> Adrian,
>>
>> Thanks for the reply.
>>
>> Is there a reason we default to converting from a String to
>> a Long?  The
>> example I gave is reading records from a VARCHAR field in a
>> database.  It
>> seems like that should be a String be default.  I'm
>> probably not
>> understanding the benefit for the automatic cast.
>>
>>
>> Brett
>>
>> On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
>> <[hidden email]> wrote:
>>
>> > Try
>> >
>> > <Set field="passedVal">
>> >
>> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>> >
>> > or
>> >
>> > <Set field="passedVal">
>> from-field="someMap["_" +
>> >
>> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>> >
>> > The idea is to make the key something other than
>> numeric.
>> >
>> > If keys like "_000" cause a problem
>> elsewhere in the code, then try
>> >
>> > <Set field="passedVal">
>> >
>> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>> >
>> > -Adrian
>> >
>> >
>> >
>> > Brett Palmer wrote:
>> >
>> >> Here is an example:
>> >>
>> >> <Set field="passedVal"
>> >>
>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>> >> />
>> >>
>> >>
>> >> Where surveyOptionSeqId is 000 but translates to
>> 0.  Then doesn't
>> >> match the key value in the map.
>> >>
>> >> Brett
>> >>
>> >>
>> >> On 1/20/09, Adrian Crum <[hidden email]>
>> wrote:
>> >>
>> >>> Brett,
>> >>>
>> >>> Could you provide a code snippet?
>> >>>
>> >>> -Adrian
>> >>>
>> >>> Brett Palmer wrote:
>> >>>
>> >>>> I saw some posts on this earlier but not
>> sure of the exact syntax.  We
>> >>>> have
>> >>>> some SimpleMethod that use index keys like
>> "000", "001", etc.  This are
>> >>>> being converted to longs and no longer
>> work in our Maps.  What is the
>> >>>> SimpleMethod syntax to preserve the String
>> value "000" instead of
>> >>>> changes
>> >>>> to
>> >>>> a long.
>> >>>>
>> >>>>
>> >>>> Brett
>> >>>>
>> >>>>
>> >>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum
Jacques,

I was planning on creating a wiki page for the UEL and the OFBiz
extensions, but it will be a while before I have the time to do it.

If anyone would like to get one started, there was another thread where
I posted a link to a JSR-245 PDF file that has the UEL syntax specification.

OFBiz adds the following extensions to the UEL:

1. ${someList[]} - appends a list element. It is converted internally to
${someList['add']} - so that syntax could be used as well.

2. ${someList[+0]} - inserts a list element at the specified index. It
is converted internally to ${someList['insert@0']} - so that syntax
could be used as well.

3. OFBiz supports variable creation (auto-vivify). In the expression
${someMap.anotherMap.mapElement} if someMap or anotherMap don't exist,
they are created.

4. OFBiz has a number of built-in UEL functions -
http://api.ofbiz.org/org/ofbiz/base/util/string/UelFunctions.html

-Adrian


Jacques Le Roux wrote:

> Adiran,
>
> Could we have a page somewhere in the Wiki ? With links to official UEL
> expressions maybe, and our specificities if any. My apologies if it
> aready exists :o)
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Brett,
>>
>> In the past, the OFBiz scripting languages (screen widgets and
>> minilang) used a home-grown expression parser that only recognized and
>> manipulated strings. We have converted the home-grown expression
>> parser over to the Unified Expression Language so that more powerful
>> expressions can be used. So, you have to look at it from an expression
>> standpoint, not a Map or database or String standpoint.
>>
>> Identifiers in UEL expressions must follow Java naming conventions.
>> Your example:
>>
>> <set field="passedVal"
>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>
>> which evaluates to:
>>
>> <set field="passedVal" from-field="someMap.000"/>
>>
>> would be similar to:
>>
>> String passedVal = someObject.000;
>>
>> in Java. Try creating a class property in Java named "000" - it won't
>> let you.
>>
>> The benefit of using the UEL is we can create expressions like:
>>
>> <set field="extendedCost" value="${orderItem.cost *
>> orderItem.quantity}"/>
>>
>> which is something we couldn't do before.
>>
>> -Adrian
>>
>>
>> --- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:
>>
>>> From: Brett Palmer <[hidden email]>
>>> Subject: Re: New Syntax to preserve String for 000 value using
>>> FlexibleString  expander
>>> To: [hidden email]
>>> Date: Tuesday, January 20, 2009, 9:47 PM
>>> Adrian,
>>>
>>> Thanks for the reply.
>>>
>>> Is there a reason we default to converting from a String to
>>> a Long?  The
>>> example I gave is reading records from a VARCHAR field in a
>>> database.  It
>>> seems like that should be a String be default.  I'm
>>> probably not
>>> understanding the benefit for the automatic cast.
>>>
>>>
>>> Brett
>>>
>>> On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
>>> <[hidden email]> wrote:
>>>
>>> > Try
>>> >
>>> > <Set field="passedVal">
>>> >
>>> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>> >
>>> > or
>>> >
>>> > <Set field="passedVal">
>>> from-field="someMap["_" +
>>> >
>>> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>>> >
>>> > The idea is to make the key something other than
>>> numeric.
>>> >
>>> > If keys like "_000" cause a problem
>>> elsewhere in the code, then try
>>> >
>>> > <Set field="passedVal">
>>> >
>>> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>>>
>>> >
>>> > -Adrian
>>> >
>>> >
>>> >
>>> > Brett Palmer wrote:
>>> >
>>> >> Here is an example:
>>> >>
>>> >> <Set field="passedVal"
>>> >>
>>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>>> >> />
>>> >>
>>> >>
>>> >> Where surveyOptionSeqId is 000 but translates to
>>> 0.  Then doesn't
>>> >> match the key value in the map.
>>> >>
>>> >> Brett
>>> >>
>>> >>
>>> >> On 1/20/09, Adrian Crum <[hidden email]>
>>> wrote:
>>> >>
>>> >>> Brett,
>>> >>>
>>> >>> Could you provide a code snippet?
>>> >>>
>>> >>> -Adrian
>>> >>>
>>> >>> Brett Palmer wrote:
>>> >>>
>>> >>>> I saw some posts on this earlier but not
>>> sure of the exact syntax.  We
>>> >>>> have
>>> >>>> some SimpleMethod that use index keys like
>>> "000", "001", etc.  This are
>>> >>>> being converted to longs and no longer
>>> work in our Maps.  What is the
>>> >>>> SimpleMethod syntax to preserve the String
>>> value "000" instead of
>>> >>>> changes
>>> >>>> to
>>> >>>> a long.
>>> >>>>
>>> >>>>
>>> >>>> Brett
>>> >>>>
>>> >>>>
>>> >>
>>
>>
>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Jacques Le Roux
Administrator
Thanks Adrian,

I will try, I have some time ahead...

Jacques

From: "Adrian Crum" <[hidden email]>

> Jacques,
>
> I was planning on creating a wiki page for the UEL and the OFBiz
> extensions, but it will be a while before I have the time to do it.
>
> If anyone would like to get one started, there was another thread where
> I posted a link to a JSR-245 PDF file that has the UEL syntax specification.
>
> OFBiz adds the following extensions to the UEL:
>
> 1. ${someList[]} - appends a list element. It is converted internally to
> ${someList['add']} - so that syntax could be used as well.
>
> 2. ${someList[+0]} - inserts a list element at the specified index. It
> is converted internally to ${someList['insert@0']} - so that syntax
> could be used as well.
>
> 3. OFBiz supports variable creation (auto-vivify). In the expression
> ${someMap.anotherMap.mapElement} if someMap or anotherMap don't exist,
> they are created.
>
> 4. OFBiz has a number of built-in UEL functions -
> http://api.ofbiz.org/org/ofbiz/base/util/string/UelFunctions.html
>
> -Adrian
>
>
> Jacques Le Roux wrote:
>> Adiran,
>>
>> Could we have a page somewhere in the Wiki ? With links to official UEL
>> expressions maybe, and our specificities if any. My apologies if it
>> aready exists :o)
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Brett,
>>>
>>> In the past, the OFBiz scripting languages (screen widgets and
>>> minilang) used a home-grown expression parser that only recognized and
>>> manipulated strings. We have converted the home-grown expression
>>> parser over to the Unified Expression Language so that more powerful
>>> expressions can be used. So, you have to look at it from an expression
>>> standpoint, not a Map or database or String standpoint.
>>>
>>> Identifiers in UEL expressions must follow Java naming conventions.
>>> Your example:
>>>
>>> <set field="passedVal"
>>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>>
>>> which evaluates to:
>>>
>>> <set field="passedVal" from-field="someMap.000"/>
>>>
>>> would be similar to:
>>>
>>> String passedVal = someObject.000;
>>>
>>> in Java. Try creating a class property in Java named "000" - it won't
>>> let you.
>>>
>>> The benefit of using the UEL is we can create expressions like:
>>>
>>> <set field="extendedCost" value="${orderItem.cost *
>>> orderItem.quantity}"/>
>>>
>>> which is something we couldn't do before.
>>>
>>> -Adrian
>>>
>>>
>>> --- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:
>>>
>>>> From: Brett Palmer <[hidden email]>
>>>> Subject: Re: New Syntax to preserve String for 000 value using
>>>> FlexibleString  expander
>>>> To: [hidden email]
>>>> Date: Tuesday, January 20, 2009, 9:47 PM
>>>> Adrian,
>>>>
>>>> Thanks for the reply.
>>>>
>>>> Is there a reason we default to converting from a String to
>>>> a Long?  The
>>>> example I gave is reading records from a VARCHAR field in a
>>>> database.  It
>>>> seems like that should be a String be default.  I'm
>>>> probably not
>>>> understanding the benefit for the automatic cast.
>>>>
>>>>
>>>> Brett
>>>>
>>>> On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
>>>> <[hidden email]> wrote:
>>>>
>>>> > Try
>>>> >
>>>> > <Set field="passedVal">
>>>> >
>>>> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>>> >
>>>> > or
>>>> >
>>>> > <Set field="passedVal">
>>>> from-field="someMap["_" +
>>>> >
>>>> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>>>> >
>>>> > The idea is to make the key something other than
>>>> numeric.
>>>> >
>>>> > If keys like "_000" cause a problem
>>>> elsewhere in the code, then try
>>>> >
>>>> > <Set field="passedVal">
>>>> >
>>>> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>>>>
>>>> >
>>>> > -Adrian
>>>> >
>>>> >
>>>> >
>>>> > Brett Palmer wrote:
>>>> >
>>>> >> Here is an example:
>>>> >>
>>>> >> <Set field="passedVal"
>>>> >>
>>>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>>>> >> />
>>>> >>
>>>> >>
>>>> >> Where surveyOptionSeqId is 000 but translates to
>>>> 0.  Then doesn't
>>>> >> match the key value in the map.
>>>> >>
>>>> >> Brett
>>>> >>
>>>> >>
>>>> >> On 1/20/09, Adrian Crum <[hidden email]>
>>>> wrote:
>>>> >>
>>>> >>> Brett,
>>>> >>>
>>>> >>> Could you provide a code snippet?
>>>> >>>
>>>> >>> -Adrian
>>>> >>>
>>>> >>> Brett Palmer wrote:
>>>> >>>
>>>> >>>> I saw some posts on this earlier but not
>>>> sure of the exact syntax.  We
>>>> >>>> have
>>>> >>>> some SimpleMethod that use index keys like
>>>> "000", "001", etc.  This are
>>>> >>>> being converted to longs and no longer
>>>> work in our Maps.  What is the
>>>> >>>> SimpleMethod syntax to preserve the String
>>>> value "000" instead of
>>>> >>>> changes
>>>> >>>> to
>>>> >>>> a long.
>>>> >>>>
>>>> >>>>
>>>> >>>> Brett
>>>> >>>>
>>>> >>>>
>>>> >>
>>>
>>>
>>>
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Brett
In reply to this post by Adrian Crum-2
Adrian,

Thanks for the explanation.  I'll do some more reading on the unified
expression language to get caught up.


Brett

On Wed, Jan 21, 2009 at 7:21 AM, Adrian Crum <[hidden email]> wrote:

> Brett,
>
> In the past, the OFBiz scripting languages (screen widgets and minilang)
> used a home-grown expression parser that only recognized and manipulated
> strings. We have converted the home-grown expression parser over to the
> Unified Expression Language so that more powerful expressions can be used.
> So, you have to look at it from an expression standpoint, not a Map or
> database or String standpoint.
>
> Identifiers in UEL expressions must follow Java naming conventions. Your
> example:
>
> <set field="passedVal"
> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>
> which evaluates to:
>
> <set field="passedVal" from-field="someMap.000"/>
>
> would be similar to:
>
> String passedVal = someObject.000;
>
> in Java. Try creating a class property in Java named "000" - it won't let
> you.
>
> The benefit of using the UEL is we can create expressions like:
>
> <set field="extendedCost" value="${orderItem.cost * orderItem.quantity}"/>
>
> which is something we couldn't do before.
>
> -Adrian
>
>
> --- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:
>
> > From: Brett Palmer <[hidden email]>
> > Subject: Re: New Syntax to preserve String for 000 value using
> FlexibleString  expander
> > To: [hidden email]
> > Date: Tuesday, January 20, 2009, 9:47 PM
> > Adrian,
> >
> > Thanks for the reply.
> >
> > Is there a reason we default to converting from a String to
> > a Long?  The
> > example I gave is reading records from a VARCHAR field in a
> > database.  It
> > seems like that should be a String be default.  I'm
> > probably not
> > understanding the benefit for the automatic cast.
> >
> >
> > Brett
> >
> > On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
> > <[hidden email]> wrote:
> >
> > > Try
> > >
> > > <Set field="passedVal">
> > >
> > from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
> > >
> > > or
> > >
> > > <Set field="passedVal">
> > from-field="someMap["_" +
> > >
> > surveyResponseOptionAnswer.surveyOptionSeqId]"/>
> > >
> > > The idea is to make the key something other than
> > numeric.
> > >
> > > If keys like "_000" cause a problem
> > elsewhere in the code, then try
> > >
> > > <Set field="passedVal">
> > >
> >
> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
> > >
> > > -Adrian
> > >
> > >
> > >
> > > Brett Palmer wrote:
> > >
> > >> Here is an example:
> > >>
> > >> <Set field="passedVal"
> > >>
> > from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
> > >> />
> > >>
> > >>
> > >> Where surveyOptionSeqId is 000 but translates to
> > 0.  Then doesn't
> > >> match the key value in the map.
> > >>
> > >> Brett
> > >>
> > >>
> > >> On 1/20/09, Adrian Crum <[hidden email]>
> > wrote:
> > >>
> > >>> Brett,
> > >>>
> > >>> Could you provide a code snippet?
> > >>>
> > >>> -Adrian
> > >>>
> > >>> Brett Palmer wrote:
> > >>>
> > >>>> I saw some posts on this earlier but not
> > sure of the exact syntax.  We
> > >>>> have
> > >>>> some SimpleMethod that use index keys like
> > "000", "001", etc.  This are
> > >>>> being converted to longs and no longer
> > work in our Maps.  What is the
> > >>>> SimpleMethod syntax to preserve the String
> > value "000" instead of
> > >>>> changes
> > >>>> to
> > >>>> a long.
> > >>>>
> > >>>>
> > >>>> Brett
> > >>>>
> > >>>>
> > >>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
Done in http://docs.ofbiz.org/x/Hhk
Please let me know if it needs more information

Thanks

Jacques

From: "Jacques Le Roux" <[hidden email]>

> Thanks Adrian,
>
> I will try, I have some time ahead...
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Jacques,
>>
>> I was planning on creating a wiki page for the UEL and the OFBiz
>> extensions, but it will be a while before I have the time to do it.
>>
>> If anyone would like to get one started, there was another thread where
>> I posted a link to a JSR-245 PDF file that has the UEL syntax specification.
>>
>> OFBiz adds the following extensions to the UEL:
>>
>> 1. ${someList[]} - appends a list element. It is converted internally to
>> ${someList['add']} - so that syntax could be used as well.
>>
>> 2. ${someList[+0]} - inserts a list element at the specified index. It
>> is converted internally to ${someList['insert@0']} - so that syntax
>> could be used as well.
>>
>> 3. OFBiz supports variable creation (auto-vivify). In the expression
>> ${someMap.anotherMap.mapElement} if someMap or anotherMap don't exist,
>> they are created.
>>
>> 4. OFBiz has a number of built-in UEL functions -
>> http://api.ofbiz.org/org/ofbiz/base/util/string/UelFunctions.html
>>
>> -Adrian
>>
>>
>> Jacques Le Roux wrote:
>>> Adiran,
>>>
>>> Could we have a page somewhere in the Wiki ? With links to official UEL
>>> expressions maybe, and our specificities if any. My apologies if it
>>> aready exists :o)
>>>
>>> Jacques
>>>
>>> From: "Adrian Crum" <[hidden email]>
>>>> Brett,
>>>>
>>>> In the past, the OFBiz scripting languages (screen widgets and
>>>> minilang) used a home-grown expression parser that only recognized and
>>>> manipulated strings. We have converted the home-grown expression
>>>> parser over to the Unified Expression Language so that more powerful
>>>> expressions can be used. So, you have to look at it from an expression
>>>> standpoint, not a Map or database or String standpoint.
>>>>
>>>> Identifiers in UEL expressions must follow Java naming conventions.
>>>> Your example:
>>>>
>>>> <set field="passedVal"
>>>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>>>
>>>> which evaluates to:
>>>>
>>>> <set field="passedVal" from-field="someMap.000"/>
>>>>
>>>> would be similar to:
>>>>
>>>> String passedVal = someObject.000;
>>>>
>>>> in Java. Try creating a class property in Java named "000" - it won't
>>>> let you.
>>>>
>>>> The benefit of using the UEL is we can create expressions like:
>>>>
>>>> <set field="extendedCost" value="${orderItem.cost *
>>>> orderItem.quantity}"/>
>>>>
>>>> which is something we couldn't do before.
>>>>
>>>> -Adrian
>>>>
>>>>
>>>> --- On Tue, 1/20/09, Brett Palmer <[hidden email]> wrote:
>>>>
>>>>> From: Brett Palmer <[hidden email]>
>>>>> Subject: Re: New Syntax to preserve String for 000 value using
>>>>> FlexibleString  expander
>>>>> To: [hidden email]
>>>>> Date: Tuesday, January 20, 2009, 9:47 PM
>>>>> Adrian,
>>>>>
>>>>> Thanks for the reply.
>>>>>
>>>>> Is there a reason we default to converting from a String to
>>>>> a Long?  The
>>>>> example I gave is reading records from a VARCHAR field in a
>>>>> database.  It
>>>>> seems like that should be a String be default.  I'm
>>>>> probably not
>>>>> understanding the benefit for the automatic cast.
>>>>>
>>>>>
>>>>> Brett
>>>>>
>>>>> On Tue, Jan 20, 2009 at 12:06 PM, Adrian Crum
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> > Try
>>>>> >
>>>>> > <Set field="passedVal">
>>>>> >
>>>>> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
>>>>> >
>>>>> > or
>>>>> >
>>>>> > <Set field="passedVal">
>>>>> from-field="someMap["_" +
>>>>> >
>>>>> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
>>>>> >
>>>>> > The idea is to make the key something other than
>>>>> numeric.
>>>>> >
>>>>> > If keys like "_000" cause a problem
>>>>> elsewhere in the code, then try
>>>>> >
>>>>> > <Set field="passedVal">
>>>>> >
>>>>> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>>>>>
>>>>> >
>>>>> > -Adrian
>>>>> >
>>>>> >
>>>>> >
>>>>> > Brett Palmer wrote:
>>>>> >
>>>>> >> Here is an example:
>>>>> >>
>>>>> >> <Set field="passedVal"
>>>>> >>
>>>>> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
>>>>> >> />
>>>>> >>
>>>>> >>
>>>>> >> Where surveyOptionSeqId is 000 but translates to
>>>>> 0.  Then doesn't
>>>>> >> match the key value in the map.
>>>>> >>
>>>>> >> Brett
>>>>> >>
>>>>> >>
>>>>> >> On 1/20/09, Adrian Crum <[hidden email]>
>>>>> wrote:
>>>>> >>
>>>>> >>> Brett,
>>>>> >>>
>>>>> >>> Could you provide a code snippet?
>>>>> >>>
>>>>> >>> -Adrian
>>>>> >>>
>>>>> >>> Brett Palmer wrote:
>>>>> >>>
>>>>> >>>> I saw some posts on this earlier but not
>>>>> sure of the exact syntax.  We
>>>>> >>>> have
>>>>> >>>> some SimpleMethod that use index keys like
>>>>> "000", "001", etc.  This are
>>>>> >>>> being converted to longs and no longer
>>>>> work in our Maps.  What is the
>>>>> >>>> SimpleMethod syntax to preserve the String
>>>>> value "000" instead of
>>>>> >>>> changes
>>>>> >>>> to
>>>>> >>>> a long.
>>>>> >>>>
>>>>> >>>>
>>>>> >>>> Brett
>>>>> >>>>
>>>>> >>>>
>>>>> >>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: New Syntax to preserve String for 000 value using FlexibleString expander

Adrian Crum-2
Thanks Jacques!


--- On Sat, 1/24/09, Jacques Le Roux <[hidden email]> wrote:

> From: Jacques Le Roux <[hidden email]>
> Subject: Re: New Syntax to preserve String for 000 value using FlexibleString  expander
> To: [hidden email], "Jacques Le Roux" <[hidden email]>
> Date: Saturday, January 24, 2009, 12:06 AM
> Done in http://docs.ofbiz.org/x/Hhk
> Please let me know if it needs more information
>
> Thanks
>
> Jacques
>
> From: "Jacques Le Roux"
> <[hidden email]>
> > Thanks Adrian,
> >
> > I will try, I have some time ahead...
> >
> > Jacques
> >
> > From: "Adrian Crum"
> <[hidden email]>
> >> Jacques,
> >>
> >> I was planning on creating a wiki page for the UEL
> and the OFBiz extensions, but it will be a while before I
> have the time to do it.
> >>
> >> If anyone would like to get one started, there was
> another thread where I posted a link to a JSR-245 PDF file
> that has the UEL syntax specification.
> >>
> >> OFBiz adds the following extensions to the UEL:
> >>
> >> 1. ${someList[]} - appends a list element. It is
> converted internally to ${someList['add']} - so that
> syntax could be used as well.
> >>
> >> 2. ${someList[+0]} - inserts a list element at the
> specified index. It is converted internally to
> ${someList['insert@0']} - so that syntax could be
> used as well.
> >>
> >> 3. OFBiz supports variable creation (auto-vivify).
> In the expression ${someMap.anotherMap.mapElement} if
> someMap or anotherMap don't exist, they are created.
> >>
> >> 4. OFBiz has a number of built-in UEL functions -
> http://api.ofbiz.org/org/ofbiz/base/util/string/UelFunctions.html
> >>
> >> -Adrian
> >>
> >>
> >> Jacques Le Roux wrote:
> >>> Adiran,
> >>>
> >>> Could we have a page somewhere in the Wiki ?
> With links to official UEL expressions maybe, and our
> specificities if any. My apologies if it aready exists :o)
> >>>
> >>> Jacques
> >>>
> >>> From: "Adrian Crum"
> <[hidden email]>
> >>>> Brett,
> >>>>
> >>>> In the past, the OFBiz scripting languages
> (screen widgets and minilang) used a home-grown expression
> parser that only recognized and manipulated strings. We have
> converted the home-grown expression parser over to the
> Unified Expression Language so that more powerful
> expressions can be used. So, you have to look at it from an
> expression standpoint, not a Map or database or String
> standpoint.
> >>>>
> >>>> Identifiers in UEL expressions must follow
> Java naming conventions. Your example:
> >>>>
> >>>> <set field="passedVal"
> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
> >>>>
> >>>> which evaluates to:
> >>>>
> >>>> <set field="passedVal"
> from-field="someMap.000"/>
> >>>>
> >>>> would be similar to:
> >>>>
> >>>> String passedVal = someObject.000;
> >>>>
> >>>> in Java. Try creating a class property in
> Java named "000" - it won't let you.
> >>>>
> >>>> The benefit of using the UEL is we can
> create expressions like:
> >>>>
> >>>> <set field="extendedCost"
> value="${orderItem.cost *
> orderItem.quantity}"/>
> >>>>
> >>>> which is something we couldn't do
> before.
> >>>>
> >>>> -Adrian
> >>>>
> >>>>
> >>>> --- On Tue, 1/20/09, Brett Palmer
> <[hidden email]> wrote:
> >>>>
> >>>>> From: Brett Palmer
> <[hidden email]>
> >>>>> Subject: Re: New Syntax to preserve
> String for 000 value using FlexibleString  expander
> >>>>> To: [hidden email]
> >>>>> Date: Tuesday, January 20, 2009, 9:47
> PM
> >>>>> Adrian,
> >>>>>
> >>>>> Thanks for the reply.
> >>>>>
> >>>>> Is there a reason we default to
> converting from a String to
> >>>>> a Long?  The
> >>>>> example I gave is reading records from
> a VARCHAR field in a
> >>>>> database.  It
> >>>>> seems like that should be a String be
> default.  I'm
> >>>>> probably not
> >>>>> understanding the benefit for the
> automatic cast.
> >>>>>
> >>>>>
> >>>>> Brett
> >>>>>
> >>>>> On Tue, Jan 20, 2009 at 12:06 PM,
> Adrian Crum
> >>>>> <[hidden email]> wrote:
> >>>>>
> >>>>> > Try
> >>>>> >
> >>>>> > <Set
> field="passedVal">
> >>>>> >
> >>>>>
> from-field="someMap._${surveyResponseOptionAnswer.surveyOptionSeqId}"/>
> >>>>> >
> >>>>> > or
> >>>>> >
> >>>>> > <Set
> field="passedVal">
> >>>>> from-field="someMap["_"
> +
> >>>>> >
> >>>>>
> surveyResponseOptionAnswer.surveyOptionSeqId]"/>
> >>>>> >
> >>>>> > The idea is to make the key
> something other than
> >>>>> numeric.
> >>>>> >
> >>>>> > If keys like "_000"
> cause a problem
> >>>>> elsewhere in the code, then try
> >>>>> >
> >>>>> > <Set
> field="passedVal">
> >>>>> >
> >>>>>
> from-field="someMap[str:toString(surveyResponseOptionAnswer.surveyOptionSeqId)]"/>
>
> >>>>> >
> >>>>> > -Adrian
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> > Brett Palmer wrote:
> >>>>> >
> >>>>> >> Here is an example:
> >>>>> >>
> >>>>> >> <Set
> field="passedVal"
> >>>>> >>
> >>>>>
> from-field="someMap.${surveyResponseOptionAnswer.surveyOptionSeqId}"
> >>>>> >> />
> >>>>> >>
> >>>>> >>
> >>>>> >> Where surveyOptionSeqId is
> 000 but translates to
> >>>>> 0.  Then doesn't
> >>>>> >> match the key value in the
> map.
> >>>>> >>
> >>>>> >> Brett
> >>>>> >>
> >>>>> >>
> >>>>> >> On 1/20/09, Adrian Crum
> <[hidden email]>
> >>>>> wrote:
> >>>>> >>
> >>>>> >>> Brett,
> >>>>> >>>
> >>>>> >>> Could you provide a code
> snippet?
> >>>>> >>>
> >>>>> >>> -Adrian
> >>>>> >>>
> >>>>> >>> Brett Palmer wrote:
> >>>>> >>>
> >>>>> >>>> I saw some posts on
> this earlier but not
> >>>>> sure of the exact syntax.  We
> >>>>> >>>> have
> >>>>> >>>> some SimpleMethod
> that use index keys like
> >>>>> "000", "001", etc.
>  This are
> >>>>> >>>> being converted to
> longs and no longer
> >>>>> work in our Maps.  What is the
> >>>>> >>>> SimpleMethod syntax
> to preserve the String
> >>>>> value "000" instead of
> >>>>> >>>> changes
> >>>>> >>>> to
> >>>>> >>>> a long.
> >>>>> >>>>
> >>>>> >>>>
> >>>>> >>>> Brett
> >>>>> >>>>
> >>>>> >>>>
> >>>>> >>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >