Discussion: Unified Expression Language Functions

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

Discussion: Unified Expression Language Functions

Adrian Crum
Now that we have the Unified Expression Language implemented in
FlexibleStringExpander, we gain the ability to use UEL functions.

On the plus side, UEL functions can make screen widget and mini-language
code more flexible and more powerful. On the minus side, you have to
know the functions and what they do (in other words, no auto-completion
when working in XML).

As an example, I frequently need to know the size of a List, Map, or
String. With current code, I have to use the bsh: prefix and a short script:

<set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.

Using a UEL function:

<set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>

or to get the length of a String:

<set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
type="Integer"/>.

I don't know if this would be of any use, or if it is desirable. I'm
just tossing the idea out there for discussion.

-Adrian
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
Hi Adrian,

Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
changing(/adding) type from "Double" to "BigDecimal" as David suggested recently

Thanks

Jacques

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

> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL functions.
>
> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus side,
> you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>
> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix and
> a short script:
>
> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>
> Using a UEL function:
>
> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>
> or to get the length of a String:
>
> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>
> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>
> -Adrian
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum
Also could {util: syntax deal with stuff like "{bsh:org.ofbiz.*"  (ie replace bsh by util there) ?
This would allow to replace most of bsh uses in xml files

Thanks

Jacques

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

> Hi Adrian,
>
> Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
> changing(/adding) type from "Double" to "BigDecimal" as David suggested recently
>
> Thanks
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL functions.
>>
>> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus side,
>> you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>>
>> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix and
>> a short script:
>>
>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>
>> Using a UEL function:
>>
>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>
>> or to get the length of a String:
>>
>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>
>> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>>
>> -Adrian
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum
From: "Jacques Le Roux" <[hidden email]>
> Also could {util: syntax deal with stuff like "{bsh:org.ofbiz.*"  (ie replace bsh by util there) ?

Mmm, thinking more about (and after a quick look at UelUtil.java and UelFunctions.java) I guess it makes no sense to invoke "util:"
in these cases.
But would a simple syntax (without "util:" ie simply removing "bsh:") not possible (I guess it's not possible right now, but could
it be ?)
I believe we can't nor yet replace "bsh:" "by "grovvy:", I'm wrong ?

The idea behing all theses questions is to slowly get rid of BeanShell everywhere (since not maintained anymore)

Thanks

Jacques

> This would allow to replace most of bsh uses in xml files
>
> Thanks
>
> Jacques
>
> From: "Jacques Le Roux" <[hidden email]>
>> Hi Adrian,
>>
>> Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
>> changing(/adding) type from "Double" to "BigDecimal" as David suggested recently
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL
>>> functions.
>>>
>>> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus
>>> side, you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>>>
>>> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix
>>> and a short script:
>>>
>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>
>>> Using a UEL function:
>>>
>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>
>>> or to get the length of a String:
>>>
>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>>
>>> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>>>
>>> -Adrian
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
OK, I'm reading http://java.sun.com/products/jsp/reference/techart/unifiedEL.html
It will be more clear, thank askikng stupid questions :o)

Jacques

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

> From: "Jacques Le Roux" <[hidden email]>
>> Also could {util: syntax deal with stuff like "{bsh:org.ofbiz.*"  (ie replace bsh by util there) ?
>
> Mmm, thinking more about (and after a quick look at UelUtil.java and UelFunctions.java) I guess it makes no sense to invoke
> "util:" in these cases.
> But would a simple syntax (without "util:" ie simply removing "bsh:") not possible (I guess it's not possible right now, but could
> it be ?)
> I believe we can't nor yet replace "bsh:" "by "grovvy:", I'm wrong ?
>
> The idea behing all theses questions is to slowly get rid of BeanShell everywhere (since not maintained anymore)
>
> Thanks
>
> Jacques
>
>> This would allow to replace most of bsh uses in xml files
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Jacques Le Roux" <[hidden email]>
>>> Hi Adrian,
>>>
>>> Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
>>> changing(/adding) type from "Double" to "BigDecimal" as David suggested recently
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Adrian Crum" <[hidden email]>
>>>> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL
>>>> functions.
>>>>
>>>> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus
>>>> side, you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>>>>
>>>> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix
>>>> and a short script:
>>>>
>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>>
>>>> Using a UEL function:
>>>>
>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>
>>>> or to get the length of a String:
>>>>
>>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>>>
>>>> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>>>>
>>>> -Adrian
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum
I was considering something like bsh:run("...") but I'm still busy with
getting some of the bugs worked out of the UEL integration.

-Adrian

Jacques Le Roux wrote:

> OK, I'm reading
> http://java.sun.com/products/jsp/reference/techart/unifiedEL.html
> It will be more clear, thank askikng stupid questions :o)
>
> Jacques
>
> From: "Jacques Le Roux" <[hidden email]>
>> From: "Jacques Le Roux" <[hidden email]>
>>> Also could {util: syntax deal with stuff like "{bsh:org.ofbiz.*"  (ie
>>> replace bsh by util there) ?
>>
>> Mmm, thinking more about (and after a quick look at UelUtil.java and
>> UelFunctions.java) I guess it makes no sense to invoke
>> "util:" in these cases.
>> But would a simple syntax (without "util:" ie simply removing "bsh:")
>> not possible (I guess it's not possible right now, but could
>> it be ?)
>> I believe we can't nor yet replace "bsh:" "by "grovvy:", I'm wrong ?
>>
>> The idea behing all theses questions is to slowly get rid of BeanShell
>> everywhere (since not maintained anymore)
>>
>> Thanks
>>
>> Jacques
>>
>>> This would allow to replace most of bsh uses in xml files
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Jacques Le Roux" <[hidden email]>
>>>> Hi Adrian,
>>>>
>>>> Is {util: syntax also dealing with ternary operator (did not look
>>>> into details, doing some {bsh: to {util: changes while
>>>> changing(/adding) type from "Double" to "BigDecimal" as David
>>>> suggested recently
>>>>
>>>> Thanks
>>>>
>>>> Jacques
>>>>
>>>> From: "Adrian Crum" <[hidden email]>
>>>>> Now that we have the Unified Expression Language implemented in
>>>>> FlexibleStringExpander, we gain the ability to use UEL
>>>>> functions.
>>>>>
>>>>> On the plus side, UEL functions can make screen widget and
>>>>> mini-language code more flexible and more powerful. On the minus
>>>>> side, you have to know the functions and what they do (in other
>>>>> words, no auto-completion when working in XML).
>>>>>
>>>>> As an example, I frequently need to know the size of a List, Map,
>>>>> or String. With current code, I have to use the bsh: prefix
>>>>> and a short script:
>>>>>
>>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}"
>>>>> type="Integer"/>.
>>>>>
>>>>> Using a UEL function:
>>>>>
>>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>>
>>>>> or to get the length of a String:
>>>>>
>>>>> <set field="stringSize"
>>>>> value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>>>>
>>>>> I don't know if this would be of any use, or if it is desirable.
>>>>> I'm just tossing the idea out there for discussion.
>>>>>
>>>>> -Adrian
>>>>>
>>>>
>>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum
In reply to this post by Jacques Le Roux
Jacques,

UEL supports ternary operations. So,

<set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal
+ absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>

becomes

<set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
absolutePostedBalance) : debitTotal}" type="BigDecimal"/>

Also, the reason for the UEL function name prefix (math: str: util:) is
the same reason we have Java package names and XML namespaces - to avoid
function name clash.

-Adrian


Jacques Le Roux wrote:

> Hi Adrian,
>
> Is {util: syntax also dealing with ternary operator (did not look into
> details, doing some {bsh: to {util: changes while changing(/adding) type
> from "Double" to "BigDecimal" as David suggested recently
>
> Thanks
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Now that we have the Unified Expression Language implemented in
>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>
>> On the plus side, UEL functions can make screen widget and
>> mini-language code more flexible and more powerful. On the minus side,
>> you have to know the functions and what they do (in other words, no
>> auto-completion when working in XML).
>>
>> As an example, I frequently need to know the size of a List, Map, or
>> String. With current code, I have to use the bsh: prefix and a short
>> script:
>>
>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>
>> Using a UEL function:
>>
>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>
>> or to get the length of a String:
>>
>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>> type="Integer"/>.
>>
>> I don't know if this would be of any use, or if it is desirable. I'm
>> just tossing the idea out there for discussion.
>>
>> -Adrian
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
Thanks for clarification Adrian,

I must admit the information in http://java.sun.com/products/jsp/reference/techart/unifiedEL.html are not quite clear :/
I think I got most it though, is there a better reference ?

I did a bunch of change. I guess now that most of them were correct, but as I had a doubt I reverted them all but the one I was
sure. Anyway I will re-do some

Jacques

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

> Jacques,
>
> UEL supports ternary operations. So,
>
> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal
> + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>
> becomes
>
> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>
> Also, the reason for the UEL function name prefix (math: str: util:) is
> the same reason we have Java package names and XML namespaces - to avoid
> function name clash.
>
> -Adrian
>
>
> Jacques Le Roux wrote:
>> Hi Adrian,
>>
>> Is {util: syntax also dealing with ternary operator (did not look into
>> details, doing some {bsh: to {util: changes while changing(/adding) type
>> from "Double" to "BigDecimal" as David suggested recently
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Now that we have the Unified Expression Language implemented in
>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>
>>> On the plus side, UEL functions can make screen widget and
>>> mini-language code more flexible and more powerful. On the minus side,
>>> you have to know the functions and what they do (in other words, no
>>> auto-completion when working in XML).
>>>
>>> As an example, I frequently need to know the size of a List, Map, or
>>> String. With current code, I have to use the bsh: prefix and a short
>>> script:
>>>
>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>
>>> Using a UEL function:
>>>
>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>
>>> or to get the length of a String:
>>>
>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>>> type="Integer"/>.
>>>
>>> I don't know if this would be of any use, or if it is desirable. I'm
>>> just tossing the idea out there for discussion.
>>>
>>> -Adrian
>>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum
So the sequel should be ok, please confirm (I will try to post the patch as attachment in another email - for readability - but I'm
afraid it will not get through)

Index: applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
===================================================================
--- applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (revision 727828)
+++ applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (working copy)
@@ -448,7 +448,7 @@
             <else>
                 <!-- if new status is paid check if the complete invoice is applied. -->
                 <if-compare field="parameters.statusId" operator="equals" value="INVOICE_PAID">
-                    <set field="notApplied" type="BigDecimal"
value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
+                    <set field="notApplied" type="BigDecimal"
value="${org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
                     <if-compare field="notApplied" operator="not-equals" value="0.00" type="BigDecimal">
                         <add-error><fail-message message="Cannot change status to 'paid', invoice ${invoice.invoiceId} has an
unapplied balance of [${notApplied}]"/></add-error>
                         <check-errors/>
Index: applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
===================================================================
--- applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (revision 727747)
+++ applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (working copy)
@@ -226,7 +226,7 @@
         <!-- check the scheduled posting date, but only if it's set -->
         <if-not-empty field="acctgTrans.scheduledPostingDate">
             <set field="scheduledPostingDate" from-field="acctgTrans.scheduledPostingDate"/>
-            <set field="beforeScheduled" value="${bsh:
org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/>
+            <set field="beforeScheduled" value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/>
             <if-compare field="beforeScheduled" operator="equals" value="true" type="Boolean">
                 <add-error><fail-message message="Not posting GL Accounting Transaction with ID [${parameters.acctgTransId}]
because it's not scheduled to be posted yet.  The scheduled posting date is [${acctgTrans.scheduledPostingDate}]"/></add-error>
             </if-compare>
@@ -335,7 +335,7 @@
                 <get-related-one relation-name="GlAccountClass" value-name="glAccount" to-value-name="glAccountClass"/>
                 <get-related-one relation-name="ParentGlAccountClass" value-name="glAccountClass"
to-value-name="parentGlAccountClass"/>
                 <!-- test if the account is a DEBIT account -->
-                <set field="isDebit" value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/>
+                <set field="isDebit" value="${org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/>
                 <if-compare field="isDebit" operator="equals" value="true">
                         <if-compare field="acctgTransEntry.debitCreditFlag" operator="equals" value="D">
                             <set from-field="acctgTransEntry.amount" field="postingAmount"/>
@@ -349,7 +349,7 @@
                         </if-compare>
                     <else>
                         <!-- otherwise, test if the account is credit -->
-                        <set field="isCredit" value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/>
+                        <set field="isCredit" value="${org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/>
                         <if-compare field="isCredit" operator="equals" value="true">
                             <if-compare field="acctgTransEntry.debitCreditFlag" operator="equals" value="C">
                                 <set from-field="acctgTransEntry.amount" field="postingAmount"/>
Index: applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
===================================================================
--- applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (revision 727747)
+++ applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (working copy)
@@ -186,7 +186,7 @@

                     <!-- check if the payment fully applied when set to confirmed-->
                     <if-compare field="parameters.statusId" operator="equals" value="PMNT_CONFIRMED">
-                        <set field="notYetApplied"
value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
+                        <set field="notYetApplied"
value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
                         <if-compare field="notYetApplied" operator="greater" value="0.00">
                             <add-error><fail-property resource="AccountingUiLabels"
property="AccountingPSNotConfirmedNotFullyApplied"/></add-error>
                             <log level="error" message="Cannot change from ${payment.statusId} to ${parameters.statusId}, payment
not fully applied: ${notYetapplied}"/>
Index: applications/accounting/webapp/accounting/agreement/AgreementForms.xml
===================================================================
--- applications/accounting/webapp/accounting/agreement/AgreementForms.xml (revision 727747)
+++ applications/accounting/webapp/accounting/agreement/AgreementForms.xml (working copy)
@@ -334,7 +334,7 @@
         <field name="partyId"><hidden value="${agreement.partyIdTo}"/></field>
         <field name="currencyUomId"><hidden value="${agreementItem.currencyUomId}"/></field>
         <field name="availableFromDate" use-when="agreementProductAppl==null">
-            <!--<date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
+            <!--<date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
             <date-time default-value="${agreement.fromDate}"/>
         </field>
         <field name="availableFromDate" use-when="agreementProductAppl!=null">
Index: applications/accounting/webapp/accounting/payment/PaymentForms.xml
===================================================================
--- applications/accounting/webapp/accounting/payment/PaymentForms.xml (revision 727747)
+++ applications/accounting/webapp/accounting/payment/PaymentForms.xml (working copy)
@@ -57,7 +57,7 @@
             </service>
         </actions>
         <row-actions>
-            <set field="amountToApply"
value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId);}"/>
+            <set field="amountToApply"
value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId)}"/>
         </row-actions>
         <field name="paymentId" widget-style="buttontext">
             <hyperlink description="${paymentId}" target="paymentOverview?paymentId=${paymentId}"/>
@@ -402,7 +402,7 @@
             </entity-condition>
         </actions>
         <row-actions>
-            <set field="amountApplied" value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator,
paymentApplicationId);}"/>
+            <set field="amountApplied" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator,
paymentApplicationId)}"/>
         </row-actions>
         <auto-fields-entity entity-name="PaymentApplication" default-field-type="display"/>
         <field name="paymentApplicationId"><hidden/></field>
Index: applications/accounting/widget/BillingAccountForms.xml
===================================================================
--- applications/accounting/widget/BillingAccountForms.xml (revision 727747)
+++ applications/accounting/widget/BillingAccountForms.xml (working copy)
@@ -133,7 +133,7 @@
         </field>
         <!--
         <field name="netBalance" title="${uiLabelMap.AccountingBillingNetBalance}"
tooltip="${uiLabelMap.AccountingBillingNetBalanceMessage}">
-            <display description="${bsh:org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
billingAccountId)}" type="currency" currency="${billingAccount.accountCurrencyUomId}"/>
+            <display description="${org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
billingAccountId)}" type="currency" currency="${billingAccount.accountCurrencyUomId}"/>
         </field>
         -->
         <field name="availableBalance" title="${uiLabelMap.AccountingBillingAvailableBalance}"
