How is request passed to groovy scripts?

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

How is request passed to groovy scripts?

Ritesh Trivedi
Hi,

I am trying to call sendEmailFromScreen for a custom screen very similar to EmailOrderScreens, the groovy script is one of the existing ones ShopCart.groovy. sendEmailFromScreen service throws an exception groovy - property request not found for class ShopCart.

I looked at similar code in e-commerce etc for sending email e.g. OrderConfirmEmail - I dont see any difference in 2 calls.

Will appreciate any pointers...
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

BJ Freeman
groovy does not have anything to do with calling a service.
that is done thru the target and the controller.
grovvy is used to marshal and manipulate data for display or sending in
context to services.
review
http://docs.ofbiz.org/display/OFBTECH/Framework+Introduction+Videos+and+Diagrams
all videos specifically #7

Ritesh Trivedi wrote:

> Hi,
>
> I am trying to call sendEmailFromScreen for a custom screen very similar to
> EmailOrderScreens, the groovy script is one of the existing ones
> ShopCart.groovy. sendEmailFromScreen service throws an exception groovy -
> property request not found for class ShopCart.
>
> I looked at similar code in e-commerce etc for sending email e.g.
> OrderConfirmEmail - I dont see any difference in 2 calls.
>
> Will appreciate any pointers...
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

BJ Freeman
take a look at the ProductStoreEmailSetting
data in the
application/ecommerce/data/demoproducts.xml
for examples of screens being used for this service.
if you look at the service
sendMailFromScreen
you will see what is needed.
if you look at
component://party/widget/partymgr/EmailPartyScreens.xml#CreatePartyNotification
you will see an example of a screen that is passed



[hidden email] wrote:

> groovy does not have anything to do with calling a service.
> that is done thru the target and the controller.
> grovvy is used to marshal and manipulate data for display or sending in
> context to services.
> review
> http://docs.ofbiz.org/display/OFBTECH/Framework+Introduction+Videos+and+Diagrams 
>
> all videos specifically #7
>
> Ritesh Trivedi wrote:
>> Hi,
>>
>> I am trying to call sendEmailFromScreen for a custom screen very
>> similar to
>> EmailOrderScreens, the groovy script is one of the existing ones
>> ShopCart.groovy. sendEmailFromScreen service throws an exception groovy -
>> property request not found for class ShopCart.
>> I looked at similar code in e-commerce etc for sending email e.g.
>> OrderConfirmEmail - I dont see any difference in 2 calls.
>>
>> Will appreciate any pointers...
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

Ravindra Mandre-2
In reply to this post by BJ Freeman
Hi ,
I am not confirm but let you check this that whether you set property for
your groovy file or not. and So then please post your console or screen
error in mail.


Regards
Ravindra Mandre
Indore
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

Ritesh Trivedi
I guess I could have been bit more clear in asking the question...

I actually meant request object (HttpServletRequest) passed to the groovy script. As it seems like its an implicit object or getting passed somehow that I cant figure out.

I will try to be more explicit. I am calling sendEmailFromScreen service and passing it one of the screen names.  

Here is the screen definition
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd">
    <screen name="EmailFullCart">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleShoppingCart"/>
                <set field="headerItem" value="Shopping Cart"/>
                <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy"/>
                <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowPromoText.groovy"/>
            </actions>
            <widgets>
                <platform-specific><html><html-template location="component://neobits/webapp/neobits/cart/showcart.ftl"/></html></platform-specific>
            </widgets>
        </section>
    </screen>
</screens>

As you can see one of the actions is ShowCart.groovy which is an existing groovy script in ecommerce demo app and here is the first line of that script

// Get the Cart and Prepare Size
shoppingCart = ShoppingCartEvents.getCartObject(request);

I get request property not set for ShowCart error while passing this screen to be rendered with sendMailFromScreen from my java code.

So my original question was how is request object passed to Groovy script, Looking at the existing calls it doesnt look like it is passed in the context while calling the service or is it done by ServiceEventHandler. Can someone more familiar with the topic shed some light?

King-of-mabs wrote
Hi ,
I am not confirm but let you check this that whether you set property for
your groovy file or not. and So then please post your console or screen
error in mail.


Regards
Ravindra Mandre
Indore
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

BJ Freeman
have you looked at the confirmed order email.
seems your duplicating it function.

Ritesh Trivedi wrote:

