You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ZongoZongo <nr...@gmx.net> on 2006/12/11 19:40:36 UTC
which submitbutton was pressed?
Hi
One simple short question :-)
How can I get the name of the submitbutton that has been pressed in a form
(inside flowscript).
something like cocoon.request.getpressedButton() :-)
By the way, I am not using CForms. But I think, that doesnt change anything.
THX,
Niclas
--
View this message in context: http://www.nabble.com/which-submitbutton-was-pressed--tf2795896.html#a7800473
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Niclas,
it might be that you are misunderstanding my example.
If I was correct you wanted to know which button you pressed in the form
right?
You can find that out with 'form.submitId'.
The example shows how to do some actions based on the value of the
submitId, which is being evaluated in the switch statement.
Kind regards,
Jeroen Reijn
ZongoZongo wrote:
> The Problem is, that the forms are generated dynamically. So i dont now which
> buttons eaven exists.
> I hoped I could commit a set of variables that are transered depending on
> the button.
>
>
> Jeroen Reijn wrote:
>> Hi Niclas,
>>
>> If you've defined the submit button as an fd:submit, you can react in
>> flow based on the submitId of the form.
>>
>> You can request the submitId from flow by using:
>>
>> form.submitId
>>
>> Example:
>>
>> form.showForm();
>> switch(form.submitId) {
>> case "details":
>> showDetails();
>> break;
>> case "create":
>> createNew();
>> break;
>> case "ok":
>> redisplayForm = false;
>> processForm(form);
>> break;
>> }
>>
>> I hope this helps you out.
>>
>> Kind regards,
>>
>> Jeroen Reijn
>>
>>
>> ZongoZongo wrote:
>>> Hi
>>>
>>> Couldnt solve the problem. But I am now using cforms. Inside the
>>> definition
>>> of the submitbutton you can set the <attribute/> tags.
>>> But the problem stays the same. How can I find out which button has been
>>> pressed und how can I extract the attributes? Please help. This is very
>>> fundamtel for my further work :-(
>>>
>>> greetings,
>>>
>>> Niclas
>>>
>>>
>>> ZongoZongo wrote:
>>>> Hi
>>>>
>>>> One simple short question :-)
>>>> How can I get the name of the submitbutton that has been pressed in a
>>>> form
>>>> (inside flowscript).
>>>> something like cocoon.request.getpressedButton() :-)
>>>>
>>>> By the way, I am not using CForms. But I think, that doesnt change
>>>> anything.
>>>>
>>>> THX,
>>>>
>>>> Niclas
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by Jeroen Reijn <j....@hippo.nl>.
Niclas,
it's the same as Simone described, but here is the example I used. I
won't post the entire sample, but just a short version. I modified the
inplace_edit example in the cforms block to test this.
In my flowscript I modified the do_inplace function
(forms_flow_example.js), where the floscript function now looks like:
form.showForm("inplace_edit-display-pipeline.jx");
var buttonId = form.submitId;
var widget = form.lookupWidget(buttonId);
var attribute = widget.getAttribute("objectType");
print(attribute);
In my form definition I have an OK button with an attribute objectType
with the value 123.
<fd:submit id="ok">
<fd:label>OK</fd:label>
<fd:attributes>
<fd:attribute name="objectType" value="123"/>
</fd:attributes>
</fd:submit>
Then in my form template I defined the widget to be shown on the page.
<ft:widget id="ok"/>
When pressing OK in my form, flowscript prints out '123' (the value of
the objectType attribute).
What I meant with my previous email was that you showed us an example of
one of your widgets.
[quote]
<fd:submit id="link-contributionDOT2">
<fd:label>Datenbankkomprimierung</fd:label>
<fd:attributes>
<attribute name="objectType" value="link-contribution" />
<attribute name="id" value="2" />
^^^^
</fd:attributes>
</fd:submit>
[/quote]
If you look at it carefully, you will nottice I contains the fd: prefix
for *attributes*, but not for an *attribute*.
That's why you get the null value back when requesting the attribute value.
I hope this helps.
Kind regards,
Jeroen Reijn
ZongoZongo wrote:
> @Reijn: I am still not that familiar with cocoon. I would be kind, if you
> could post the sourcecode, of how to fetch the value.
>
> Thanks a lot
>
> regards,
>
> Niclas
>
>
> Jeroen Reijn wrote:
>> Niclas,
>>
>> now I understood what went wrong before.
>> Try fetching the value after putting the namespace in front the attribute:
>>
>> <fd:submit id="link-contributionDOT2">
>> <fd:label>Datenbankkomprimierung</fd:label>
>> <fd:attributes>
>> <fd:attribute name="objectType" value="link-contribution" />
>> <fd:attribute name="id" value="2" />
>> </fd:attributes>
>> </fd:submit>
>>
>> Does this help? I tried it with cocoon 2.1.10 and it seems to work.
>>
>> Kind regards,
>>
>> Reijn
>>
>>
>> ZongoZongo wrote:
>>> Yea, that sounds great. Sadly I get a null value forr the "var attribute"
>>> :-(
>>>
>>> Thats one of my widgets:
>>>
>>> <fd:submit id="link-contributionDOT2">
>>> <fd:label>Datenbankkomprimierung</fd:label>
>>> <fd:attributes>
>>> <attribute name="objectType" value="link-contribution" />
>>> <attribute name="id" value="2" />
>>> </fd:attributes>
>>> </fd:submit>
>>>
>>> Why is this so difficult :-D
>>>
>>> Niclas
>>>
>>>
>>>
>>>
>>> Simone Gianni-2 wrote:
>>>> ZongoZongo wrote:
>>>>> The Problem is, that the forms are generated dynamically. So i dont now
>>>>> which
>>>>> buttons eaven exists.
>>>>>
>>>> Hi Niclas,
>>>> you can write the following :
>>>>
>>>> var buttonid = form.submitId;
>>>> var widget = form.lookupWidget(buttonid);
>>>> var attribute = widget.getAttribute("myattribute");
>>>>
>>>> More or less .. :) I don' t have the code by hand, but that's the idea.
>>>>
>>>> Simone
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by ZongoZongo <nr...@gmx.net>.
@Reijn: I am still not that familiar with cocoon. I would be kind, if you
could post the sourcecode, of how to fetch the value.
Thanks a lot
regards,
Niclas
Jeroen Reijn wrote:
>
> Niclas,
>
> now I understood what went wrong before.
> Try fetching the value after putting the namespace in front the attribute:
>
> <fd:submit id="link-contributionDOT2">
> <fd:label>Datenbankkomprimierung</fd:label>
> <fd:attributes>
> <fd:attribute name="objectType" value="link-contribution" />
> <fd:attribute name="id" value="2" />
> </fd:attributes>
> </fd:submit>
>
> Does this help? I tried it with cocoon 2.1.10 and it seems to work.
>
> Kind regards,
>
> Reijn
>
>
> ZongoZongo wrote:
>> Yea, that sounds great. Sadly I get a null value forr the "var attribute"
>> :-(
>>
>> Thats one of my widgets:
>>
>> <fd:submit id="link-contributionDOT2">
>> <fd:label>Datenbankkomprimierung</fd:label>
>> <fd:attributes>
>> <attribute name="objectType" value="link-contribution" />
>> <attribute name="id" value="2" />
>> </fd:attributes>
>> </fd:submit>
>>
>> Why is this so difficult :-D
>>
>> Niclas
>>
>>
>>
>>
>> Simone Gianni-2 wrote:
>>> ZongoZongo wrote:
>>>> The Problem is, that the forms are generated dynamically. So i dont now
>>>> which
>>>> buttons eaven exists.
>>>>
>>> Hi Niclas,
>>> you can write the following :
>>>
>>> var buttonid = form.submitId;
>>> var widget = form.lookupWidget(buttonid);
>>> var attribute = widget.getAttribute("myattribute");
>>>
>>> More or less .. :) I don' t have the code by hand, but that's the idea.
>>>
>>> Simone
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/which-submitbutton-was-pressed--tf2795896.html#a7832696
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by Jeroen Reijn <j....@hippo.nl>.
Niclas,
now I understood what went wrong before.
Try fetching the value after putting the namespace in front the attribute:
<fd:submit id="link-contributionDOT2">
<fd:label>Datenbankkomprimierung</fd:label>
<fd:attributes>
<fd:attribute name="objectType" value="link-contribution" />
<fd:attribute name="id" value="2" />
</fd:attributes>
</fd:submit>
Does this help? I tried it with cocoon 2.1.10 and it seems to work.
Kind regards,
Reijn
ZongoZongo wrote:
> Yea, that sounds great. Sadly I get a null value forr the "var attribute" :-(
>
> Thats one of my widgets:
>
> <fd:submit id="link-contributionDOT2">
> <fd:label>Datenbankkomprimierung</fd:label>
> <fd:attributes>
> <attribute name="objectType" value="link-contribution" />
> <attribute name="id" value="2" />
> </fd:attributes>
> </fd:submit>
>
> Why is this so difficult :-D
>
> Niclas
>
>
>
>
> Simone Gianni-2 wrote:
>> ZongoZongo wrote:
>>> The Problem is, that the forms are generated dynamically. So i dont now
>>> which
>>> buttons eaven exists.
>>>
>> Hi Niclas,
>> you can write the following :
>>
>> var buttonid = form.submitId;
>> var widget = form.lookupWidget(buttonid);
>> var attribute = widget.getAttribute("myattribute");
>>
>> More or less .. :) I don' t have the code by hand, but that's the idea.
>>
>> Simone
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by ZongoZongo <nr...@gmx.net>.
Yea, that sounds great. Sadly I get a null value forr the "var attribute" :-(
Thats one of my widgets:
<fd:submit id="link-contributionDOT2">
<fd:label>Datenbankkomprimierung</fd:label>
<fd:attributes>
<attribute name="objectType" value="link-contribution" />
<attribute name="id" value="2" />
</fd:attributes>
</fd:submit>
Why is this so difficult :-D
Niclas
Simone Gianni-2 wrote:
>
> ZongoZongo wrote:
>> The Problem is, that the forms are generated dynamically. So i dont now
>> which
>> buttons eaven exists.
>>
> Hi Niclas,
> you can write the following :
>
> var buttonid = form.submitId;
> var widget = form.lookupWidget(buttonid);
> var attribute = widget.getAttribute("myattribute");
>
> More or less .. :) I don' t have the code by hand, but that's the idea.
>
> Simone
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/which-submitbutton-was-pressed--tf2795896.html#a7831932
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by Simone Gianni <si...@apache.org>.
ZongoZongo wrote:
> The Problem is, that the forms are generated dynamically. So i dont now which
> buttons eaven exists.
>
Hi Niclas,
you can write the following :
var buttonid = form.submitId;
var widget = form.lookupWidget(buttonid);
var attribute = widget.getAttribute("myattribute");
More or less .. :) I don' t have the code by hand, but that's the idea.
Simone
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by ZongoZongo <nr...@gmx.net>.
The Problem is, that the forms are generated dynamically. So i dont now which
buttons eaven exists.
I hoped I could commit a set of variables that are transered depending on
the button.
Jeroen Reijn wrote:
>
> Hi Niclas,
>
> If you've defined the submit button as an fd:submit, you can react in
> flow based on the submitId of the form.
>
> You can request the submitId from flow by using:
>
> form.submitId
>
> Example:
>
> form.showForm();
> switch(form.submitId) {
> case "details":
> showDetails();
> break;
> case "create":
> createNew();
> break;
> case "ok":
> redisplayForm = false;
> processForm(form);
> break;
> }
>
> I hope this helps you out.
>
> Kind regards,
>
> Jeroen Reijn
>
>
> ZongoZongo wrote:
>> Hi
>>
>> Couldnt solve the problem. But I am now using cforms. Inside the
>> definition
>> of the submitbutton you can set the <attribute/> tags.
>> But the problem stays the same. How can I find out which button has been
>> pressed und how can I extract the attributes? Please help. This is very
>> fundamtel for my further work :-(
>>
>> greetings,
>>
>> Niclas
>>
>>
>> ZongoZongo wrote:
>>> Hi
>>>
>>> One simple short question :-)
>>> How can I get the name of the submitbutton that has been pressed in a
>>> form
>>> (inside flowscript).
>>> something like cocoon.request.getpressedButton() :-)
>>>
>>> By the way, I am not using CForms. But I think, that doesnt change
>>> anything.
>>>
>>> THX,
>>>
>>> Niclas
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/which-submitbutton-was-pressed--tf2795896.html#a7831182
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Niclas,
If you've defined the submit button as an fd:submit, you can react in
flow based on the submitId of the form.
You can request the submitId from flow by using:
form.submitId
Example:
form.showForm();
switch(form.submitId) {
case "details":
showDetails();
break;
case "create":
createNew();
break;
case "ok":
redisplayForm = false;
processForm(form);
break;
}
I hope this helps you out.
Kind regards,
Jeroen Reijn
ZongoZongo wrote:
> Hi
>
> Couldnt solve the problem. But I am now using cforms. Inside the definition
> of the submitbutton you can set the <attribute/> tags.
> But the problem stays the same. How can I find out which button has been
> pressed und how can I extract the attributes? Please help. This is very
> fundamtel for my further work :-(
>
> greetings,
>
> Niclas
>
>
> ZongoZongo wrote:
>> Hi
>>
>> One simple short question :-)
>> How can I get the name of the submitbutton that has been pressed in a form
>> (inside flowscript).
>> something like cocoon.request.getpressedButton() :-)
>>
>> By the way, I am not using CForms. But I think, that doesnt change
>> anything.
>>
>> THX,
>>
>> Niclas
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: which submitbutton was pressed?
Posted by ZongoZongo <nr...@gmx.net>.
Hi
Couldnt solve the problem. But I am now using cforms. Inside the definition
of the submitbutton you can set the <attribute/> tags.
But the problem stays the same. How can I find out which button has been
pressed und how can I extract the attributes? Please help. This is very
fundamtel for my further work :-(
greetings,
Niclas
ZongoZongo wrote:
>
> Hi
>
> One simple short question :-)
> How can I get the name of the submitbutton that has been pressed in a form
> (inside flowscript).
> something like cocoon.request.getpressedButton() :-)
>
> By the way, I am not using CForms. But I think, that doesnt change
> anything.
>
> THX,
>
> Niclas
>
--
View this message in context: http://www.nabble.com/which-submitbutton-was-pressed--tf2795896.html#a7830676
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org