tooltip="${uiLabelMap.AccountingBillingAvailableBalanceMessage}">
Index: applications/accounting/widget/Menus.xml
===================================================================
--- applications/accounting/widget/Menus.xml (revision 727747)
+++ applications/accounting/widget/Menus.xml (working copy)
@@ -292,7 +292,7 @@
     <menu name="PaymentSubTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml"
           menu-container-style="button-bar button-style-2">
         <actions>
-            <set field="isDisbursement" value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/>
+            <set field="isDisbursement" value="${org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/>
         </actions>
         <menu-item name="createNew" title="${uiLabelMap.CommonCreateNew}">
             <condition>
Index: applications/accounting/widget/PaymentScreens.xml
===================================================================
--- applications/accounting/widget/PaymentScreens.xml (revision 727747)
+++ applications/accounting/widget/PaymentScreens.xml (working copy)
@@ -139,7 +139,7 @@
                 <set field="appliedAmount" type="String" value="${bsh:
                     import java.text.NumberFormat;
                     return(NumberFormat.getNumberInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment)));}"/>
-                <set field="notAppliedAmount" type="BigDecimal"
value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
+                <set field="notAppliedAmount" type="BigDecimal"
value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
                 <set field="notAppliedAmountStr" type="String" value="${bsh:
                     import java.text.NumberFormat;
                     return(NumberFormat.getCurrencyInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)));}"/>
@@ -316,8 +316,8 @@
                 <set field="labelTitleProperty" value="PageTitlePaymentOverview"/>
                 <set field="paymentId" from-field="parameters.paymentId"/>
                 <entity-one entity-name="Payment" value-name="payment"/>
-                <set field="appliedAmount"
value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/>
-                <set field="notAppliedAmount"
value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/>
+                <set field="appliedAmount"
value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/>
+                <set field="notAppliedAmount"
value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonPaymentDecorator" location="${parameters.mainDecoratorLocation}">
Index: applications/accounting/widget/ReportFinancialSummaryScreens.xml
===================================================================
--- applications/accounting/widget/ReportFinancialSummaryScreens.xml (revision 727747)
+++ applications/accounting/widget/ReportFinancialSummaryScreens.xml (working copy)
@@ -27,8 +27,8 @@
                 <set field="titleProperty" value="PageTitleFinancialSummaryReportOptions"/>
                 <set field="headerItem" value="FinancialSummryReports"/>

-                <set field="month" from-field="parameters.month"
default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
-                <set field="year" from-field="parameters.year"
default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
+                <set field="month" from-field="parameters.month"
default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
+                <set field="year" from-field="parameters.year"
default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
             </actions>
             <widgets>
                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
@@ -100,8 +100,8 @@
             <actions>
                 <set field="headerItem" value="FinancialSummryReports"/>

-                <set field="month" from-field="parameters.month" type="Integer"
default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
-                <set field="year" from-field="parameters.year" type="Integer"
default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
+                <set field="month" from-field="parameters.month" type="Integer"
default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
+                <set field="year" from-field="parameters.year" type="Integer"
default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
                 <set field="organizationPartyId" from-field="parameters.organizationPartyId"/>
                 <set field="currencyUomId" from-field="parameters.currencyUomId"/>

Index: applications/order/webapp/ordermgr/requirement/RequirementForms.xml
===================================================================
--- applications/order/webapp/ordermgr/requirement/RequirementForms.xml (revision 727747)
+++ applications/order/webapp/ordermgr/requirement/RequirementForms.xml (working copy)
@@ -281,7 +281,7 @@
         </field>
         <field name="facilityId"><display/></field>
         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
-            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
+            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
         </field>
         <field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
         <field name="idValue" title="UPCA"><display/></field>
@@ -306,7 +306,7 @@
             <display-entity entity-name="Product" key-field-name="productId" description="${internalName}"/>
         </field>
         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
-            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
+            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
         </field>
         <field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
         <field name="idValue" title="UPCA"><display/></field>
@@ -335,7 +335,7 @@
     <form name="ApprovedProductRequirementsByVendor" type="list" use-row-submit="true" list-name="requirements"
target="ApprovedProductRequirements" separate-columns="true"
         paginate-target="ApprovedProductRequirementsByVendor" odd-row-style="alternate-row" default-table-style="basic-table
hover-bar">
         <field name="partyId">
-            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
+            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
         </field>
         <field name="productId" title="${uiLabelMap.OrderVendorRequirementCount}" widget-area-style="align-text"><display
also-hidden="false"/></field>
         <field name="billToCustomerPartyId">
Index: applications/order/webapp/ordermgr/return/ReturnForms.xml
===================================================================
--- applications/order/webapp/ordermgr/return/ReturnForms.xml (revision 727747)
+++ applications/order/webapp/ordermgr/return/ReturnForms.xml (working copy)
@@ -90,7 +90,7 @@
         </field>
         <field name="paymentMethodId" use-when="creditCardList!=null&amp;&amp;creditCardList.size()&gt;0">
             <drop-down allow-empty="true">
-                <list-options key-name="paymentMethodId" list-name="creditCardList" list-entry-name="creditCardPm"
description="${bsh:org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
+                <list-options key-name="paymentMethodId" list-name="creditCardList" list-entry-name="creditCardPm"
description="${org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
             </drop-down>
         </field>
         <field name="newCreditCard" widget-style="buttontext"
use-when="returnHeader!=null&amp;&amp;returnHeader.getString(&quot;fromPartyId&quot;)!=null">
Index: applications/product/webapp/catalog/product/ProductForms.xml
===================================================================
--- applications/product/webapp/catalog/product/ProductForms.xml (revision 727747)
+++ applications/product/webapp/catalog/product/ProductForms.xml (working copy)
@@ -701,7 +701,7 @@
             </drop-down>
         </field>
         <field name="availableFromDate" use-when="supplierProduct==null">
-            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
+            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
         </field>
         <field name="availableFromDate" use-when="supplierProduct!=null">
             <display/>
Index: applications/product/webapp/facility/facility/FacilityForms.xml
===================================================================
--- applications/product/webapp/facility/facility/FacilityForms.xml (revision 727747)
+++ applications/product/webapp/facility/facility/FacilityForms.xml (working copy)
@@ -349,7 +349,7 @@
         <field name="offsetQOHQty" title="${uiLabelMap.ProductQtyOffsetQOHBelow}"><text/></field>
         <field name="offsetATPQty" title="${uiLabelMap.ProductQtyOffsetATPBelow}"><text/></field>
         <field name="productsSoldThruTimestamp" title="${uiLabelMap.ProductShowProductsSoldThruTimestamp}">
-            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
+            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
         </field>
         <field name="VIEW_SIZE" entry-name="viewSize" title="${uiLabelMap.ProductShowProductsPerPage}"><text/></field>
         <field name="monthsInPastLimit" entry-name="monthsInPastLimit"><text/></field>
Index: applications/workeffort/widget/WorkEffortForms.xml
===================================================================
--- applications/workeffort/widget/WorkEffortForms.xml (revision 727747)
+++ applications/workeffort/widget/WorkEffortForms.xml (working copy)
@@ -842,7 +842,7 @@
            <hyperlink target="EditWorkEffort?workEffortId=${workEffortId}" also-hidden="false" description="${workEffortId}"/>
         </field>
         <field name="noteInfo" title="${uiLabelMap.CommonNote}"><display/></field>
-        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${noteDateTime}"/></field>
+        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${noteDateTime}"/></field>
         <field name="internalNote" title="${uiLabelMap.WorkEffortPrivatePublic}" widget-style="buttontext"
use-when="internalNote.equals(&quot;N&quot;)">
             <hyperlink target="updateWorkEffortNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
description="${uiLabelMap.OrderNotesPrivate}" />
         </field>
Index: framework/example/widget/example/FormWidgetExampleForms.xml
===================================================================
--- framework/example/widget/example/FormWidgetExampleForms.xml (revision 727747)
+++ framework/example/widget/example/FormWidgetExampleForms.xml (working copy)
@@ -39,7 +39,7 @@
         <field name="field9"
                title="Field9: date and time selection field with default value"
                tooltip="Same as above, Uses the ${bsh: notation to call an util method to get the now timestamp}">
-            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
+            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
         </field>
         <!-- ***************** -->
         <!-- ***   field10  *** -->
@@ -97,7 +97,7 @@
                entry-name="exampleDateField"
                title="Field7: date and time display with custom format"
                tooltip="This is an example of MM/dd/yyyy format">
