Proposal: add the optional "invoke" attribute to the xml "script" element

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

Proposal: add the optional "invoke" attribute to the xml "script" element

Jacopo Cappellato-4
Hi all,

from the widgets (screens, forms...) we can call a script using the following syntax:

<script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>

What about adding an optional "invoke" attribute to it, to specify a method in the script?

For example:

<script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy" invoke="someMethod"/>

In this way we would enable components to reorganize their scripts into less source files; for example, instead of having:

<script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
<script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryContentContent.groovy"/>
<script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategorySEO.groovy"/>

we could group the three files into one with three methods:

<script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategory"/>
<script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategoryContentContent"/>
<script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategorySeo"/>

Jacopo

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: add the optional "invoke" attribute to the xml "script" element

Adrian Crum-3
To call a function/method, just append "#" plus the function/method name
to the script location.

-Adrian

On 3/10/2012 8:35 AM, Jacopo Cappellato wrote:

> Hi all,
>
> from the widgets (screens, forms...) we can call a script using the following syntax:
>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>
> What about adding an optional "invoke" attribute to it, to specify a method in the script?
>
> For example:
>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy" invoke="someMethod"/>
>
> In this way we would enable components to reorganize their scripts into less source files; for example, instead of having:
>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryContentContent.groovy"/>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategorySEO.groovy"/>
>
> we could group the three files into one with three methods:
>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategory"/>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategoryContentContent"/>
> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategorySeo"/>
>
> Jacopo
>
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: add the optional "invoke" attribute to the xml "script" element

Jacopo Cappellato-4
Ah, this is nice... I didn't know about this, thank you Adrian.

Jacopo

On Mar 10, 2012, at 9:37 AM, Adrian Crum wrote:

> To call a function/method, just append "#" plus the function/method name to the script location.
>
> -Adrian
>
> On 3/10/2012 8:35 AM, Jacopo Cappellato wrote:
>> Hi all,
>>
>> from the widgets (screens, forms...) we can call a script using the following syntax:
>>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>>
>> What about adding an optional "invoke" attribute to it, to specify a method in the script?
>>
>> For example:
>>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy" invoke="someMethod"/>
>>
>> In this way we would enable components to reorganize their scripts into less source files; for example, instead of having:
>>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryContentContent.groovy"/>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategorySEO.groovy"/>
>>
>> we could group the three files into one with three methods:
>>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategory"/>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategoryContentContent"/>
>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategorySeo"/>
>>
>> Jacopo
>>

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: add the optional "invoke" attribute to the xml "script" element

Adrian Crum-3
Having a separate invoke attribute would be nice - it would make the
widget code clearer.

-Adrian

On 3/10/2012 8:39 AM, Jacopo Cappellato wrote:

> Ah, this is nice... I didn't know about this, thank you Adrian.
>
> Jacopo
>
> On Mar 10, 2012, at 9:37 AM, Adrian Crum wrote:
>
>> To call a function/method, just append "#" plus the function/method name to the script location.
>>
>> -Adrian
>>
>> On 3/10/2012 8:35 AM, Jacopo Cappellato wrote:
>>> Hi all,
>>>
>>> from the widgets (screens, forms...) we can call a script using the following syntax:
>>>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>>>
>>> What about adding an optional "invoke" attribute to it, to specify a method in the script?
>>>
>>> For example:
>>>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy" invoke="someMethod"/>
>>>
>>> In this way we would enable components to reorganize their scripts into less source files; for example, instead of having:
>>>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryContentContent.groovy"/>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategorySEO.groovy"/>
>>>
>>> we could group the three files into one with three methods:
>>>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategory"/>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategoryContentContent"/>
>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategorySeo"/>
>>>
>>> Jacopo
>>>
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: add the optional "invoke" attribute to the xml "script" element

Jacopo Cappellato-4
Yes,

I agree with you; maybe this could be considered as part of the Minilang syntax refactoring effort you are leading: we could use similar attributes in widgets.
But in the meantime again, thanks for the hint about the "#" syntax.

Jacopo

On Mar 10, 2012, at 9:41 AM, Adrian Crum wrote:

> Having a separate invoke attribute would be nice - it would make the widget code clearer.
>
> -Adrian
>
> On 3/10/2012 8:39 AM, Jacopo Cappellato wrote:
>> Ah, this is nice... I didn't know about this, thank you Adrian.
>>
>> Jacopo
>>
>> On Mar 10, 2012, at 9:37 AM, Adrian Crum wrote:
>>
>>> To call a function/method, just append "#" plus the function/method name to the script location.
>>>
>>> -Adrian
>>>
>>> On 3/10/2012 8:35 AM, Jacopo Cappellato wrote:
>>>> Hi all,
>>>>
>>>> from the widgets (screens, forms...) we can call a script using the following syntax:
>>>>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>>>>
>>>> What about adding an optional "invoke" attribute to it, to specify a method in the script?
>>>>
>>>> For example:
>>>>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy" invoke="someMethod"/>
>>>>
>>>> In this way we would enable components to reorganize their scripts into less source files; for example, instead of having:
>>>>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryContentContent.groovy"/>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategorySEO.groovy"/>
>>>>
>>>> we could group the three files into one with three methods:
>>>>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategory"/>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategoryContentContent"/>
>>>> <script location="component://product/webapp/catalog/WEB-INF/actions/category/CategoryScripts.groovy" invoke="editCategorySeo"/>
>>>>
>>>> Jacopo
>>>>