cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira>
Subject Re: [Woody] Row Submit Action
Date Sun, 14 Dec 2003 16:20:26 GMT
Sylvain Wallez wrote:

> Upayavira wrote:
>> Bruno Dumon wrote:
>>> On Fri, 2003-12-12 at 11:47, Upayavira wrote:
>>>> I need a row submit action, that allows a form to be submitted for 
>>>> a specific line in a repeater.
>>>> An example usecase would be on a selling site, you have a repeater 
>>>> showing purchasable items, each with a 'buy' button next to it.
>>>> Clicking on a row submit action will submit the form and allow the 
>>>> flowscript code that deals with the submitted form to gain access 
>>>> to either the repeater row object, or at least the row index that 
>>>> was clicked.
>>>> Is there anything like this already? Any of you interested in 
>>>> adding it ;-)
>>> Use a wd:submit widget (or wd:action) as child of the repeater. In 
>>> its event handler you can get the repeater row by getting the parent 
>>> of the submitted widget:
>>> event.getSourceWidget().getParent()
>>> using getId() on it will return the row number (as a string). You 
>>> can access other widgets on the repeater row by using the 
>>> getWidget(id) method on it.
>> Bruno,
>> Thanks for this. What I've done is extend the RowAction to give it a 
>> 'submit-row' action-command. I've added a property to the repeater 
>> for it to store and access the 'submittedRow'. When the submit-row 
>> RowAction is clicked, it sets the submitted row on the repeater. Then 
>> from flow, the submitted row can be found from flow using 
>> form.getWidget("repeatername").getSubmittedRow().
>> I would rather not do it in an event handler, as I'd have to store 
>> the row somewhere for future use outside of the forms flow.
>> Is this reasonable? Is it a reasonable patch?
> IMO, it's better to go through the widget that triggered the submit 
> than asking to the repeater (furthermore, what happens in the case of 
> nested repeaters?).
> I you want this to be handled by the flow, The Form object provides a 
> getSubmitWidget() that gives the submitting widget. From there, you 
> can use the same getParent() as outlined by Bruno to access the row, 
> and then the row id, child widgets, etc.

Splendid. That's what I wanted to be able to do, and without any 
modifications to Cocoon - even better!

Thanks for this.


View raw message