-            <display description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
&quot;MM/dd/yyyy&quot;);}"/>
+            <display description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MM/dd/yyyy&quot;)}"/>
         </field>
         <!-- ***************** -->
         <!-- ***   field8  *** -->
@@ -106,7 +106,7 @@
                entry-name="exampleDateField"
                title="Field8: date and time display with custom format"
                tooltip="This is an example of MMMM, dd, yyyy format">
-            <display description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MMMM, dd,
yyyy&quot;);}"/>
+            <display description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MMMM, dd, yyyy&quot;)}"/>
         </field>
     </form>

Index: framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml
===================================================================
--- framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml (revision 727747)
+++ framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml (working copy)
@@ -24,7 +24,7 @@
     <!-- Temporal Expression forms -->
     <form name="FindTemporalExpression" target="findTemporalExpression" type="single">
         <actions>
-            <set field="expressionTypeList"
value="${bsh:org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap);}" type="List"/>
+            <set field="expressionTypeList"
value="${org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap)}" type="List"/>
         </actions>
         <field name="tempExprId" title="${uiLabelMap.TemporalExpressionId}"><text-find/></field>
 <!--        <field name="tempExprTypeId" title="${uiLabelMap.TemporalExpressionType}">
Index: specialpurpose/ebay/widget/EbayForms.xml
===================================================================
--- specialpurpose/ebay/widget/EbayForms.xml (revision 727747)
+++ specialpurpose/ebay/widget/EbayForms.xml (working copy)
@@ -29,8 +29,8 @@
                 </entity-options>
             </drop-down>
         </field>
-        <field name="fromDate" title="${uiLabelMap.CommonFromDateTime}"><date-time default-value="${bsh:
org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
-        <field name="thruDate" title="${uiLabelMap.CommonThruDateTime}"><date-time default-value="${bsh:
org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
+        <field name="fromDate" title="${uiLabelMap.CommonFromDateTime}"><date-time
default-value="${org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
+        <field name="thruDate" title="${uiLabelMap.CommonThruDateTime}"><date-time
default-value="${org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
         <field name="submitButton" title="${uiLabelMap.EbayImportOrdersSearchFromEbay}"><submit button-type="button"/></field>
     </form>
     <form name="ListOrdersFromEbay" type="multi" use-row-submit="true" list-name="orderList" target="ImportOrderFromEbay"
Index: specialpurpose/projectmgr/widget/forms/ProjectForms.xml
===================================================================
--- specialpurpose/projectmgr/widget/forms/ProjectForms.xml (revision 727747)
+++ specialpurpose/projectmgr/widget/forms/ProjectForms.xml (working copy)
@@ -426,7 +426,7 @@
             </entity-condition>
         </actions>
         <field name="workEffortId"><hidden/></field>
-        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${bsh:
org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
context.get(&quot;locale&quot;))}"/></field>
+        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at
${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
context.get(&quot;locale&quot;))}"/></field>
     </form>
     <form name="listResourcesTasks" type="list" list-name="tasks" paginate-target="listResourcesTask"
target="updateResourcesTaskAssigment"
         odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
Index: specialpurpose/projectmgr/widget/forms/TaskForms.xml
===================================================================
--- specialpurpose/projectmgr/widget/forms/TaskForms.xml (revision 727747)
+++ specialpurpose/projectmgr/widget/forms/TaskForms.xml (working copy)
@@ -442,7 +442,7 @@
         </actions>
         <field name="noteId"><hidden/></field>
         <field name="workEffortId"><hidden/></field>
-        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${bsh:
org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
context.get(&quot;locale&quot;))}"/></field>
+        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at
${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
context.get(&quot;locale&quot;))}"/></field>

         <field name="Private/Public" widget-style="buttontext" title="${uiLabelMap.ProjectMgrPrivateOrPublic}"
use-when="internalNote.equals(&quot;N&quot;)">
             <hyperlink target="updateTaskNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
description="${uiLabelMap.OrderNotesPrivate}"></hyperlink>
Index: specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
===================================================================
--- specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (revision 727747)
+++ specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (working copy)
@@ -119,7 +119,7 @@
             <hyperlink also-hidden="false" description="${timesheetId}" target="Timesheet?timesheetId=${timesheetId}"/>
         </field>
         <field name="partyId" title="${uiLabelMap.PartyParty}"><display-entity entity-name="PartyNameView"
description="${firstName} ${middleName} ${lastName} ${groupName}"/></field>
-        <field name="actualHours" title="${uiLabelMap.ProjectMgrActualHours}"><display description="${bsh:
org.ofbiz.project.Various.calculateActualHours(delegator, timesheetId);}"/></field>
+        <field name="actualHours" title="${uiLabelMap.ProjectMgrActualHours}"><display
description="${org.ofbiz.project.Various.calculateActualHours(delegator, timesheetId)}"/></field>
         <field name="statusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem"
description="${description}"/></field>
         <field name="fromDate" title="${uiLabelMap.CommonFromDate}"><display type="date"/></field>
         <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><display type="date"/></field>


Jacques

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

> Jacques,
>
> UEL supports ternary operations. So,
>
> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal + absolutePostedBalance): (debitTotal))}"
> type="BigDecimal"/>
>
> becomes
>
> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal + absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>
> Also, the reason for the UEL function name prefix (math: str: util:) is the same reason we have Java package names and XML
> namespaces - to avoid function name clash.
>
> -Adrian
>
>
> Jacques Le Roux wrote:
>> Hi Adrian,
>>
>> Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
>> changing(/adding) type from "Double" to "BigDecimal" as David suggested recently
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL
>>> functions.
>>>
>>> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus
>>> side, you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>>>
>>> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix
>>> and a short script:
>>>
>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>
>>> Using a UEL function:
>>>
>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>
>>> or to get the length of a String:
>>>
>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>>
>>> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>>>
>>> -Adrian
>>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum
Patch attached for review

Jacques

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

