You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Shereen <sh...@hotmail.com> on 2010/12/05 15:54:46 UTC

Re: comparing two dates using use-when

Hi All
Please all I need help on using the use-when attribute
I've made a product status field in the form and I want to check for that
field this field s string and I can't use use- when with strings
what I have done is this:
        <actions>
        <set field="productStatus" value="product.ProductStatusId"/>
        </actions>
This was to store the status of the product

this is to change target when the status equals "Periodic Mass Load"
        <alt-target use-when="${productStatus.equals('Periodic Mass Load')}"
target="updateProductChangeStatusPeriodicMassReady"/>

this is a submit button I want to use also if the status matches this value
"Periodic Mass Load"

	    <field name="submitButton" title="Periodic Mass Ready"
use-when="${productStatus.equals('Periodic Mass Load')}"
widget-style="smallSubmit"><submit button-type="button"/></field>

anyone can help or give me a link to read?
I duno how to check strings. I tried to remove spaces but the problem
remains te same.
Instead of single quotes I put double quote and the same problem remains

here's the exception

  at java.lang.Thread.run(Thread.java:619)
2010-12-05 16:38:17,127 (http-0.0.0.0-8443-2)
[FlexibleStringExpander.java:692:ERROR] Error evaluating expression
${productStatus.equals('Periodic Mass Load')}: javax.el.ELException: Error
parsing '${productStatus.equals('Periodic Mass Load')}': syntax error at
position 22, encountered '(', expected '}'
2010-12-05 16:38:17,157 (http-0.0.0.0-8443-2)
[StandardWrapperValve.java:274:ERROR] Servlet.service() for servlet
ControlServlet threw exception
bsh.TokenMgrError: Lexical error at line 1, column 26.  Encountered: "e"
(101), after : "\'P"
        at bsh.ParserTokenManager.getNextToken(Unknown Source)
        at bsh.Parser.jj_scan_token(Unknown Source)
        at bsh.Parser.jj_3R_138(Unknown Source)
        at bsh.Parser.jj_3R_129(Unknown Source)
        at bsh.Parser.jj_3R_98(Unknown Source)
        at bsh.Parser.jj_3R_57(Unknown Source)
        at bsh.Parser.jj_3R_33(Unknown Source)
        at bsh.Parser.jj_3R_107(Unknown Source)
        at bsh.Parser.jj_3R_70(Unknown Source)
        at bsh.Parser.jj_3R_39(Unknown Source)
        at bsh.Parser.jj_3R_134(Unknown Source)
        at bsh.Parser.jj_3R_106(Unknown Source)
        at bsh.Parser.jj_3R_69(Unknown Source)
        at bsh.Parser.jj_3R_37(Unknown Source)
        at bsh.Parser.jj_3R_101(Unknown Source)
        at bsh.Parser.jj_3R_57(Unknown Source)
        at bsh.Parser.jj_3R_33(Unknown Source)
        at bsh.Parser.jj_3R_107(Unknown Source)
        at bsh.Parser.jj_3R_70(Unknown Source)
        at bsh.Parser.jj_3R_39(Unknown Source)
        at bsh.Parser.jj_3R_133(Unknown Source)
        at bsh.Parser.jj_3R_104(Unknown Source)
        at bsh.Parser.jj_3R_58(Unknown Source)
        at bsh.Parser.jj_3R_33(Unknown Source)
        at bsh.Parser.jj_3_8(Unknown Source)
        at bsh.Parser.jj_2_8(Unknown Source)
        at bsh.Parser.Expression(Unknown Source)
        at bsh.Parser.StatementExpression(Unknown Source)
        at bsh.Parser.Statement(Unknown Source)
        at bsh.Parser.BlockStatement(Unknown Source)
        at bsh.Parser.Line(Unknown Source)
        at bsh.Interpreter.parseScript(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at org.ofbiz.widget.form.ModelForm.getTarget(ModelForm.java:1967)
        at
org.ofbiz.widget.form.MacroFormRenderer.renderFormOpen(MacroFormRenderer.java:1237)
        at
org.ofbiz.widget.form.ModelForm.renderSingleFormString(ModelForm.java:879)
        at
org.ofbiz.widget.form.ModelForm.renderFormString(ModelForm.java:837)
        at
org.ofbiz.widget.screen.ModelScreenWidget$Form.renderWidgetString(ModelScreenWidget.java:840)



-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3073306.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: comparing two dates using use-when

Posted by Jacques Le Roux <ja...@les7arts.com>.
You must put actions before al-target (if you use an XML content aware editor you should see that). You can use use-when in an 
alt-target.

Unfortunatley due to some inconsistence still in OFBiz, when you use use-when you actually use underneath a BSH syntax and not a 
Groovy syntax. So inside the use-when expression you need to use &amp; &apos; &gt; &lt; &quot; instead of & " > < '.
You should find enough examples OOTB. 

Adrian suggested to use an UEL functions, I never tried that

Jacques

From: "Shereen" <sh...@hotmail.com>
> It seem I don't have enough infoirmation about use-when attribute. does
> anyone have?
> everything goes right when I use it to check if something is null or not but
> when I do further checking it deosn't go right
> the use-when is widely used in ofbiz to check if something is null or not or
> the map in the conext is null or not
> but what I want to do now is to check if the productStatus equals certain
> value or not and the checking always gives me negative answer
> something strange happens as well
> <form name="EditProduct" type="single" target="updateProduct" title=""
> default-map-name="product"
>        header-row-style="header-row" default-table-style="basic-table">
>        <actions>
>       <set field="productStatus"
> from-field="product.productStatusId"></set>
>        </actions>
> when I go to print the productStatus it doesn't print the status it's not
> null but prints nothing on the screen I put the actions before alt-target
> because I'll need it to decide which target shall i go to.
> Am I putting the actions in a wrong place?
> does anyone have any suggestion to use different submit buttons and
> different targets based on product status?
>
> -- 
> View this message in context: http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3077804.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
> 



Re: comparing two dates using use-when

Posted by Shereen <sh...@hotmail.com>.
It seem I don't have enough infoirmation about use-when attribute. does
anyone have?
everything goes right when I use it to check if something is null or not but
when I do further checking it deosn't go right
the use-when is widely used in ofbiz to check if something is null or not or
the map in the conext is null or not
but what I want to do now is to check if the productStatus equals certain
value or not and the checking always gives me negative answer
something strange happens as well
<form name="EditProduct" type="single" target="updateProduct" title=""
default-map-name="product"
        header-row-style="header-row" default-table-style="basic-table">
        <actions>
       <set field="productStatus"
from-field="product.productStatusId"></set>
        </actions>
when I go to print the productStatus it doesn't print the status it's not
null but prints nothing on the screen I put the actions before alt-target
because I'll need it to decide which target shall i go to.
Am I putting the actions in a wrong place?
does anyone have any suggestion to use different submit buttons and
different targets based on product status?

-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3077804.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: comparing two dates using use-when

Posted by Ravindra Mandre <ra...@gmail.com>.
above solution given to you worked for me.
I dont know why did not worked for you :-(


Ravindra Mandre


On Mon, Dec 6, 2010 at 12:40 PM, Shereen <sh...@hotmail.com> wrote:

>
> Thanks a lot for your replies
> Unfortunately both solutions didn't work for me
> Any more suggestions?
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3074040.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Re: comparing two dates using use-when

Posted by Shereen <sh...@hotmail.com>.
Thanks a lot for your replies
Unfortunately both solutions didn't work for me
Any more suggestions?
-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3074040.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: comparing two dates using use-when

Posted by Ravindra Mandre <ra...@gmail.com>.
you may also try following if your problem did solved.

&quot;Periodic Mass Load&quot;.equals(productStatus)


HTH

Ravindra Mandre
Bangalore



On Sun, Dec 5, 2010 at 10:10 PM, Adrian Crum <ad...@yahoo.com> wrote:

> Remove the $ and curly brackets.
>
> -Adrian
>
> --- On Sun, 12/5/10, Shereen <sh...@hotmail.com> wrote:
>
> > From: Shereen <sh...@hotmail.com>
> > Subject: Re: comparing two dates using use-when
> > To: user@ofbiz.apache.org
> > Date: Sunday, December 5, 2010, 6:54 AM
> >
> > Hi All
> > Please all I need help on using the use-when attribute
> > I've made a product status field in the form and I want to
> > check for that
> > field this field s string and I can't use use- when with
> > strings
> > what I have done is this:
> >         <actions>
> >         <set field="productStatus"
> > value="product.ProductStatusId"/>
> >         </actions>
> > This was to store the status of the product
> >
> > this is to change target when the status equals "Periodic
> > Mass Load"
> >         <alt-target
> > use-when="${productStatus.equals('Periodic Mass Load')}"
> > target="updateProductChangeStatusPeriodicMassReady"/>
> >
> > this is a submit button I want to use also if the status
> > matches this value
> > "Periodic Mass Load"
> >
> >         <field
> > name="submitButton" title="Periodic Mass Ready"
> > use-when="${productStatus.equals('Periodic Mass Load')}"
> > widget-style="smallSubmit"><submit
> > button-type="button"/></field>
> >
> > anyone can help or give me a link to read?
> > I duno how to check strings. I tried to remove spaces but
> > the problem
> > remains te same.
> > Instead of single quotes I put double quote and the same
> > problem remains
> >
> > here's the exception
> >
> >   at java.lang.Thread.run(Thread.java:619)
> > 2010-12-05 16:38:17,127 (http-0.0.0.0-8443-2)
> > [FlexibleStringExpander.java:692:ERROR] Error evaluating
> > expression
> > ${productStatus.equals('Periodic Mass Load')}:
> > javax.el.ELException: Error
> > parsing '${productStatus.equals('Periodic Mass Load')}':
> > syntax error at
> > position 22, encountered '(', expected '}'
> > 2010-12-05 16:38:17,157 (http-0.0.0.0-8443-2)
> > [StandardWrapperValve.java:274:ERROR] Servlet.service() for
> > servlet
> > ControlServlet threw exception
> > bsh.TokenMgrError: Lexical error at line 1, column
> > 26.  Encountered: "e"
> > (101), after : "\'P"
> >         at
> > bsh.ParserTokenManager.getNextToken(Unknown Source)
> >         at
> > bsh.Parser.jj_scan_token(Unknown Source)
> >         at bsh.Parser.jj_3R_138(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_129(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_98(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_57(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_33(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_107(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_70(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_39(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_134(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_106(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_69(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_37(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_101(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_57(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_33(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_107(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_70(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_39(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_133(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_104(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_58(Unknown
> > Source)
> >         at bsh.Parser.jj_3R_33(Unknown
> > Source)
> >         at bsh.Parser.jj_3_8(Unknown
> > Source)
> >         at bsh.Parser.jj_2_8(Unknown
> > Source)
> >         at
> > bsh.Parser.Expression(Unknown Source)
> >         at
> > bsh.Parser.StatementExpression(Unknown Source)
> >         at bsh.Parser.Statement(Unknown
> > Source)
> >         at
> > bsh.Parser.BlockStatement(Unknown Source)
> >         at bsh.Parser.Line(Unknown
> > Source)
> >         at
> > bsh.Interpreter.parseScript(Unknown Source)
> >         at bsh.Interpreter.eval(Unknown
> > Source)
> >         at bsh.Interpreter.eval(Unknown
> > Source)
> >         at bsh.Interpreter.eval(Unknown
> > Source)
> >         at
> > org.ofbiz.widget.form.ModelForm.getTarget(ModelForm.java:1967)
> >         at
> >
> org.ofbiz.widget.form.MacroFormRenderer.renderFormOpen(MacroFormRenderer.java:1237)
> >         at
> >
> org.ofbiz.widget.form.ModelForm.renderSingleFormString(ModelForm.java:879)
> >         at
> > org.ofbiz.widget.form.ModelForm.renderFormString(ModelForm.java:837)
> >         at
> >
> org.ofbiz.widget.screen.ModelScreenWidget$Form.renderWidgetString(ModelScreenWidget.java:840)
> >
> >
> >
> > --
> > View this message in context:
> http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3073306.html
> > Sent from the OFBiz - User mailing list archive at
> > Nabble.com.
> >
>
>
>
>

Re: comparing two dates using use-when

Posted by Adrian Crum <ad...@yahoo.com>.
Remove the $ and curly brackets.

-Adrian

--- On Sun, 12/5/10, Shereen <sh...@hotmail.com> wrote:

> From: Shereen <sh...@hotmail.com>
> Subject: Re: comparing two dates using use-when
> To: user@ofbiz.apache.org
> Date: Sunday, December 5, 2010, 6:54 AM
> 
> Hi All
> Please all I need help on using the use-when attribute
> I've made a product status field in the form and I want to
> check for that
> field this field s string and I can't use use- when with
> strings
> what I have done is this:
>         <actions>
>         <set field="productStatus"
> value="product.ProductStatusId"/>
>         </actions>
> This was to store the status of the product
> 
> this is to change target when the status equals "Periodic
> Mass Load"
>         <alt-target
> use-when="${productStatus.equals('Periodic Mass Load')}"
> target="updateProductChangeStatusPeriodicMassReady"/>
> 
> this is a submit button I want to use also if the status
> matches this value
> "Periodic Mass Load"
> 
>         <field
> name="submitButton" title="Periodic Mass Ready"
> use-when="${productStatus.equals('Periodic Mass Load')}"
> widget-style="smallSubmit"><submit
> button-type="button"/></field>
> 
> anyone can help or give me a link to read?
> I duno how to check strings. I tried to remove spaces but
> the problem
> remains te same.
> Instead of single quotes I put double quote and the same
> problem remains
> 
> here's the exception
> 
>   at java.lang.Thread.run(Thread.java:619)
> 2010-12-05 16:38:17,127 (http-0.0.0.0-8443-2)
> [FlexibleStringExpander.java:692:ERROR] Error evaluating
> expression
> ${productStatus.equals('Periodic Mass Load')}:
> javax.el.ELException: Error
> parsing '${productStatus.equals('Periodic Mass Load')}':
> syntax error at
> position 22, encountered '(', expected '}'
> 2010-12-05 16:38:17,157 (http-0.0.0.0-8443-2)
> [StandardWrapperValve.java:274:ERROR] Servlet.service() for
> servlet
> ControlServlet threw exception
> bsh.TokenMgrError: Lexical error at line 1, column
> 26.  Encountered: "e"
> (101), after : "\'P"
>         at
> bsh.ParserTokenManager.getNextToken(Unknown Source)
>         at
> bsh.Parser.jj_scan_token(Unknown Source)
>         at bsh.Parser.jj_3R_138(Unknown
> Source)
>         at bsh.Parser.jj_3R_129(Unknown
> Source)
>         at bsh.Parser.jj_3R_98(Unknown
> Source)
>         at bsh.Parser.jj_3R_57(Unknown
> Source)
>         at bsh.Parser.jj_3R_33(Unknown
> Source)
>         at bsh.Parser.jj_3R_107(Unknown
> Source)
>         at bsh.Parser.jj_3R_70(Unknown
> Source)
>         at bsh.Parser.jj_3R_39(Unknown
> Source)
>         at bsh.Parser.jj_3R_134(Unknown
> Source)
>         at bsh.Parser.jj_3R_106(Unknown
> Source)
>         at bsh.Parser.jj_3R_69(Unknown
> Source)
>         at bsh.Parser.jj_3R_37(Unknown
> Source)
>         at bsh.Parser.jj_3R_101(Unknown
> Source)
>         at bsh.Parser.jj_3R_57(Unknown
> Source)
>         at bsh.Parser.jj_3R_33(Unknown
> Source)
>         at bsh.Parser.jj_3R_107(Unknown
> Source)
>         at bsh.Parser.jj_3R_70(Unknown
> Source)
>         at bsh.Parser.jj_3R_39(Unknown
> Source)
>         at bsh.Parser.jj_3R_133(Unknown
> Source)
>         at bsh.Parser.jj_3R_104(Unknown
> Source)
>         at bsh.Parser.jj_3R_58(Unknown
> Source)
>         at bsh.Parser.jj_3R_33(Unknown
> Source)
>         at bsh.Parser.jj_3_8(Unknown
> Source)
>         at bsh.Parser.jj_2_8(Unknown
> Source)
>         at
> bsh.Parser.Expression(Unknown Source)
>         at
> bsh.Parser.StatementExpression(Unknown Source)
>         at bsh.Parser.Statement(Unknown
> Source)
>         at
> bsh.Parser.BlockStatement(Unknown Source)
>         at bsh.Parser.Line(Unknown
> Source)
>         at
> bsh.Interpreter.parseScript(Unknown Source)
>         at bsh.Interpreter.eval(Unknown
> Source)
>         at bsh.Interpreter.eval(Unknown
> Source)
>         at bsh.Interpreter.eval(Unknown
> Source)
>         at
> org.ofbiz.widget.form.ModelForm.getTarget(ModelForm.java:1967)
>         at
> org.ofbiz.widget.form.MacroFormRenderer.renderFormOpen(MacroFormRenderer.java:1237)
>         at
> org.ofbiz.widget.form.ModelForm.renderSingleFormString(ModelForm.java:879)
>         at
> org.ofbiz.widget.form.ModelForm.renderFormString(ModelForm.java:837)
>         at
> org.ofbiz.widget.screen.ModelScreenWidget$Form.renderWidgetString(ModelScreenWidget.java:840)
> 
> 
> 
> -- 
> View this message in context: http://ofbiz.135035.n4.nabble.com/comparing-two-dates-using-use-when-tp3033336p3073306.html
> Sent from the OFBiz - User mailing list archive at
> Nabble.com.
>