> I guess I could have been bit more clear in asking the question...
>
> I actually meant request object (HttpServletRequest) passed to the groovy
> script. As it seems like its an implicit object or getting passed somehow
> that I cant figure out.
>
> I will try to be more explicit. I am calling sendEmailFromScreen service and
> passing it one of the screen names.  
>
> Here is the screen definition
> <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        
> xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd">
>     <screen name="EmailFullCart">
>         <section>
>             <actions>
>                 <set field="titleProperty" value="PageTitleShoppingCart"/>
>                 <set field="headerItem" value="Shopping Cart"/>
>                 <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy"/>
>                 <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowPromoText.groovy"/>
>             </actions>
>             <widgets>
>                 <platform-specific><html><html-template
> location="component://neobits/webapp/neobits/cart/showcart.ftl"/></html></platform-specific>
>             </widgets>
>         </section>
>     </screen>
> </screens>
>
> As you can see one of the actions is ShowCart.groovy which is an existing
> groovy script in ecommerce demo app and here is the first line of that
> script
>
> // Get the Cart and Prepare Size
> shoppingCart = ShoppingCartEvents.getCartObject(request);
>
> I get request property not set for ShowCart error while passing this screen
> to be rendered with sendMailFromScreen from my java code.
>
> So my original question was how is request object passed to Groovy script,
> Looking at the existing calls it doesnt look like it is passed in the
> context while calling the service or is it done by ServiceEventHandler. Can
> someone more familiar with the topic shed some light?
>
>
> King-of-mabs wrote:
>> Hi ,
>> I am not confirm but let you check this that whether you set property for
>> your groovy file or not. and So then please post your console or screen
>> error in mail.
>>
>>
>> Regards
>> Ravindra Mandre
>> Indore
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

Joe Eckard
In reply to this post by Ritesh Trivedi
Check the populateContextForRequest method in /framework/widget/src/
org/ofbiz/widget/screen/ScreenRenderer.java, I believe this is what  
you're looking for.

-Joe

On Oct 4, 2008, at 1:43 AM, Ritesh Trivedi wrote:

>
> I guess I could have been bit more clear in asking the question...
>
> I actually meant request object (HttpServletRequest) passed to the  
> groovy
> script. As it seems like its an implicit object or getting passed  
> somehow
> that I cant figure out.
>
> I will try to be more explicit. I am calling sendEmailFromScreen  
> service and
> passing it one of the screen names.
>
> Here is the screen definition
> <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd 
> ">
>    <screen name="EmailFullCart">
>        <section>
>            <actions>
>                <set field="titleProperty"  
> value="PageTitleShoppingCart"/>
>                <set field="headerItem" value="Shopping Cart"/>
>                <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
> cart/ShowCart.groovy"/>
>                <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
> cart/ShowPromoText.groovy"/>
>            </actions>
>            <widgets>
>                <platform-specific><html><html-template
> location="component://neobits/webapp/neobits/cart/showcart.ftl"/></
> html></platform-specific>
>            </widgets>
>        </section>
>    </screen>
> </screens>
>
> As you can see one of the actions is ShowCart.groovy which is an  
> existing
> groovy script in ecommerce demo app and here is the first line of that
> script
>
> // Get the Cart and Prepare Size
> shoppingCart = ShoppingCartEvents.getCartObject(request);
>
> I get request property not set for ShowCart error while passing this  
> screen
> to be rendered with sendMailFromScreen from my java code.
>
> So my original question was how is request object passed to Groovy  
> script,
> Looking at the existing calls it doesnt look like it is passed in the
> context while calling the service or is it done by  
> ServiceEventHandler. Can
> someone more familiar with the topic shed some light?
>
>
> King-of-mabs wrote:
>>
>> Hi ,
>> I am not confirm but let you check this that whether you set  
>> property for
>> your groovy file or not. and So then please post your console or  
>> screen
>> error in mail.
>>
>>
>> Regards
>> Ravindra Mandre
>> Indore
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-is-request-passed-to-groovy-scripts--tp19808550p19809275.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

Ritesh Trivedi
Joe,

Thanks for pointing that out - but sendMailFromScreen is not calling that method, it calls the populateContextForService method. OrderConfirmEmail actually gets sent from service (OrderServices.java) and yet the groovy script in OrderStatus uses request object without any errors. So it seems that someone is passing request object explicity as bodyParameter but I cant find it.


Joe Eckard wrote
Check the populateContextForRequest method in /framework/widget/src/
org/ofbiz/widget/screen/ScreenRenderer.java, I believe this is what  
you're looking for.

-Joe

On Oct 4, 2008, at 1:43 AM, Ritesh Trivedi wrote:

