Screen Widget script handling enhancement

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

Screen Widget script handling enhancement

Adrian Crum-2
Right now the screen widget only accepts bsh scripts in the <actions> section. I have a working example of the screen widget accepting simple methods also. It looks like this:

<actions>
    <script location="component://example/script/org/ofbiz/example/example/ExampleScripts.xml#myScript"/>
</actions>
 
Would something like that be useful to others? Should I commit it?

-Adrian


       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
Reply | Threaded
Open this post in threaded view
|

Re: Screen Widget script handling enhancement

David E Jones

I would be fine with that enhancement. There are caveats to using the  
simple-method this way (like transaction control, etc), but it  
certainly works and has been done in other places. It should also be  
noted that these should only be used for reading information, not for  
persisting it (just like any other screen action), and that is good as  
it makes the transaction and other caveats with using the simple-
methods less of an issue.

To clarify: this would be running the simple-method in "service" mode  
(as opposed to request event mode) and would use the current screen  
context (with a push to isolate the context) for the input context of  
the simple-method. There wouldn't be any parameters per-se, but it  
might be nice to put the entire context in the a "parameters" Map to  
make these simple-methods more like the ones that are actually called  
through the service engine. For picking out the results after the call  
to the simple-method using the results Map is probably still the best  
way to go, again to make it more similar to the typical coding of a  
simple-method called from a service and to better isolate the context.

-David


On Dec 31, 2007, at 12:45 PM, Adrian Crum wrote:

> Right now the screen widget only accepts bsh scripts in the  
> <actions> section. I have a working example of the screen widget  
> accepting simple methods also. It looks like this:
>
> <actions>
>    <script location="component://example/script/org/ofbiz/example/
> example/ExampleScripts.xml#myScript"/>
> </actions>
>
> Would something like that be useful to others? Should I commit it?
>
> -Adrian
>
>
>
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo!  
> Search.


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

Re: Screen Widget script handling enhancement

Adrian Crum-2
David,

Thank you very much for the reply and suggestions! You answered some questions I had.

My example code uses the MethodContext constructor that initializes it to service mode. After the simple method is run, I copy the MethodContext environment to the screen context - so the results of the method call can be used. Is that the right approach?

Isn't the screen widget rendering wrapped in a transaction already?

-Adrian

David E Jones <[hidden email]> wrote:
I would be fine with that enhancement. There are caveats to using the  
simple-method this way (like transaction control, etc), but it  
certainly works and has been done in other places. It should also be  
noted that these should only be used for reading information, not for  
persisting it (just like any other screen action), and that is good as  
it makes the transaction and other caveats with using the simple-
methods less of an issue.

To clarify: this would be running the simple-method in "service" mode  
(as opposed to request event mode) and would use the current screen  
context (with a push to isolate the context) for the input context of  
the simple-method. There wouldn't be any parameters per-se, but it  
might be nice to put the entire context in the a "parameters" Map to  
make these simple-methods more like the ones that are actually called  
through the service engine. For picking out the results after the call  
to the simple-method using the results Map is probably still the best  
way to go, again to make it more similar to the typical coding of a  
simple-method called from a service and to better isolate the context.

-David


On Dec 31, 2007, at 12:45 PM, Adrian Crum wrote:

> Right now the screen widget only accepts bsh scripts in the  
>  section. I have a working example of the screen widget  
> accepting simple methods also. It looks like this:
>
>
>    
>
>
> Would something like that be useful to others? Should I commit it?
>
> -Adrian
>
>
>
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo!  
> Search.



       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
Reply | Threaded
Open this post in threaded view
|

Re: Screen Widget script handling enhancement

cjhowe
In reply to this post by Adrian Crum-2
There has been discussed in the past:
http://www.nabble.com/forum/ViewPost.jtp?post=2515155&framed=y
and here regarding java methods
http://issues.apache.org/jira/browse/OFBIZ-44

IIRC, there was one more in regards to OFBIZ-44 on one of the ML, but
the consensus was the same.

I see the arguments against it still being valid as far as best
practice.  That said, I do use a generic service that takes a
simple-method name, location and inMap parameter (later sets
parameters= inMap), that accomplishes the same thing for convenience.

--- Adrian Crum <[hidden email]> wrote:

> Right now the screen widget only accepts bsh scripts in the <actions>
> section. I have a working example of the screen widget accepting
> simple methods also. It looks like this:
>
> <actions>
>     <script
>
location="component://example/script/org/ofbiz/example/example/ExampleScripts.xml#myScript"/>

> </actions>
>  
> Would something like that be useful to others? Should I commit it?
>
> -Adrian
>
>
>        
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo!
Search.

Reply | Threaded
Open this post in threaded view
|

Re: Screen Widget script handling enhancement

Adrian Crum-2
Chris,

Thanks for the links! I didn't think to research if it had already been suggested.

Your solution is an interesting one and addresses the main reason for the enhancement - how to call a simple method without having to define a service for it.