> Jacques,
>
> UEL supports ternary operations. So,
>
> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal
> + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>
> becomes
>
> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>
> Also, the reason for the UEL function name prefix (math: str: util:) is
> the same reason we have Java package names and XML namespaces - to avoid
> function name clash.
>
> -Adrian
>
>
> Jacques Le Roux wrote:
>> Hi Adrian,
>>
>> Is {util: syntax also dealing with ternary operator (did not look into
>> details, doing some {bsh: to {util: changes while changing(/adding) type
>> from "Double" to "BigDecimal" as David suggested recently
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Now that we have the Unified Expression Language implemented in
>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>
>>> On the plus side, UEL functions can make screen widget and
>>> mini-language code more flexible and more powerful. On the minus side,
>>> you have to know the functions and what they do (in other words, no
>>> auto-completion when working in XML).
>>>
>>> As an example, I frequently need to know the size of a List, Map, or
>>> String. With current code, I have to use the bsh: prefix and a short
>>> script:
>>>
>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>
>>> Using a UEL function:
>>>
>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>
>>> or to get the length of a String:
>>>
>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>>> type="Integer"/>.
>>>
>>> I don't know if this would be of any use, or if it is desirable. I'm
>>> just tossing the idea out there for discussion.
>>>
>>> -Adrian
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum
In reply to this post by Jacques Le Roux
I don't think that will work - UEL doesn't allow direct method calls
like that. The JUEL library has an extension that supports it, but I
have that disabled.

-Adrian

Jacques Le Roux wrote:

> So the sequel should be ok, please confirm (I will try to post the patch
> as attachment in another email - for readability - but I'm afraid it
> will not get through)
>
> Index:
> applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
>
> ===================================================================
> ---
> applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
> (revision 727828)
> +++
> applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
> (working copy)
> @@ -448,7 +448,7 @@
>             <else>
>                 <!-- if new status is paid check if the complete invoice
> is applied. -->
>                 <if-compare field="parameters.statusId"
> operator="equals" value="INVOICE_PAID">
> -                    <set field="notApplied" type="BigDecimal"
> value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
>
> +                    <set field="notApplied" type="BigDecimal"
> value="${org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
>
>                     <if-compare field="notApplied" operator="not-equals"
> value="0.00" type="BigDecimal">
>                         <add-error><fail-message message="Cannot change
> status to 'paid', invoice ${invoice.invoiceId} has an unapplied balance
> of [${notApplied}]"/></add-error>
>                         <check-errors/>
> Index:
> applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
>
> ===================================================================
> ---
> applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
> (revision 727747)
> +++
> applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
> (working copy)
> @@ -226,7 +226,7 @@
>         <!-- check the scheduled posting date, but only if it's set -->
>         <if-not-empty field="acctgTrans.scheduledPostingDate">
>             <set field="scheduledPostingDate"
> from-field="acctgTrans.scheduledPostingDate"/>
> -            <set field="beforeScheduled" value="${bsh:
> org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/>
>
> +            <set field="beforeScheduled"
> value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/>
>
>             <if-compare field="beforeScheduled" operator="equals"
> value="true" type="Boolean">
>                 <add-error><fail-message message="Not posting GL
> Accounting Transaction with ID [${parameters.acctgTransId}] because it's
> not scheduled to be posted yet.  The scheduled posting date is
> [${acctgTrans.scheduledPostingDate}]"/></add-error>
>             </if-compare>
> @@ -335,7 +335,7 @@
>                 <get-related-one relation-name="GlAccountClass"
> value-name="glAccount" to-value-name="glAccountClass"/>
>                 <get-related-one relation-name="ParentGlAccountClass"
> value-name="glAccountClass" to-value-name="parentGlAccountClass"/>
>                 <!-- test if the account is a DEBIT account -->
> -                <set field="isDebit"
> value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/>
>
> +                <set field="isDebit"
> value="${org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/>
>
>                 <if-compare field="isDebit" operator="equals" value="true">
>                         <if-compare
> field="acctgTransEntry.debitCreditFlag" operator="equals" value="D">
>                             <set from-field="acctgTransEntry.amount"
> field="postingAmount"/>
> @@ -349,7 +349,7 @@
>                         </if-compare>
>                     <else>
>                         <!-- otherwise, test if the account is credit -->
> -                        <set field="isCredit"
> value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/>
>
> +                        <set field="isCredit"
> value="${org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/>
>
>                         <if-compare field="isCredit" operator="equals"
> value="true">
>                             <if-compare
> field="acctgTransEntry.debitCreditFlag" operator="equals" value="C">
>                                 <set from-field="acctgTransEntry.amount"
> field="postingAmount"/>
> Index:
> applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>
> ===================================================================
> ---
> applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> (revision 727747)
> +++
> applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> (working copy)
> @@ -186,7 +186,7 @@
>
>                     <!-- check if the payment fully applied when set to
> confirmed-->
>                     <if-compare field="parameters.statusId"
> operator="equals" value="PMNT_CONFIRMED">
> -                        <set field="notYetApplied"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
>
> +                        <set field="notYetApplied"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
>
>                         <if-compare field="notYetApplied"
> operator="greater" value="0.00">
>                             <add-error><fail-property
> resource="AccountingUiLabels"
> property="AccountingPSNotConfirmedNotFullyApplied"/></add-error>
>                             <log level="error" message="Cannot change
> from ${payment.statusId} to ${parameters.statusId}, payment not fully
> applied: ${notYetapplied}"/>
> Index:
> applications/accounting/webapp/accounting/agreement/AgreementForms.xml
> ===================================================================
> ---
> applications/accounting/webapp/accounting/agreement/AgreementForms.xml
> (revision 727747)
> +++
> applications/accounting/webapp/accounting/agreement/AgreementForms.xml
> (working copy)
> @@ -334,7 +334,7 @@
>         <field name="partyId"><hidden
> value="${agreement.partyIdTo}"/></field>
>         <field name="currencyUomId"><hidden
> value="${agreementItem.currencyUomId}"/></field>
>         <field name="availableFromDate"
> use-when="agreementProductAppl==null">
> -            <!--<date-time default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
> +            <!--<date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
>             <date-time default-value="${agreement.fromDate}"/>
>         </field>
>         <field name="availableFromDate"
> use-when="agreementProductAppl!=null">
> Index: applications/accounting/webapp/accounting/payment/PaymentForms.xml
> ===================================================================
> --- applications/accounting/webapp/accounting/payment/PaymentForms.xml
> (revision 727747)
> +++ applications/accounting/webapp/accounting/payment/PaymentForms.xml
> (working copy)
> @@ -57,7 +57,7 @@
>             </service>
>         </actions>
>         <row-actions>
> -            <set field="amountToApply"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId);}"/>
>
> +            <set field="amountToApply"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId)}"/>
>
>         </row-actions>
>         <field name="paymentId" widget-style="buttontext">
>             <hyperlink description="${paymentId}"
> target="paymentOverview?paymentId=${paymentId}"/>
> @@ -402,7 +402,7 @@
>             </entity-condition>
>         </actions>
>         <row-actions>
> -            <set field="amountApplied"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator,
> paymentApplicationId);}"/>
> +            <set field="amountApplied"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator,
> paymentApplicationId)}"/>
>         </row-actions>
>         <auto-fields-entity entity-name="PaymentApplication"
> default-field-type="display"/>
>         <field name="paymentApplicationId"><hidden/></field>
> Index: applications/accounting/widget/BillingAccountForms.xml
> ===================================================================
> --- applications/accounting/widget/BillingAccountForms.xml (revision
> 727747)
> +++ applications/accounting/widget/BillingAccountForms.xml (working copy)
> @@ -133,7 +133,7 @@
>         </field>
>         <!--
>         <field name="netBalance"
> title="${uiLabelMap.AccountingBillingNetBalance}"
> tooltip="${uiLabelMap.AccountingBillingNetBalanceMessage}">
> -            <display
> description="${bsh:org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
> billingAccountId)}" type="currency"
> currency="${billingAccount.accountCurrencyUomId}"/>
> +            <display
> description="${org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
> billingAccountId)}" type="currency"
> currency="${billingAccount.accountCurrencyUomId}"/>
>         </field>
>         -->
>         <field name="availableBalance"
> title="${uiLabelMap.AccountingBillingAvailableBalance}"
> tooltip="${uiLabelMap.AccountingBillingAvailableBalanceMessage}">
> Index: applications/accounting/widget/Menus.xml
> ===================================================================
> --- applications/accounting/widget/Menus.xml (revision 727747)
> +++ applications/accounting/widget/Menus.xml (working copy)
> @@ -292,7 +292,7 @@
>     <menu name="PaymentSubTabBar" extends="CommonTabBarMenu"
> extends-resource="component://common/widget/CommonMenus.xml"
>           menu-container-style="button-bar button-style-2">
>         <actions>
> -            <set field="isDisbursement"
> value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/>
>
> +            <set field="isDisbursement"
> value="${org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/>
>
>         </actions>
>         <menu-item name="createNew" title="${uiLabelMap.CommonCreateNew}">
>             <condition>
> Index: applications/accounting/widget/PaymentScreens.xml
> ===================================================================
> --- applications/accounting/widget/PaymentScreens.xml (revision 727747)
> +++ applications/accounting/widget/PaymentScreens.xml (working copy)
> @@ -139,7 +139,7 @@
>                 <set field="appliedAmount" type="String" value="${bsh:
>                     import java.text.NumberFormat;
>                    
> return(NumberFormat.getNumberInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment)));}"/>
>
> -                <set field="notAppliedAmount" type="BigDecimal"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
>
> +                <set field="notAppliedAmount" type="BigDecimal"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/>
>
>                 <set field="notAppliedAmountStr" type="String"
> value="${bsh:
>                     import java.text.NumberFormat;
>                    
> return(NumberFormat.getCurrencyInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)));}"/>
>
> @@ -316,8 +316,8 @@
>                 <set field="labelTitleProperty"
> value="PageTitlePaymentOverview"/>
>                 <set field="paymentId" from-field="parameters.paymentId"/>
>                 <entity-one entity-name="Payment" value-name="payment"/>
> -                <set field="appliedAmount"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/>
>
> -                <set field="notAppliedAmount"
> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/>
>
> +                <set field="appliedAmount"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/>
>
> +                <set field="notAppliedAmount"
> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/>
>
>             </actions>
>             <widgets>
>                 <decorator-screen name="CommonPaymentDecorator"
> location="${parameters.mainDecoratorLocation}">
> Index: applications/accounting/widget/ReportFinancialSummaryScreens.xml
> ===================================================================
> --- applications/accounting/widget/ReportFinancialSummaryScreens.xml
> (revision 727747)
> +++ applications/accounting/widget/ReportFinancialSummaryScreens.xml
> (working copy)
> @@ -27,8 +27,8 @@
>                 <set field="titleProperty"
> value="PageTitleFinancialSummaryReportOptions"/>
>                 <set field="headerItem" value="FinancialSummryReports"/>
>
> -                <set field="month" from-field="parameters.month"
> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
>
> -                <set field="year" from-field="parameters.year"
> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
>
> +                <set field="month" from-field="parameters.month"
> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
>
> +                <set field="year" from-field="parameters.year"
> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
>
>             </actions>
>             <widgets>
>                 <decorator-screen name="main-decorator"
> location="${parameters.mainDecoratorLocation}">
> @@ -100,8 +100,8 @@
>             <actions>
>                 <set field="headerItem" value="FinancialSummryReports"/>
>
> -                <set field="month" from-field="parameters.month"
> type="Integer"
> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
>
> -                <set field="year" from-field="parameters.year"
> type="Integer"
> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
>
> +                <set field="month" from-field="parameters.month"
> type="Integer"
> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
>
> +                <set field="year" from-field="parameters.year"
> type="Integer"
> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/>
>
>                 <set field="organizationPartyId"
> from-field="parameters.organizationPartyId"/>
>                 <set field="currencyUomId"
> from-field="parameters.currencyUomId"/>
>
> Index: applications/order/webapp/ordermgr/requirement/RequirementForms.xml
> ===================================================================
> --- applications/order/webapp/ordermgr/requirement/RequirementForms.xml
> (revision 727747)
> +++ applications/order/webapp/ordermgr/requirement/RequirementForms.xml
> (working copy)
> @@ -281,7 +281,7 @@
>         </field>
>         <field name="facilityId"><display/></field>
>         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
> -            <display description="${bsh:
> org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId,
> false);}"/>
> +            <display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> partyId, false)}"/>
>         </field>
>         <field name="supplierProductId"
> title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
>         <field name="idValue" title="UPCA"><display/></field>
> @@ -306,7 +306,7 @@
>             <display-entity entity-name="Product"
> key-field-name="productId" description="${internalName}"/>
>         </field>
>         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
> -            <display description="${bsh:
> org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId,
> false);}"/>
> +            <display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> partyId, false)}"/>
>         </field>
>         <field name="supplierProductId"
> title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
>         <field name="idValue" title="UPCA"><display/></field>
> @@ -335,7 +335,7 @@
>     <form name="ApprovedProductRequirementsByVendor" type="list"
> use-row-submit="true" list-name="requirements"
> target="ApprovedProductRequirements" separate-columns="true"
>         paginate-target="ApprovedProductRequirementsByVendor"
> odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
>         <field name="partyId">
> -            <display description="${bsh:
> org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId,
> false);}"/>
> +            <display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> partyId, false)}"/>
>         </field>
>         <field name="productId"
> title="${uiLabelMap.OrderVendorRequirementCount}"
> widget-area-style="align-text"><display also-hidden="false"/></field>
>         <field name="billToCustomerPartyId">
> Index: applications/order/webapp/ordermgr/return/ReturnForms.xml
> ===================================================================
> --- applications/order/webapp/ordermgr/return/ReturnForms.xml (revision
> 727747)
> +++ applications/order/webapp/ordermgr/return/ReturnForms.xml (working
> copy)
> @@ -90,7 +90,7 @@
>         </field>
>         <field name="paymentMethodId"
> use-when="creditCardList!=null&amp;&amp;creditCardList.size()&gt;0">
>             <drop-down allow-empty="true">
> -                <list-options key-name="paymentMethodId"
> list-name="creditCardList" list-entry-name="creditCardPm"
> description="${bsh:org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
>
> +                <list-options key-name="paymentMethodId"
> list-name="creditCardList" list-entry-name="creditCardPm"
> description="${org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
>
>             </drop-down>
>         </field>
>         <field name="newCreditCard" widget-style="buttontext"
> use-when="returnHeader!=null&amp;&amp;returnHeader.getString(&quot;fromPartyId&quot;)!=null">
>
> Index: applications/product/webapp/catalog/product/ProductForms.xml
> ===================================================================
> --- applications/product/webapp/catalog/product/ProductForms.xml
> (revision 727747)
> +++ applications/product/webapp/catalog/product/ProductForms.xml
> (working copy)
> @@ -701,7 +701,7 @@
>             </drop-down>
>         </field>
>         <field name="availableFromDate" use-when="supplierProduct==null">
> -            <date-time default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> +            <date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>         </field>
>         <field name="availableFromDate" use-when="supplierProduct!=null">
>             <display/>
> Index: applications/product/webapp/facility/facility/FacilityForms.xml
> ===================================================================
> --- applications/product/webapp/facility/facility/FacilityForms.xml
> (revision 727747)
> +++ applications/product/webapp/facility/facility/FacilityForms.xml
> (working copy)
> @@ -349,7 +349,7 @@
>         <field name="offsetQOHQty"
> title="${uiLabelMap.ProductQtyOffsetQOHBelow}"><text/></field>
>         <field name="offsetATPQty"
> title="${uiLabelMap.ProductQtyOffsetATPBelow}"><text/></field>
>         <field name="productsSoldThruTimestamp"
> title="${uiLabelMap.ProductShowProductsSoldThruTimestamp}">
> -            <date-time default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> +            <date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>         </field>
>         <field name="VIEW_SIZE" entry-name="viewSize"
> title="${uiLabelMap.ProductShowProductsPerPage}"><text/></field>
>         <field name="monthsInPastLimit"
> entry-name="monthsInPastLimit"><text/></field>
> Index: applications/workeffort/widget/WorkEffortForms.xml
> ===================================================================
> --- applications/workeffort/widget/WorkEffortForms.xml (revision 727747)
> +++ applications/workeffort/widget/WorkEffortForms.xml (working copy)
> @@ -842,7 +842,7 @@
>            <hyperlink
> target="EditWorkEffort?workEffortId=${workEffortId}" also-hidden="false"
> description="${workEffortId}"/>
>         </field>
>         <field name="noteInfo"
> title="${uiLabelMap.CommonNote}"><display/></field>
> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at ${noteDateTime}"/></field>
> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at ${noteDateTime}"/></field>
>         <field name="internalNote"
> title="${uiLabelMap.WorkEffortPrivatePublic}" widget-style="buttontext"
> use-when="internalNote.equals(&quot;N&quot;)">
>             <hyperlink
> target="updateWorkEffortNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
> description="${uiLabelMap.OrderNotesPrivate}" />
>         </field>
> Index: framework/example/widget/example/FormWidgetExampleForms.xml
> ===================================================================
> --- framework/example/widget/example/FormWidgetExampleForms.xml
> (revision 727747)
> +++ framework/example/widget/example/FormWidgetExampleForms.xml (working
> copy)
> @@ -39,7 +39,7 @@
>         <field name="field9"
>                title="Field9: date and time selection field with default
> value"
>                tooltip="Same as above, Uses the ${bsh: notation to call
> an util method to get the now timestamp}">
> -            <date-time default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> +            <date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>         </field>
>         <!-- ***************** -->
>         <!-- ***   field10  *** -->
> @@ -97,7 +97,7 @@
>                entry-name="exampleDateField"
>                title="Field7: date and time display with custom format"
>                tooltip="This is an example of MM/dd/yyyy format">
> -            <display
> description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
> &quot;MM/dd/yyyy&quot;);}"/>
> +            <display
> description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
> &quot;MM/dd/yyyy&quot;)}"/>
>         </field>
>         <!-- ***************** -->
>         <!-- ***   field8  *** -->
> @@ -106,7 +106,7 @@
>                entry-name="exampleDateField"
>                title="Field8: date and time display with custom format"
>                tooltip="This is an example of MMMM, dd, yyyy format">
> -            <display
> description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
> &quot;MMMM, dd, yyyy&quot;);}"/>
> +            <display
> description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
> &quot;MMMM, dd, yyyy&quot;)}"/>
>         </field>
>     </form>
>
> Index: framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml
> ===================================================================
> --- framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml
> (revision 727747)
> +++ framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml
> (working copy)
> @@ -24,7 +24,7 @@
>     <!-- Temporal Expression forms -->
>     <form name="FindTemporalExpression" target="findTemporalExpression"
> type="single">
>         <actions>
> -            <set field="expressionTypeList"
> value="${bsh:org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap);}"
> type="List"/>
> +            <set field="expressionTypeList"
> value="${org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap)}"
> type="List"/>
>         </actions>
>         <field name="tempExprId"
> title="${uiLabelMap.TemporalExpressionId}"><text-find/></field>
> <!--        <field name="tempExprTypeId"
> title="${uiLabelMap.TemporalExpressionType}">
> Index: specialpurpose/ebay/widget/EbayForms.xml
> ===================================================================
> --- specialpurpose/ebay/widget/EbayForms.xml (revision 727747)
> +++ specialpurpose/ebay/widget/EbayForms.xml (working copy)
> @@ -29,8 +29,8 @@
>                 </entity-options>
>             </drop-down>
>         </field>
> -        <field name="fromDate"
> title="${uiLabelMap.CommonFromDateTime}"><date-time
> default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
>
> -        <field name="thruDate"
> title="${uiLabelMap.CommonThruDateTime}"><date-time
> default-value="${bsh:
> org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
>
> +        <field name="fromDate"
> title="${uiLabelMap.CommonFromDateTime}"><date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
>
> +        <field name="thruDate"
> title="${uiLabelMap.CommonThruDateTime}"><date-time
> default-value="${org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field>
>
>         <field name="submitButton"
> title="${uiLabelMap.EbayImportOrdersSearchFromEbay}"><submit
> button-type="button"/></field>
>     </form>
>     <form name="ListOrdersFromEbay" type="multi" use-row-submit="true"
> list-name="orderList" target="ImportOrderFromEbay"
> Index: specialpurpose/projectmgr/widget/forms/ProjectForms.xml
> ===================================================================
> --- specialpurpose/projectmgr/widget/forms/ProjectForms.xml (revision
> 727747)
> +++ specialpurpose/projectmgr/widget/forms/ProjectForms.xml (working copy)
> @@ -426,7 +426,7 @@
>             </entity-condition>
>         </actions>
>         <field name="workEffortId"><hidden/></field>
> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at ${bsh:
> org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime,
> &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
> context.get(&quot;locale&quot;))}"/></field>
> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at
> ${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime,
> &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
> context.get(&quot;locale&quot;))}"/></field>
>     </form>
>     <form name="listResourcesTasks" type="list" list-name="tasks"
> paginate-target="listResourcesTask" target="updateResourcesTaskAssigment"
>         odd-row-style="alternate-row" header-row-style="header-row-2"
> default-table-style="basic-table hover-bar">
> Index: specialpurpose/projectmgr/widget/forms/TaskForms.xml
> ===================================================================
> --- specialpurpose/projectmgr/widget/forms/TaskForms.xml (revision 727747)
> +++ specialpurpose/projectmgr/widget/forms/TaskForms.xml (working copy)
> @@ -442,7 +442,7 @@
>         </actions>
>         <field name="noteId"><hidden/></field>
>         <field name="workEffortId"><hidden/></field>
> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at ${bsh:
> org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime,
> &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
> context.get(&quot;locale&quot;))}"/></field>
> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator,
> noteParty, true)} at
> ${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime,
> &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
> context.get(&quot;locale&quot;))}"/></field>
>
>         <field name="Private/Public" widget-style="buttontext"
> title="${uiLabelMap.ProjectMgrPrivateOrPublic}"
> use-when="internalNote.equals(&quot;N&quot;)">
>             <hyperlink
> target="updateTaskNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
> description="${uiLabelMap.OrderNotesPrivate}"></hyperlink>
> Index: specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
> ===================================================================
> --- specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (revision
> 727747)
> +++ specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (working
> copy)
> @@ -119,7 +119,7 @@
>             <hyperlink also-hidden="false" description="${timesheetId}"
> target="Timesheet?timesheetId=${timesheetId}"/>
>         </field>
>         <field name="partyId"
> title="${uiLabelMap.PartyParty}"><display-entity
> entity-name="PartyNameView" description="${firstName} ${middleName}
> ${lastName} ${groupName}"/></field>
> -        <field name="actualHours"
> title="${uiLabelMap.ProjectMgrActualHours}"><display description="${bsh:
> org.ofbiz.project.Various.calculateActualHours(delegator,
> timesheetId);}"/></field>
> +        <field name="actualHours"
> title="${uiLabelMap.ProjectMgrActualHours}"><display
> description="${org.ofbiz.project.Various.calculateActualHours(delegator,
> timesheetId)}"/></field>
>         <field name="statusId"
> title="${uiLabelMap.CommonStatus}"><display-entity
> entity-name="StatusItem" description="${description}"/></field>
>         <field name="fromDate"
> title="${uiLabelMap.CommonFromDate}"><display type="date"/></field>
>         <field name="thruDate"
> title="${uiLabelMap.CommonThruDate}"><display type="date"/></field>
>
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Jacques,
>>
>> UEL supports ternary operations. So,
>>
>> <set field="parameters.debitTotal" value="${bsh:(showDebit?
>> (debitTotal + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>>
>> becomes
>>
>> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
>> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>>
>> Also, the reason for the UEL function name prefix (math: str: util:)
>> is the same reason we have Java package names and XML namespaces - to
>> avoid function name clash.
>>
>> -Adrian
>>
>>
>> Jacques Le Roux wrote:
>>> Hi Adrian,
>>>
>>> Is {util: syntax also dealing with ternary operator (did not look
>>> into details, doing some {bsh: to {util: changes while
>>> changing(/adding) type from "Double" to "BigDecimal" as David
>>> suggested recently
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Adrian Crum" <[hidden email]>
>>>> Now that we have the Unified Expression Language implemented in
>>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>>
>>>> On the plus side, UEL functions can make screen widget and
>>>> mini-language code more flexible and more powerful. On the minus
>>>> side, you have to know the functions and what they do (in other
>>>> words, no auto-completion when working in XML).
>>>>
>>>> As an example, I frequently need to know the size of a List, Map, or
>>>> String. With current code, I have to use the bsh: prefix and a short
>>>> script:
>>>>
>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}"
>>>> type="Integer"/>.
>>>>
>>>> Using a UEL function:
>>>>
>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>
>>>> or to get the length of a String:
>>>>
>>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>>>> type="Integer"/>.
>>>>
>>>> I don't know if this would be of any use, or if it is desirable. I'm
>>>> just tossing the idea out there for discussion.
>>>>
>>>> -Adrian
>>>>
>>>
>>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
From: "Adrian Crum" <[hidden email]>
>I don't think that will work - UEL doesn't allow direct method calls like that. The JUEL library has an extension that supports it,
>but I have that disabled.

OK, we will see then, I revert locally for now.

Jacques

> -Adrian
>
> Jacques Le Roux wrote:
>> So the sequel should be ok, please confirm (I will try to post the patch as attachment in another email - for readability - but
>> I'm afraid it will not get through)
>>
>> Index: applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
>> ===================================================================
>> ---
>> applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (revision 727828)
>> +++ applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (working copy)
>> @@ -448,7 +448,7 @@
>>             <else>
>>                 <!-- if new status is paid check if the complete invoice is applied. -->
>>                 <if-compare field="parameters.statusId" operator="equals" value="INVOICE_PAID">
>> -                    <set field="notApplied" type="BigDecimal"
>> value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/> +                    <set
>> field="notApplied" type="BigDecimal" value="${org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
>> <if-compare field="notApplied" operator="not-equals" value="0.00" type="BigDecimal">
>>                         <add-error><fail-message message="Cannot change status to 'paid', invoice ${invoice.invoiceId} has an
>> unapplied balance of [${notApplied}]"/></add-error>
>>                         <check-errors/>
>> Index: applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
>> ===================================================================
>> ---
>> applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (revision 727747)
>> +++ applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (working copy)
>> @@ -226,7 +226,7 @@
>>         <!-- check the scheduled posting date, but only if it's set -->
>>         <if-not-empty field="acctgTrans.scheduledPostingDate">
>>             <set field="scheduledPostingDate" from-field="acctgTrans.scheduledPostingDate"/>
>> -            <set field="beforeScheduled" value="${bsh:
>> org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/> +            <set field="beforeScheduled"
>> value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp().before(scheduledPostingDate)}"/> <if-compare field="beforeScheduled"
>> operator="equals" value="true" type="Boolean">
>>                 <add-error><fail-message message="Not posting GL Accounting Transaction with ID [${parameters.acctgTransId}]
>> because it's not scheduled to be posted yet.  The scheduled posting date is [${acctgTrans.scheduledPostingDate}]"/></add-error>
>>             </if-compare>
>> @@ -335,7 +335,7 @@
>>                 <get-related-one relation-name="GlAccountClass" value-name="glAccount" to-value-name="glAccountClass"/>
>>                 <get-related-one relation-name="ParentGlAccountClass" value-name="glAccountClass"
>> to-value-name="parentGlAccountClass"/>
>>                 <!-- test if the account is a DEBIT account -->
>> -                <set field="isDebit" value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/> +
>> <set field="isDebit" value="${org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)}"/> <if-compare field="isDebit"
>> operator="equals" value="true">
>>                         <if-compare field="acctgTransEntry.debitCreditFlag" operator="equals" value="D">
>>                             <set from-field="acctgTransEntry.amount" field="postingAmount"/>
>> @@ -349,7 +349,7 @@
>>                         </if-compare>
>>                     <else>
>>                         <!-- otherwise, test if the account is credit -->
>> -                        <set field="isCredit"
>> value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/> +                        <set
>> field="isCredit" value="${org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)}"/> <if-compare field="isCredit"
>> operator="equals" value="true">
>>                             <if-compare field="acctgTransEntry.debitCreditFlag" operator="equals" value="C">
>>                                 <set from-field="acctgTransEntry.amount" field="postingAmount"/>
>> Index: applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>> ===================================================================
>> ---
>> applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (revision 727747)
>> +++ applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (working copy)
>> @@ -186,7 +186,7 @@
>>
>>                     <!-- check if the payment fully applied when set to confirmed-->
>>                     <if-compare field="parameters.statusId" operator="equals" value="PMNT_CONFIRMED">
>> -                        <set field="notYetApplied"
>> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/> +                        <set
>> field="notYetApplied" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/> <if-compare
>> field="notYetApplied" operator="greater" value="0.00">
>>                             <add-error><fail-property resource="AccountingUiLabels"
>> property="AccountingPSNotConfirmedNotFullyApplied"/></add-error>
>>                             <log level="error" message="Cannot change from ${payment.statusId} to ${parameters.statusId}, payment
>> not fully applied: ${notYetapplied}"/>
>> Index: applications/accounting/webapp/accounting/agreement/AgreementForms.xml
>> ===================================================================
>> ---
>> applications/accounting/webapp/accounting/agreement/AgreementForms.xml (revision 727747)
>> +++ applications/accounting/webapp/accounting/agreement/AgreementForms.xml (working copy)
>> @@ -334,7 +334,7 @@
>>         <field name="partyId"><hidden value="${agreement.partyIdTo}"/></field>
>>         <field name="currencyUomId"><hidden value="${agreementItem.currencyUomId}"/></field>
>>         <field name="availableFromDate" use-when="agreementProductAppl==null">
>> -            <!--<date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
>> +            <!--<date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>-->
>>             <date-time default-value="${agreement.fromDate}"/>
>>         </field>
>>         <field name="availableFromDate" use-when="agreementProductAppl!=null">
>> Index: applications/accounting/webapp/accounting/payment/PaymentForms.xml
>> ===================================================================
>> --- applications/accounting/webapp/accounting/payment/PaymentForms.xml (revision 727747)
>> +++ applications/accounting/webapp/accounting/payment/PaymentForms.xml (working copy)
>> @@ -57,7 +57,7 @@
>>             </service>
>>         </actions>
>>         <row-actions>
>> -            <set field="amountToApply"
>> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId);}"/> +            <set
>> field="amountToApply" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(delegator,paymentId)}"/>
>> </row-actions>
>>         <field name="paymentId" widget-style="buttontext">
>>             <hyperlink description="${paymentId}" target="paymentOverview?paymentId=${paymentId}"/>
>> @@ -402,7 +402,7 @@
>>             </entity-condition>
>>         </actions>
>>         <row-actions>
>> -            <set field="amountApplied"
>> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator, paymentApplicationId);}"/>
>> +            <set field="amountApplied" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedAmount(delegator,
>> paymentApplicationId)}"/>
>>         </row-actions>
>>         <auto-fields-entity entity-name="PaymentApplication" default-field-type="display"/>
>>         <field name="paymentApplicationId"><hidden/></field>
>> Index: applications/accounting/widget/BillingAccountForms.xml
>> ===================================================================
>> --- applications/accounting/widget/BillingAccountForms.xml (revision 727747)
>> +++ applications/accounting/widget/BillingAccountForms.xml (working copy)
>> @@ -133,7 +133,7 @@
>>         </field>
>>         <!--
>>         <field name="netBalance" title="${uiLabelMap.AccountingBillingNetBalance}"
>> tooltip="${uiLabelMap.AccountingBillingNetBalanceMessage}">
>> -            <display description="${bsh:org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
>> billingAccountId)}" type="currency" currency="${billingAccount.accountCurrencyUomId}"/>
>> +            <display description="${org.ofbiz.accounting.payment.BillingAccountWorker.getBillingAccountNetBalance(delegator,
>> billingAccountId)}" type="currency" currency="${billingAccount.accountCurrencyUomId}"/>
>>         </field>
>>         -->
>>         <field name="availableBalance" title="${uiLabelMap.AccountingBillingAvailableBalance}"
>> tooltip="${uiLabelMap.AccountingBillingAvailableBalanceMessage}">
>> Index: applications/accounting/widget/Menus.xml
>> ===================================================================
>> --- applications/accounting/widget/Menus.xml (revision 727747)
>> +++ applications/accounting/widget/Menus.xml (working copy)
>> @@ -292,7 +292,7 @@
>>     <menu name="PaymentSubTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml"
>>           menu-container-style="button-bar button-style-2">
>>         <actions>
>> -            <set field="isDisbursement" value="${bsh:org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/> +
>> <set field="isDisbursement" value="${org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"/> </actions>
>>         <menu-item name="createNew" title="${uiLabelMap.CommonCreateNew}">
>>             <condition>
>> Index: applications/accounting/widget/PaymentScreens.xml
>> ===================================================================
>> --- applications/accounting/widget/PaymentScreens.xml (revision 727747)
>> +++ applications/accounting/widget/PaymentScreens.xml (working copy)
>> @@ -139,7 +139,7 @@
>>                 <set field="appliedAmount" type="String" value="${bsh:
>>                     import java.text.NumberFormat;
>>
>> return(NumberFormat.getNumberInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment)));}"/>
>>  -                <set field="notAppliedAmount" type="BigDecimal"
>> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/> +                <set
>> field="notAppliedAmount" type="BigDecimal"
>> value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)}"/> <set field="notAppliedAmountStr"
>> type="String" value="${bsh:
>>                     import java.text.NumberFormat;
>>
>> return(NumberFormat.getCurrencyInstance(context.get(&quot;locale&quot;)).format(org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment)));}"/>
>> @@ -316,8 +316,8 @@
>>                 <set field="labelTitleProperty" value="PageTitlePaymentOverview"/>
>>                 <set field="paymentId" from-field="parameters.paymentId"/>
>>                 <entity-one entity-name="Payment" value-name="payment"/>
>> -                <set field="appliedAmount"
>> value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/> -                <set
>> field="notAppliedAmount" value="${bsh:org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/> +
>> <set field="appliedAmount" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentAppliedBd(payment).toString()}"/> +
>> <set field="notAppliedAmount" value="${org.ofbiz.accounting.payment.PaymentWorker.getPaymentNotAppliedBd(payment).toString()}"/>
>> </actions>
>>             <widgets>
>>                 <decorator-screen name="CommonPaymentDecorator" location="${parameters.mainDecoratorLocation}">
>> Index: applications/accounting/widget/ReportFinancialSummaryScreens.xml
>> ===================================================================
>> --- applications/accounting/widget/ReportFinancialSummaryScreens.xml (revision 727747)
>> +++ applications/accounting/widget/ReportFinancialSummaryScreens.xml (working copy)
>> @@ -27,8 +27,8 @@
>>                 <set field="titleProperty" value="PageTitleFinancialSummaryReportOptions"/>
>>                 <set field="headerItem" value="FinancialSummryReports"/>
>>
>> -                <set field="month" from-field="parameters.month"
>> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/> -                <set field="year"
>> from-field="parameters.year" default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/> +
>> <set field="month" from-field="parameters.month"
>> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/> +                <set field="year"
>> from-field="parameters.year" default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/> </actions>
>>             <widgets>
>>                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
>> @@ -100,8 +100,8 @@
>>             <actions>
>>                 <set field="headerItem" value="FinancialSummryReports"/>
>>
>> -                <set field="month" from-field="parameters.month" type="Integer"
>> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/> -                <set field="year"
>> from-field="parameters.year" type="Integer"
>> default-value="${bsh:org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/> +                <set field="month"
>> from-field="parameters.month" type="Integer" default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;MM&quot;)}"/>
>> +                <set field="year" from-field="parameters.year" type="Integer"
>> default-value="${org.ofbiz.base.util.UtilDateTime.nowDateString(&quot;yyyy&quot;)}"/> <set field="organizationPartyId"
>> from-field="parameters.organizationPartyId"/>
>>                 <set field="currencyUomId" from-field="parameters.currencyUomId"/>
>>
>> Index: applications/order/webapp/ordermgr/requirement/RequirementForms.xml
>> ===================================================================
>> --- applications/order/webapp/ordermgr/requirement/RequirementForms.xml (revision 727747)
>> +++ applications/order/webapp/ordermgr/requirement/RequirementForms.xml (working copy)
>> @@ -281,7 +281,7 @@
>>         </field>
>>         <field name="facilityId"><display/></field>
>>         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
>> -            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
>> +            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
>>         </field>
>>         <field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
>>         <field name="idValue" title="UPCA"><display/></field>
>> @@ -306,7 +306,7 @@
>>             <display-entity entity-name="Product" key-field-name="productId" description="${internalName}"/>
>>         </field>
>>         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
>> -            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
>> +            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
>>         </field>
>>         <field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
>>         <field name="idValue" title="UPCA"><display/></field>
>> @@ -335,7 +335,7 @@
>>     <form name="ApprovedProductRequirementsByVendor" type="list" use-row-submit="true" list-name="requirements"
>> target="ApprovedProductRequirements" separate-columns="true"
>>         paginate-target="ApprovedProductRequirementsByVendor" odd-row-style="alternate-row" default-table-style="basic-table
>> hover-bar">
>>         <field name="partyId">
>> -            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
>> +            <display description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false)}"/>
>>         </field>
>>         <field name="productId" title="${uiLabelMap.OrderVendorRequirementCount}" widget-area-style="align-text"><display
>> also-hidden="false"/></field>
>>         <field name="billToCustomerPartyId">
>> Index: applications/order/webapp/ordermgr/return/ReturnForms.xml
>> ===================================================================
>> --- applications/order/webapp/ordermgr/return/ReturnForms.xml (revision 727747)
>> +++ applications/order/webapp/ordermgr/return/ReturnForms.xml (working copy)
>> @@ -90,7 +90,7 @@
>>         </field>
>>         <field name="paymentMethodId" use-when="creditCardList!=null&amp;&amp;creditCardList.size()&gt;0">
>>             <drop-down allow-empty="true">
>> -                <list-options key-name="paymentMethodId" list-name="creditCardList" list-entry-name="creditCardPm"
>> description="${bsh:org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
>> +                <list-options key-name="paymentMethodId" list-name="creditCardList" list-entry-name="creditCardPm"
>> description="${org.ofbiz.party.contact.ContactHelper.formatCreditCard(creditCardPm.getRelatedOne(&quot;CreditCard&quot;))}"/>
>> </drop-down>
>>         </field>
>>         <field name="newCreditCard" widget-style="buttontext"
>> use-when="returnHeader!=null&amp;&amp;returnHeader.getString(&quot;fromPartyId&quot;)!=null"> Index:
>> applications/product/webapp/catalog/product/ProductForms.xml
>> ===================================================================
>> --- applications/product/webapp/catalog/product/ProductForms.xml (revision 727747)
>> +++ applications/product/webapp/catalog/product/ProductForms.xml (working copy)
>> @@ -701,7 +701,7 @@
>>             </drop-down>
>>         </field>
>>         <field name="availableFromDate" use-when="supplierProduct==null">
>> -            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>> +            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>>         </field>
>>         <field name="availableFromDate" use-when="supplierProduct!=null">
>>             <display/>
>> Index: applications/product/webapp/facility/facility/FacilityForms.xml
>> ===================================================================
>> --- applications/product/webapp/facility/facility/FacilityForms.xml (revision 727747)
>> +++ applications/product/webapp/facility/facility/FacilityForms.xml (working copy)
>> @@ -349,7 +349,7 @@
>>         <field name="offsetQOHQty" title="${uiLabelMap.ProductQtyOffsetQOHBelow}"><text/></field>
>>         <field name="offsetATPQty" title="${uiLabelMap.ProductQtyOffsetATPBelow}"><text/></field>
>>         <field name="productsSoldThruTimestamp" title="${uiLabelMap.ProductShowProductsSoldThruTimestamp}">
>> -            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>> +            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>>         </field>
>>         <field name="VIEW_SIZE" entry-name="viewSize" title="${uiLabelMap.ProductShowProductsPerPage}"><text/></field>
>>         <field name="monthsInPastLimit" entry-name="monthsInPastLimit"><text/></field>
>> Index: applications/workeffort/widget/WorkEffortForms.xml
>> ===================================================================
>> --- applications/workeffort/widget/WorkEffortForms.xml (revision 727747)
>> +++ applications/workeffort/widget/WorkEffortForms.xml (working copy)
>> @@ -842,7 +842,7 @@
>>            <hyperlink target="EditWorkEffort?workEffortId=${workEffortId}" also-hidden="false" description="${workEffortId}"/>
>>         </field>
>>         <field name="noteInfo" title="${uiLabelMap.CommonNote}"><display/></field>
>> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${noteDateTime}"/></field>
>> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${noteDateTime}"/></field>
>>         <field name="internalNote" title="${uiLabelMap.WorkEffortPrivatePublic}" widget-style="buttontext"
>> use-when="internalNote.equals(&quot;N&quot;)">
>>             <hyperlink target="updateWorkEffortNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
>> description="${uiLabelMap.OrderNotesPrivate}" />
>>         </field>
>> Index: framework/example/widget/example/FormWidgetExampleForms.xml
>> ===================================================================
>> --- framework/example/widget/example/FormWidgetExampleForms.xml (revision 727747)
>> +++ framework/example/widget/example/FormWidgetExampleForms.xml (working copy)
>> @@ -39,7 +39,7 @@
>>         <field name="field9"
>>                title="Field9: date and time selection field with default value"
>>                tooltip="Same as above, Uses the ${bsh: notation to call an util method to get the now timestamp}">
>> -            <date-time default-value="${bsh: org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>> +            <date-time default-value="${org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
>>         </field>
>>         <!-- ***************** -->
>>         <!-- ***   field10  *** -->
>> @@ -97,7 +97,7 @@
>>                entry-name="exampleDateField"
>>                title="Field7: date and time display with custom format"
>>                tooltip="This is an example of MM/dd/yyyy format">
>> -            <display description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField,
>> &quot;MM/dd/yyyy&quot;);}"/>
>> +            <display description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MM/dd/yyyy&quot;)}"/>
>>         </field>
>>         <!-- ***************** -->
>>         <!-- ***   field8  *** -->
>> @@ -106,7 +106,7 @@
>>                entry-name="exampleDateField"
>>                title="Field8: date and time display with custom format"
>>                tooltip="This is an example of MMMM, dd, yyyy format">
>> -            <display description="${bsh:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MMMM, dd,
>> yyyy&quot;);}"/>
>> +            <display description="${org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, &quot;MMMM, dd,
>> yyyy&quot;)}"/>
>>         </field>
>>     </form>
>>
>> Index: framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml
>> ===================================================================
>> --- framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml (revision 727747)
>> +++ framework/webtools/webapp/webtools/tempexpr/tempExprForms.xml (working copy)
>> @@ -24,7 +24,7 @@
>>     <!-- Temporal Expression forms -->
>>     <form name="FindTemporalExpression" target="findTemporalExpression" type="single">
>>         <actions>
>> -            <set field="expressionTypeList"
>> value="${bsh:org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap);}" type="List"/>
>> +            <set field="expressionTypeList"
>> value="${org.ofbiz.service.calendar.ExpressionUiHelper.getExpressionTypeList(uiLabelMap)}" type="List"/>
>>         </actions>
>>         <field name="tempExprId" title="${uiLabelMap.TemporalExpressionId}"><text-find/></field>
>> <!--        <field name="tempExprTypeId" title="${uiLabelMap.TemporalExpressionType}">
>> Index: specialpurpose/ebay/widget/EbayForms.xml
>> ===================================================================
>> --- specialpurpose/ebay/widget/EbayForms.xml (revision 727747)
>> +++ specialpurpose/ebay/widget/EbayForms.xml (working copy)
>> @@ -29,8 +29,8 @@
>>                 </entity-options>
>>             </drop-down>
>>         </field>
>> -        <field name="fromDate" title="${uiLabelMap.CommonFromDateTime}"><date-time default-value="${bsh:
>> org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field> -        <field
>> name="thruDate" title="${uiLabelMap.CommonThruDateTime}"><date-time default-value="${bsh:
>> org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field> +        <field
>> name="fromDate" title="${uiLabelMap.CommonFromDateTime}"><date-time
>> default-value="${org.ofbiz.base.util.UtilDateTime.getDayStart(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field> +
>> <field name="thruDate" title="${uiLabelMap.CommonThruDateTime}"><date-time
>> default-value="${org.ofbiz.base.util.UtilDateTime.getDayEnd(org.ofbiz.base.util.UtilDateTime.nowTimestamp())}"/></field> <field
>> name="submitButton" title="${uiLabelMap.EbayImportOrdersSearchFromEbay}"><submit button-type="button"/></field>
>>     </form>
>>     <form name="ListOrdersFromEbay" type="multi" use-row-submit="true" list-name="orderList" target="ImportOrderFromEbay"
>> Index: specialpurpose/projectmgr/widget/forms/ProjectForms.xml
>> ===================================================================
>> --- specialpurpose/projectmgr/widget/forms/ProjectForms.xml (revision 727747)
>> +++ specialpurpose/projectmgr/widget/forms/ProjectForms.xml (working copy)
>> @@ -426,7 +426,7 @@
>>             </entity-condition>
>>         </actions>
>>         <field name="workEffortId"><hidden/></field>
>> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${bsh:
>> org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
>> context.get(&quot;locale&quot;))}"/></field>
>> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at
>> ${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
>> context.get(&quot;locale&quot;))}"/></field>
>>     </form>
>>     <form name="listResourcesTasks" type="list" list-name="tasks" paginate-target="listResourcesTask"
>> target="updateResourcesTaskAssigment"
>>         odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
>> Index: specialpurpose/projectmgr/widget/forms/TaskForms.xml
>> ===================================================================
>> --- specialpurpose/projectmgr/widget/forms/TaskForms.xml (revision 727747)
>> +++ specialpurpose/projectmgr/widget/forms/TaskForms.xml (working copy)
>> @@ -442,7 +442,7 @@
>>         </actions>
>>         <field name="noteId"><hidden/></field>
>>         <field name="workEffortId"><hidden/></field>
>> -        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${bsh:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at ${bsh:
>> org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
>> context.get(&quot;locale&quot;))}"/></field>
>> +        <field name="noteParty" title="${uiLabelMap.CommonBy}"><display
>> description="${org.ofbiz.party.party.PartyHelper.getPartyName(delegator, noteParty, true)} at
>> ${org.ofbiz.base.util.UtilDateTime.timeStampToString(noteDateTime, &quot;dd-MM-yyyy HH:mm&quot;, TimeZone.getDefault(),
>> context.get(&quot;locale&quot;))}"/></field>
>>
>>         <field name="Private/Public" widget-style="buttontext" title="${uiLabelMap.ProjectMgrPrivateOrPublic}"
>> use-when="internalNote.equals(&quot;N&quot;)">
>>             <hyperlink target="updateTaskNote?workEffortId=${workEffortId}&amp;noteId=${noteId}&amp;internalNote=Y"
>> description="${uiLabelMap.OrderNotesPrivate}"></hyperlink>
>> Index: specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
>> ===================================================================
>> --- specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (revision 727747)
>> +++ specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (working copy)
>> @@ -119,7 +119,7 @@
>>             <hyperlink also-hidden="false" description="${timesheetId}" target="Timesheet?timesheetId=${timesheetId}"/>
>>         </field>
>>         <field name="partyId" title="${uiLabelMap.PartyParty}"><display-entity entity-name="PartyNameView"
>> description="${firstName} ${middleName} ${lastName} ${groupName}"/></field>
>> -        <field name="actualHours" title="${uiLabelMap.ProjectMgrActualHours}"><display description="${bsh:
>> org.ofbiz.project.Various.calculateActualHours(delegator, timesheetId);}"/></field>
>> +        <field name="actualHours" title="${uiLabelMap.ProjectMgrActualHours}"><display
>> description="${org.ofbiz.project.Various.calculateActualHours(delegator, timesheetId)}"/></field>
>>         <field name="statusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem"
>> description="${description}"/></field>
>>         <field name="fromDate" title="${uiLabelMap.CommonFromDate}"><display type="date"/></field>
>>         <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><display type="date"/></field>
>>
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Jacques,
>>>
>>> UEL supports ternary operations. So,
>>>
>>> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal + absolutePostedBalance): (debitTotal))}"
>>> type="BigDecimal"/>
>>>
>>> becomes
>>>
>>> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal + absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>>>
>>> Also, the reason for the UEL function name prefix (math: str: util:) is the same reason we have Java package names and XML
>>> namespaces - to avoid function name clash.
>>>
>>> -Adrian
>>>
>>>
>>> Jacques Le Roux wrote:
>>>> Hi Adrian,
>>>>
>>>> Is {util: syntax also dealing with ternary operator (did not look into details, doing some {bsh: to {util: changes while
>>>> changing(/adding) type from "Double" to "BigDecimal" as David suggested recently
>>>>
>>>> Thanks
>>>>
>>>> Jacques
>>>>
>>>> From: "Adrian Crum" <[hidden email]>
>>>>> Now that we have the Unified Expression Language implemented in FlexibleStringExpander, we gain the ability to use UEL
>>>>> functions.
>>>>>
>>>>> On the plus side, UEL functions can make screen widget and mini-language code more flexible and more powerful. On the minus
>>>>> side, you have to know the functions and what they do (in other words, no auto-completion when working in XML).
>>>>>
>>>>> As an example, I frequently need to know the size of a List, Map, or String. With current code, I have to use the bsh: prefix
>>>>> and a short script:
>>>>>
>>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}" type="Integer"/>.
>>>>>
>>>>> Using a UEL function:
>>>>>
>>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>>
>>>>> or to get the length of a String:
>>>>>
>>>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}" type="Integer"/>.
>>>>>
>>>>> I don't know if this would be of any use, or if it is desirable. I'm just tossing the idea out there for discussion.
>>>>>
>>>>> -Adrian
>>>>>
>>>>
>>>>
>>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

David E Jones-3
In reply to this post by Jacques Le Roux

This may be a novel idea... but you could always test them and see if  
they work or not... ;)

-David


On Dec 18, 2008, at 2:09 PM, Jacques Le Roux wrote:

> Thanks for clarification Adrian,
>
> I must admit the information in http://java.sun.com/products/jsp/reference/techart/unifiedEL.html 
>  are not quite clear :/
> I think I got most it though, is there a better reference ?
>
> I did a bunch of change. I guess now that most of them were correct,  
> but as I had a doubt I reverted them all but the one I was sure.  
> Anyway I will re-do some
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Jacques,
>>
>> UEL supports ternary operations. So,
>>
>> <set field="parameters.debitTotal" value="${bsh:(showDebit?  
>> (debitTotal
>> + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>>
>> becomes
>>
>> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
>> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>>
>> Also, the reason for the UEL function name prefix (math: str:  
>> util:) is
>> the same reason we have Java package names and XML namespaces - to  
>> avoid
>> function name clash.
>>
>> -Adrian
>>
>>
>> Jacques Le Roux wrote:
>>> Hi Adrian,
>>>
>>> Is {util: syntax also dealing with ternary operator (did not look  
>>> into
>>> details, doing some {bsh: to {util: changes while changing(/
>>> adding) type
>>> from "Double" to "BigDecimal" as David suggested recently
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Adrian Crum" <[hidden email]>
>>>> Now that we have the Unified Expression Language implemented in
>>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>>
>>>> On the plus side, UEL functions can make screen widget and
>>>> mini-language code more flexible and more powerful. On the minus  
>>>> side,
>>>> you have to know the functions and what they do (in other words, no
>>>> auto-completion when working in XML).
>>>>
>>>> As an example, I frequently need to know the size of a List, Map,  
>>>> or
>>>> String. With current code, I have to use the bsh: prefix and a  
>>>> short
>>>> script:
>>>>
>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}"  
>>>> type="Integer"/>.
>>>>
>>>> Using a UEL function:
>>>>
>>>> <set field="mapSize" value="${util:size(uiLabelMap)}"  
>>>> type="Integer"/>
>>>>
>>>> or to get the length of a String:
>>>>
>>>> <set field="stringSize" value="$
>>>> {util:size(uiLabelMap.CommonParty)}"
>>>> type="Integer"/>.
>>>>
>>>> I don't know if this would be of any use, or if it is desirable.  
>>>> I'm
>>>> just tossing the idea out there for discussion.
>>>>
>>>> -Adrian
>>>>
>>>
>>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum
In reply to this post by Jacques Le Roux
http://jcp.org/aboutJava/communityprocess/final/jsr245/

Click on one of the Download links, accept the terms, then download the
file marked:

JavaServer Pages 2.1 Expression Language Specification (pdf)

-Adrian

Jacques Le Roux wrote:

> Thanks for clarification Adrian,
>
> I must admit the information in
> http://java.sun.com/products/jsp/reference/techart/unifiedEL.html are
> not quite clear :/
> I think I got most it though, is there a better reference ?
>
> I did a bunch of change. I guess now that most of them were correct, but
> as I had a doubt I reverted them all but the one I was sure. Anyway I
> will re-do some
>
> Jacques
>
> From: "Adrian Crum" <[hidden email]>
>> Jacques,
>>
>> UEL supports ternary operations. So,
>>
>> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal
>> + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>>
>> becomes
>>
>> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
>> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>>
>> Also, the reason for the UEL function name prefix (math: str: util:) is
>> the same reason we have Java package names and XML namespaces - to avoid
>> function name clash.
>>
>> -Adrian
>>
>>
>> Jacques Le Roux wrote:
>>> Hi Adrian,
>>>
>>> Is {util: syntax also dealing with ternary operator (did not look into
>>> details, doing some {bsh: to {util: changes while changing(/adding) type
>>> from "Double" to "BigDecimal" as David suggested recently
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Adrian Crum" <[hidden email]>
>>>> Now that we have the Unified Expression Language implemented in
>>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>>
>>>> On the plus side, UEL functions can make screen widget and
>>>> mini-language code more flexible and more powerful. On the minus side,
>>>> you have to know the functions and what they do (in other words, no
>>>> auto-completion when working in XML).
>>>>
>>>> As an example, I frequently need to know the size of a List, Map, or
>>>> String. With current code, I have to use the bsh: prefix and a short
>>>> script:
>>>>
>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}"
>>>> type="Integer"/>.
>>>>
>>>> Using a UEL function:
>>>>
>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>
>>>> or to get the length of a String:
>>>>
>>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>>>> type="Integer"/>.
>>>>
>>>> I don't know if this would be of any use, or if it is desirable. I'm
>>>> just tossing the idea out there for discussion.
>>>>
>>>> -Adrian
>>>>
>>>
>>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adam Heath-2
In reply to this post by David E Jones-3
David E Jones wrote:
>
> This may be a novel idea... but you could always test them and see if
> they work or not... ;)

How about we keep the current custom parser, but then add uel as a
prefix, like ${bsh:} is, then issue warnings for strings that don't
match a prefix, giving the line number/file of the string.

I think it'd be better to not have a default language there, and always
explicitly request a particular language for interpetting.

Of course, there's one other major problem, finding the end of the
token.  Take for instance, the following String:

toProcess = "foo${bsh:\"abc\"+123+\"}\"}";

Finding the matching {} there is difficult, if you can't have a unified
parser for the multiple languages.

ps: You could say that fixing the above could be done by escaping the
internal '}'.  But then you'd have java-source-level escaping,
StringExpander-level escaping, chosen language escaping, etc, all
conflicting/overlapping with each other.

Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum
Adam Heath wrote:

> David E Jones wrote:
>> This may be a novel idea... but you could always test them and see if
>> they work or not... ;)
>
> How about we keep the current custom parser, but then add uel as a
> prefix, like ${bsh:} is, then issue warnings for strings that don't
> match a prefix, giving the line number/file of the string.
>
> I think it'd be better to not have a default language there, and always
> explicitly request a particular language for interpetting.
>
> Of course, there's one other major problem, finding the end of the
> token.  Take for instance, the following String:
>
> toProcess = "foo${bsh:\"abc\"+123+\"}\"}";
>
> Finding the matching {} there is difficult, if you can't have a unified
> parser for the multiple languages.
>
> ps: You could say that fixing the above could be done by escaping the
> internal '}'.  But then you'd have java-source-level escaping,
> StringExpander-level escaping, chosen language escaping, etc, all
> conflicting/overlapping with each other.

The home-grown parser is very limited. In the original
FlexibleMapAccessor code, it just scanned the expression for a period
and assumed any period found was a Map element delimiter. Problem is,
there could be periods anywhere in the expression that aren't Map
element delimiters.

My preference is to replace the home-grown parser with the JUEL parser -
because it is far more sophisticated and has been thoroughly tested.

I also prefer to have UEL as the default language for ${} expressions -
because it is well known, well documented, and very powerful.

-Adrian


Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

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

> Adam Heath wrote:
>> David E Jones wrote:
>>> This may be a novel idea... but you could always test them and see if
>>> they work or not... ;)
>>
>> How about we keep the current custom parser, but then add uel as a
>> prefix, like ${bsh:} is, then issue warnings for strings that don't
>> match a prefix, giving the line number/file of the string.
>>
>> I think it'd be better to not have a default language there, and always
>> explicitly request a particular language for interpetting.
>>
>> Of course, there's one other major problem, finding the end of the
>> token.  Take for instance, the following String:
>>
>> toProcess = "foo${bsh:\"abc\"+123+\"}\"}";
>>
>> Finding the matching {} there is difficult, if you can't have a unified
>> parser for the multiple languages.
>>
>> ps: You could say that fixing the above could be done by escaping the
>> internal '}'.  But then you'd have java-source-level escaping,
>> StringExpander-level escaping, chosen language escaping, etc, all
>> conflicting/overlapping with each other.
>
> The home-grown parser is very limited. In the original
> FlexibleMapAccessor code, it just scanned the expression for a period
> and assumed any period found was a Map element delimiter. Problem is,
> there could be periods anywhere in the expression that aren't Map
> element delimiters.
>
> My preference is to replace the home-grown parser with the JUEL parser -
> because it is far more sophisticated and has been thoroughly tested.
>
> I also prefer to have UEL as the default language for ${} expressions -
> because it is well known, well documented, and very powerful.

Maybe a bit enthusiast and not very well documented at this stage, but my feeling is +1

Jacques
 
> -Adrian
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Adrian Crum-2
Jacques,

Did you download that PDF file I mentioned previously? Also, there is a UEL tutorial:

http://java.sun.com/javaee/5/docs/tutorial/backup/doc/JSPIntro7.html

-Adrian


--- On Fri, 12/19/08, Jacques Le Roux <[hidden email]> wrote:

> From: Jacques Le Roux <[hidden email]>
> Subject: Re: Discussion: Unified Expression Language Functions
> To: [hidden email]
> Date: Friday, December 19, 2008, 9:27 AM
> From: "Adrian Crum" <[hidden email]>
> > Adam Heath wrote:
> >> David E Jones wrote:
> >>> This may be a novel idea... but you could
> always test them and see if
> >>> they work or not... ;)
> >>
> >> How about we keep the current custom parser, but
> then add uel as a
> >> prefix, like ${bsh:} is, then issue warnings for
> strings that don't
> >> match a prefix, giving the line number/file of the
> string.
> >>
> >> I think it'd be better to not have a default
> language there, and always
> >> explicitly request a particular language for
> interpetting.
> >>
> >> Of course, there's one other major problem,
> finding the end of the
> >> token.  Take for instance, the following String:
> >>
> >> toProcess =
> "foo${bsh:\"abc\"+123+\"}\"}";
> >>
> >> Finding the matching {} there is difficult, if you
> can't have a unified
> >> parser for the multiple languages.
> >>
> >> ps: You could say that fixing the above could be
> done by escaping the
> >> internal '}'.  But then you'd have
> java-source-level escaping,
> >> StringExpander-level escaping, chosen language
> escaping, etc, all
> >> conflicting/overlapping with each other.
> >
> > The home-grown parser is very limited. In the original
> FlexibleMapAccessor code, it just scanned the expression for
> a period and assumed any period found was a Map element
> delimiter. Problem is, there could be periods anywhere in
> the expression that aren't Map element delimiters.
> >
> > My preference is to replace the home-grown parser with
> the JUEL parser - because it is far more sophisticated and
> has been thoroughly tested.
> >
> > I also prefer to have UEL as the default language for
> ${} expressions - because it is well known, well documented,
> and very powerful.
>
> Maybe a bit enthusiast and not very well documented at this
> stage, but my feeling is +1
>
> Jacques
>
> > -Adrian
> >
> >


     
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum
Thanks Adrian,

I tried to send you a msg directly but got

This is an automatically generated Delivery Status Notification.      
Delivery to the following recipients is still underway after 20.3 hour(s):
  * [hidden email]
Will keep trying and contact you if the message can't be delivered permanently.

I suppose it's a one way address

Jacques

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

> http://jcp.org/aboutJava/communityprocess/final/jsr245/
>
> Click on one of the Download links, accept the terms, then download the
> file marked:
>
> JavaServer Pages 2.1 Expression Language Specification (pdf)
>
> -Adrian
>
> Jacques Le Roux wrote:
>> Thanks for clarification Adrian,
>>
>> I must admit the information in
>> http://java.sun.com/products/jsp/reference/techart/unifiedEL.html are
>> not quite clear :/
>> I think I got most it though, is there a better reference ?
>>
>> I did a bunch of change. I guess now that most of them were correct, but
>> as I had a doubt I reverted them all but the one I was sure. Anyway I
>> will re-do some
>>
>> Jacques
>>
>> From: "Adrian Crum" <[hidden email]>
>>> Jacques,
>>>
>>> UEL supports ternary operations. So,
>>>
>>> <set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal
>>> + absolutePostedBalance): (debitTotal))}" type="BigDecimal"/>
>>>
>>> becomes
>>>
>>> <set field="parameters.debitTotal" value="${showDebit ? (debitTotal +
>>> absolutePostedBalance) : debitTotal}" type="BigDecimal"/>
>>>
>>> Also, the reason for the UEL function name prefix (math: str: util:) is
>>> the same reason we have Java package names and XML namespaces - to avoid
>>> function name clash.
>>>
>>> -Adrian
>>>
>>>
>>> Jacques Le Roux wrote:
>>>> Hi Adrian,
>>>>
>>>> Is {util: syntax also dealing with ternary operator (did not look into
>>>> details, doing some {bsh: to {util: changes while changing(/adding) type
>>>> from "Double" to "BigDecimal" as David suggested recently
>>>>
>>>> Thanks
>>>>
>>>> Jacques
>>>>
>>>> From: "Adrian Crum" <[hidden email]>
>>>>> Now that we have the Unified Expression Language implemented in
>>>>> FlexibleStringExpander, we gain the ability to use UEL functions.
>>>>>
>>>>> On the plus side, UEL functions can make screen widget and
>>>>> mini-language code more flexible and more powerful. On the minus side,
>>>>> you have to know the functions and what they do (in other words, no
>>>>> auto-completion when working in XML).
>>>>>
>>>>> As an example, I frequently need to know the size of a List, Map, or
>>>>> String. With current code, I have to use the bsh: prefix and a short
>>>>> script:
>>>>>
>>>>> <set field="mapSize" value="${bsh:uiLabelMap.size();}"
>>>>> type="Integer"/>.
>>>>>
>>>>> Using a UEL function:
>>>>>
>>>>> <set field="mapSize" value="${util:size(uiLabelMap)}" type="Integer"/>
>>>>>
>>>>> or to get the length of a String:
>>>>>
>>>>> <set field="stringSize" value="${util:size(uiLabelMap.CommonParty)}"
>>>>> type="Integer"/>.
>>>>>
>>>>> I don't know if this would be of any use, or if it is desirable. I'm
>>>>> just tossing the idea out there for discussion.
>>>>>
>>>>> -Adrian
>>>>>
>>>>
>>>>
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Unified Expression Language Functions

Jacques Le Roux
Administrator
In reply to this post by Adrian Crum-2
Yes, thanks. See my other msg (special address)

Jacques

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

> Jacques,
>
> Did you download that PDF file I mentioned previously? Also, there is a UEL tutorial:
>
> http://java.sun.com/javaee/5/docs/tutorial/backup/doc/JSPIntro7.html
>
> -Adrian
>
>
> --- On Fri, 12/19/08, Jacques Le Roux <[hidden email]> wrote:
>
>> From: Jacques Le Roux <[hidden email]>
>> Subject: Re: Discussion: Unified Expression Language Functions
>> To: [hidden email]
>> Date: Friday, December 19, 2008, 9:27 AM
>> From: "Adrian Crum" <[hidden email]>
>> > Adam Heath wrote:
>> >> David E Jones wrote:
>> >>> This may be a novel idea... but you could
>> always test them and see if
>> >>> they work or not... ;)
>> >>
>> >> How about we keep the current custom parser, but
>> then add uel as a
>> >> prefix, like ${bsh:} is, then issue warnings for
>> strings that don't
>> >> match a prefix, giving the line number/file of the
>> string.
>> >>
>> >> I think it'd be better to not have a default
>> language there, and always
>> >> explicitly request a particular language for
>> interpetting.
>> >>
>> >> Of course, there's one other major problem,
>> finding the end of the
>> >> token.  Take for instance, the following String:
>> >>
>> >> toProcess =
>> "foo${bsh:\"abc\"+123+\"}\"}";
>> >>
>> >> Finding the matching {} there is difficult, if you
>> can't have a unified
>> >> parser for the multiple languages.
>> >>
>> >> ps: You could say that fixing the above could be
>> done by escaping the
>> >> internal '}'.  But then you'd have
>> java-source-level escaping,
>> >> StringExpander-level escaping, chosen language
>> escaping, etc, all
>> >> conflicting/overlapping with each other.
>> >
>> > The home-grown parser is very limited. In the original
>> FlexibleMapAccessor code, it just scanned the expression for
>> a period and assumed any period found was a Map element
>> delimiter. Problem is, there could be periods anywhere in
>> the expression that aren't Map element delimiters.
>> >
>> > My preference is to replace the home-grown parser with
>> the JUEL parser - because it is far more sophisticated and
>> has been thoroughly tested.
>> >
>> > I also prefer to have UEL as the default language for
>> ${} expressions - because it is well known, well documented,
>> and very powerful.
>>
>> Maybe a bit enthusiast and not very well documented at this
>> stage, but my feeling is +1
>>
>> Jacques
>>
>> > -Adrian
>> >
>> >
>
>
>      
>
12