>
> I guess I could have been bit more clear in asking the question...
>
> I actually meant request object (HttpServletRequest) passed to the  
> groovy
> script. As it seems like its an implicit object or getting passed  
> somehow
> that I cant figure out.
>
> I will try to be more explicit. I am calling sendEmailFromScreen  
> service and
> passing it one of the screen names.
>
> Here is the screen definition
> <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd 
> ">
>    <screen name="EmailFullCart">
>        <section>
>            <actions>
>                <set field="titleProperty"  
> value="PageTitleShoppingCart"/>
>                <set field="headerItem" value="Shopping Cart"/>
>                <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
> cart/ShowCart.groovy"/>
>                <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
> cart/ShowPromoText.groovy"/>
>            </actions>
>            <widgets>
>                <platform-specific><html><html-template
> location="component://neobits/webapp/neobits/cart/showcart.ftl"/></
> html></platform-specific>
>            </widgets>
>        </section>
>    </screen>
> </screens>
>
> As you can see one of the actions is ShowCart.groovy which is an  
> existing
> groovy script in ecommerce demo app and here is the first line of that
> script
>
> // Get the Cart and Prepare Size
> shoppingCart = ShoppingCartEvents.getCartObject(request);
>
> I get request property not set for ShowCart error while passing this  
> screen
> to be rendered with sendMailFromScreen from my java code.
>
> So my original question was how is request object passed to Groovy  
> script,
> Looking at the existing calls it doesnt look like it is passed in the
> context while calling the service or is it done by  
> ServiceEventHandler. Can
> someone more familiar with the topic shed some light?
>
>
> King-of-mabs wrote:
>>
>> Hi ,
>> I am not confirm but let you check this that whether you set  
>> property for
>> your groovy file or not. and So then please post your console or  
>> screen
>> error in mail.
>>
>>
>> Regards
>> Ravindra Mandre
>> Indore
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-is-request-passed-to-groovy-scripts--tp19808550p19809275.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.


 
Reply | Threaded
Open this post in threaded view
|

Re: How is request passed to groovy scripts?

BJ Freeman
orderservices.java
calls
sendOrderNotificationScreen with a type like PRDS_ODR_CONFIRM
sendOrderNotificationScreen  lookes up in the ProductStoreEmails
https://demo.hotwaxmedia.com/webtools/control/FindGeneric?entityName=ProductStoreEmailSetting&find=true&VIEW_SIZE=50&VIEW_INDEX=0

I could not find the OrderStatus.groovy
however
SendConfirmationEmail.groovy
does the same thing that orderservices.java does



Ritesh Trivedi wrote:

> Joe,
>
> Thanks for pointing that out - but sendMailFromScreen is not calling that
> method, it calls the populateContextForService method. OrderConfirmEmail
> actually gets sent from service (OrderServices.java) and yet the groovy
> script in OrderStatus uses request object without any errors. So it seems
> that someone is passing request object explicity as bodyParameter but I cant
> find it.
>
>
>
> Joe Eckard wrote:
>> Check the populateContextForRequest method in /framework/widget/src/
>> org/ofbiz/widget/screen/ScreenRenderer.java, I believe this is what  
>> you're looking for.
>>
>> -Joe
>>
>> On Oct 4, 2008, at 1:43 AM, Ritesh Trivedi wrote:
>>
>>> I guess I could have been bit more clear in asking the question...
>>>
>>> I actually meant request object (HttpServletRequest) passed to the  
>>> groovy
>>> script. As it seems like its an implicit object or getting passed  
>>> somehow
>>> that I cant figure out.
>>>
>>> I will try to be more explicit. I am calling sendEmailFromScreen  
>>> service and
>>> passing it one of the screen names.
>>>
>>> Here is the screen definition
>>> <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>
>>> xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd 
>>> ">
>>>    <screen name="EmailFullCart">
>>>        <section>
>>>            <actions>
>>>                <set field="titleProperty"  
>>> value="PageTitleShoppingCart"/>
>>>                <set field="headerItem" value="Shopping Cart"/>
>>>                <script
>>> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
>>> cart/ShowCart.groovy"/>
>>>                <script
>>> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/
>>> cart/ShowPromoText.groovy"/>
>>>            </actions>
>>>            <widgets>
>>>                <platform-specific><html><html-template
>>> location="component://neobits/webapp/neobits/cart/showcart.ftl"/></
>>> html></platform-specific>
>>>            </widgets>
>>>        </section>
>>>    </screen>
>>> </screens>
>>>
>>> As you can see one of the actions is ShowCart.groovy which is an  
>>> existing
>>> groovy script in ecommerce demo app and here is the first line of that
>>> script
>>>
>>> // Get the Cart and Prepare Size
>>> shoppingCart = ShoppingCartEvents.getCartObject(request);
>>>
>>> I get request property not set for ShowCart error while passing this  
>>> screen
>>> to be rendered with sendMailFromScreen from my java code.
>>>
>>> So my original question was how is request object passed to Groovy  
>>> script,
>>> Looking at the existing calls it doesnt look like it is passed in the
>>> context while calling the service or is it done by  
>>> ServiceEventHandler. Can
>>> someone more familiar with the topic shed some light?
>>>
>>>
>>> King-of-mabs wrote:
>>>> Hi ,
>>>> I am not confirm but let you check this that whether you set  
>>>> property for
>>>> your groovy file or not. and So then please post your console or  
>>>> screen
>>>> error in mail.
>>>>
>>>>
>>>> Regards
>>>> Ravindra Mandre
>>>> Indore
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-is-request-passed-to-groovy-scripts--tp19808550p19809275.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
>>  
>>
>