-Adrian

Chris Howe <[hidden email]> wrote: There has been discussed in the past:
http://www.nabble.com/forum/ViewPost.jtp?post=2515155&framed=y
and here regarding java methods
http://issues.apache.org/jira/browse/OFBIZ-44

IIRC, there was one more in regards to OFBIZ-44 on one of the ML, but
the consensus was the same.

I see the arguments against it still being valid as far as best
practice.  That said, I do use a generic service that takes a
simple-method name, location and inMap parameter (later sets
parameters= inMap), that accomplishes the same thing for convenience.

--- Adrian Crum  wrote:

> Right now the screen widget only accepts bsh scripts in the
> section. I have a working example of the screen widget accepting
> simple methods also. It looks like this:
>
>
>    
>
location="component://example/script/org/ofbiz/example/example/ExampleScripts.xml#myScript"/>

>
>  
> Would something like that be useful to others? Should I commit it?
>
> -Adrian
>
>
>        
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo!
Search.



       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
Reply | Threaded
Open this post in threaded view
|

Re: Screen Widget script handling enhancement

Adrian Crum-2
In reply to this post by David E Jones
David,

I applied your suggestions with the exception of the transaction - since widget rendering is already wrapped in a transaction - and it all works great.

I'll wait a few days to see if there are any objections, then I'll commit it.

Thanks again for your suggestions!

-Adrian

David E Jones <[hidden email]> wrote:
I would be fine with that enhancement. There are caveats to using the  
simple-method this way (like transaction control, etc), but it  
certainly works and has been done in other places. It should also be  
noted that these should only be used for reading information, not for  
persisting it (just like any other screen action), and that is good as  
it makes the transaction and other caveats with using the simple-
methods less of an issue.

To clarify: this would be running the simple-method in "service" mode  
(as opposed to request event mode) and would use the current screen  
context (with a push to isolate the context) for the input context of  
the simple-method. There wouldn't be any parameters per-se, but it  
might be nice to put the entire context in the a "parameters" Map to  
make these simple-methods more like the ones that are actually called  
through the service engine. For picking out the results after the call  
to the simple-method using the results Map is probably still the best  
way to go, again to make it more similar to the typical coding of a  
simple-method called from a service and to better isolate the context.

-David


On Dec 31, 2007, at 12:45 PM, Adrian Crum wrote:

> Right now the screen widget only accepts bsh scripts in the  
>  section. I have a working example of the screen widget  
> accepting simple methods also. It looks like this:
>
>
>    
>
>
> Would something like that be useful to others? Should I commit it?
>
> -Adrian
>
>
>
> ---------------------------------
> Looking for last minute shopping deals?  Find them fast with Yahoo!  
> Search.



       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
Reply | Threaded
Open this post in threaded view
|

Re: Screen Widget script handling enhancement

David E Jones

Don't worry about doing anything about the transaction thing. I was  
just meaning that when you skip the service engine you lose the  
additional transaction control (new transaction, timeout, etc), but  
for this it really should be needed.

-David


On Dec 31, 2007, at 1:39 PM, Adrian Crum wrote:

> David,
>
> I applied your suggestions with the exception of the transaction -  
> since widget rendering is already wrapped in a transaction - and it  
> all works great.
>
> I'll wait a few days to see if there are any objections, then I'll  
> commit it.
>
> Thanks again for your suggestions!
>
> -Adrian
>
> David E Jones <[hidden email]> wrote:
> I would be fine with that enhancement. There are caveats to using the
> simple-method this way (like transaction control, etc), but it
> certainly works and has been done in other places. It should also be
> noted that these should only be used for reading information, not for
> persisting it (just like any other screen action), and that is good as
> it makes the transaction and other caveats with using the simple-
> methods less of an issue.
>
> To clarify: this would be running the simple-method in "service" mode
> (as opposed to request event mode) and would use the current screen
> context (with a push to isolate the context) for the input context of
> the simple-method. There wouldn't be any parameters per-se, but it
> might be nice to put the entire context in the a "parameters" Map to
> make these simple-methods more like the ones that are actually called
> through the service engine. For picking out the results after the call
> to the simple-method using the results Map is probably still the best
> way to go, again to make it more similar to the typical coding of a
> simple-method called from a service and to better isolate the context.
>
> -David
>
>
> On Dec 31, 2007, at 12:45 PM, Adrian Crum wrote:
>
>> Right now the screen widget only accepts bsh scripts in the
>> section. I have a working example of the screen widget
>> accepting simple methods also. It looks like this:
>>
>>
>>
>>
>>
>> Would something like that be useful to others? Should I commit it?
>>
>> -Adrian
>>
>>
>>
>> ---------------------------------
>> Looking for last minute shopping deals?  Find them fast with Yahoo!
>> Search.
>
>
>
>
> ---------------------------------
> Never miss a thing.   Make Yahoo your homepage.


smime.p7s (3K) Download Attachment