Hi all,
I have problem of comparing two dates using use-when.I am working in a list form where a field is needed to do multiple task according to the condition set in use-when. Now i am trying to compare the startDate with the current date in another field which serves multiple purpose using use-when, but the problem is that i don't know the write syntax which serves the purpose.Could any body provide me the write syntax of doing so.I tried a groovy kind of thing (use-when="${groovy:currentDate>startDate}") which returns the value of the condition as true all the time and the purpose of use-when is not fulfilled. Eagerly waiting for the solution. With Regads Soumya |
I haven't used the groovy sysntax yet, instead I use java (actually
beanshell) syntax. In your case it should be something like: use-when="${currentDate.after(startDate)}" HTH Bilgin "N".equals(isPosted) On Tue, Nov 9, 2010 at 9:00 AM, soumya jyoti guru <[hidden email]>wrote: > Hi all, > I have problem of comparing two dates using use-when.I am > working in a list form where a field is needed to do multiple task > according to the condition set in use-when. > Now i am trying to compare the startDate with the current date > in another field which serves multiple purpose using use-when, but the > problem is that i don't know the write syntax which serves the > purpose.Could any body provide me the write syntax of doing so.I tried > a groovy kind of thing (use-when="${groovy:currentDate>startDate}") > which returns the value of the condition as true all the time and the > purpose of use-when is not fulfilled. > Eagerly waiting for the solution. > With Regads > Soumya > |
thanks for replying,
but in my case it is not working because the currentDate is in the form of timestamp and the startDate is in the form of Date-time.sorry to miss this important details in my earlier question. Thanks again, for replying back.Please reply back if there is any other way out. On Tue, Nov 9, 2010 at 2:58 PM, Bilgin Ibryam <[hidden email]> wrote: > I haven't used the groovy sysntax yet, instead I use java (actually > beanshell) syntax. > In your case it should be something like: > > use-when="${currentDate.after(startDate)}" > > HTH > Bilgin > > "N".equals(isPosted) > > On Tue, Nov 9, 2010 at 9:00 AM, soumya jyoti guru <[hidden email]>wrote: > >> Hi all, >> I have problem of comparing two dates using use-when.I am >> working in a list form where a field is needed to do multiple task >> according to the condition set in use-when. >> Now i am trying to compare the startDate with the current date >> in another field which serves multiple purpose using use-when, but the >> problem is that i don't know the write syntax which serves the >> purpose.Could any body provide me the write syntax of doing so.I tried >> a groovy kind of thing (use-when="${groovy:currentDate>startDate}") >> which returns the value of the condition as true all the time and the >> purpose of use-when is not fulfilled. >> Eagerly waiting for the solution. >> With Regads >> Soumya >> > |
On Tue, Nov 9, 2010 at 9:58 AM, soumya jyoti guru <[hidden email]>wrote:
> thanks for replying, > but in my case it is not working because > the currentDate is in the form of timestamp and the startDate is in > the form of Date-time.sorry to miss this important details in my > earlier question. > Thanks again, for replying back.Please > reply back if there is any other way out. > > You can do the conversion from date to timestamp first and then compare. Conversion can be done inside use-when, or you can add a row-actions and prepare your data there (this actions will be executed once for each row) There might/should be a better way to do this using groovy though Bilgin |
Hi soumya ,
There are examples available in in the Example components for the same purpose , please take a look in example forms. HTH Ravindra Mandre On Tue, Nov 9, 2010 at 4:02 PM, Bilgin Ibryam <[hidden email]> wrote: > On Tue, Nov 9, 2010 at 9:58 AM, soumya jyoti guru <[hidden email] > >wrote: > > > thanks for replying, > > but in my case it is not working because > > the currentDate is in the form of timestamp and the startDate is in > > the form of Date-time.sorry to miss this important details in my > > earlier question. > > Thanks again, for replying back.Please > > reply back if there is any other way out. > > > > > You can do the conversion from date to timestamp first and then compare. > Conversion can be done inside use-when, or you can add a row-actions and > prepare your data there (this actions will be executed once for each row) > > There might/should be a better way to do this using groovy though > > Bilgin > |
In reply to this post by Bilgin Ibryam-2
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) |
Remove the $ and curly brackets.
-Adrian --- On Sun, 12/5/10, Shereen <[hidden email]> wrote: > From: Shereen <[hidden email]> > Subject: Re: comparing two dates using use-when > To: [hidden email] > 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. > |
you may also try following if your problem did solved.
"Periodic Mass Load".equals(productStatus) HTH Ravindra Mandre Bangalore On Sun, Dec 5, 2010 at 10:10 PM, Adrian Crum <[hidden email]> wrote: > Remove the $ and curly brackets. > > -Adrian > > --- On Sun, 12/5/10, Shereen <[hidden email]> wrote: > > > From: Shereen <[hidden email]> > > Subject: Re: comparing two dates using use-when > > To: [hidden email] > > 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. > > > > > > |
Thanks a lot for your replies
Unfortunately both solutions didn't work for me Any more suggestions? |
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 <[hidden email]> 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. > |
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? |
Administrator
|
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 & ' > < " instead of & " > < '. You should find enough examples OOTB. Adrian suggested to use an UEL functions, I never tried that Jacques From: "Shereen" <[hidden email]> > 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. > |
Free forum by Nabble | Edit this page |