You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Benjamin Bratkus <br...@oio.de> on 2007/05/22 13:46:35 UTC

howto click a t:commandbutton via js

hi folks,

actually i am fighting with my different browsers :P so for firefox 1.x and
2.x my app works fine but the same side within ie6 do not work. 

means i fill in in a h:inputText a string and press return and i got the next
view by using the button under the inpuText

ie ignores me :9

so i thought about something like :

<div>
<label for="username">#{msg['add.byusername']} </label>
<h:inputText id="username"value="#{myBean.userName}"
onkeypress="if(event.keyCode == 13)
document.getElementsByName('selectbutton').doclick();"/>
<!-- get the select button and press it ? ->
</div>
<div class="indent-large">
<ul class="buttons">
<li class="select">
<t:commandButton id="selectbutton" name="selectbutton"
action="#{myBean.select}" value="#{msg['action.select.label']}"
title="#{msg['action.select.tooltip']}" />
</li>
<li class="cancel">
<t:commandButton action="#{myBean.cancel}" immediate="true"
value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}" />
</li>
</ul>
</div>

question : how can i press the select button via a js function ?

best regards,

ben


RE: howto click a t:commandbutton via js

Posted by Benjamin Bratkus <br...@oio.de>.
you would not believe it ..... the real reason - i love it :P

through the wild structure the reason why it wouldn work is :

onkeypress="if(event.keyCode == 13) document.getElementById('form:form:selectbutton').onclick();return true;

the damned id was form:form:....

thx for your responses

ben

On Tue, 22 May 2007 15:24:47 +0200, Benjamin Bratkus wrote
> he all,
> 
> thanks for your fast replies. but i think this is going in the wrong direction. i just want to realize that if someone fills in a string into this input text and presses return
> 
> <h:inputText id="username"value="#{myBean.userName}" x_onKeyPress="if(event.keyCode == 13) document.getElementsByName('selectbutton').doclick();"/>
> 
> the t:commandbutton
> 
> <t:commandButton id="selectbutton" name="selectbutton" action="#{myBean.select}" value="#{msg['action.select.label']}" title="#{msg['action.select.tooltip']}" />
> 
> is pressed as the user would do.
> 
> sorry but cant do anything you proposed.
> 
> ben 
> 
> On Tue, 22 May 2007 08:23:28 -0400, William Hoover wrote
> > I think he ment to say: 
> >  
> > Internet Expolder:
> > myInputObj.click();
> >  
> > Firefox:
> > HTMLElement.prototype.click = function() {
> > var evt = this.ownerDocument.createEvent('MouseEvents');
> > evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
> > this.dispatchEvent(evt);
> > }
> >  
> > -----Original Message-----
> > From: Benjamin Bratkus [mailto:bratkus@oio.de]
> > Sent: Tuesday, May 22, 2007 8:15 AM
> > To: MyFaces Discussion
> > Subject: Re: howto click a t:commandbutton via js
> > 
> > i guess you mean the x_x_onClick() for the submit button ? or do you mean i have to write my own method ? 
> > 
> > ben 
> > 
> > p.s. the x_x_onClick does not work... 
> > 
> > On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote 
> > > try 
> > > ... 
> > > document.getElementsByName('selectbutton').x_x_x_onClick();"/> 
> > > ... 
> > > 
> > > On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:hi folks, 
> > > 
> > > actually i am fighting with my different browsers :P so for firefox 1.x and 
> > > 2.x my app works fine but the same side within ie6 do not work. 
> > > 
> > > means i fill in in a h:inputText a string and press return and i got the next 
> > > view by using the button under the inpuText 
> > > 
> > > ie ignores me :9 
> > > 
> > > so i thought about something like : 
> > > 
> > > <div> 
> > > <label for="username">#{msg['add.byusername']} </label> 
> > > <h:inputText id="username"value="#{myBean.userName}" 
> > > x_x_x_onKeyPress="if(event.keyCode == 13) 
> > > document.getElementsByName('selectbutton').doclick();"/> 
> > > <!-- get the select button and press it ? -> 
> > > </div> 
> > > <div class="indent-large"> 
> > > <ul class="buttons"> 
> > > <li class="select"> 
> > > <t:commandButton id="selectbutton" name="selectbutton" 
> > > action="#{myBean.select}" value="#{msg['action.select.label']}" 
> > > title="#{msg['action.select.tooltip']}" /> 
> > > </li> 
> > > <li class="cancel"> 
> > > <t:commandButton action="#{ myBean.cancel}" immediate="true" 
> > > value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}" /> 
> > > </li> 
> > > </ul> 
> > > </div> 
> > > 
> > > question : how can i press the select button via a js function ? 
> > > 
> > > best regards, 
> > > 
> > > ben 
> > > 
> > > 
> > 
> > Viele Grüße, best regards, 
> > 
> > Benjamin Bratkus 
> > -- 
> > Orientation in Objects GmbH 
> > Weinheimer Str. 68 
> > D-68309 Mannheim 
> > http://www.oio.de 
> > Tel. +49(0)621-71839-0 
> > Fax +49(0)621-71839-50 
> > 
> > Amtsgericht Mannheim 
> > HRB 38348 
> > 
> > 
> 
> Viele Grüße, best regards, 
> 
> Benjamin Bratkus 
> -- 
> Orientation in Objects GmbH 
> Weinheimer Str. 68 
> D-68309 Mannheim 
> http://www.oio.de 
> Tel. +49(0)621-71839-0 
> Fax +49(0)621-71839-50 
> 
> Amtsgericht Mannheim 
> HRB 38348 
> 
>

Viele Grüße, best regards,

Benjamin Bratkus 
-- 
Orientation in Objects GmbH 
Weinheimer Str. 68 
D-68309 Mannheim 
http://www.oio.de 
Tel. +49(0)621-71839-0 
Fax +49(0)621-71839-50

Amtsgericht Mannheim 
HRB 38348

 

RE: howto click a t:commandbutton via js

Posted by Benjamin Bratkus <br...@oio.de>.
he all,

thanks for your fast replies. but i think this is going in the wrong direction. i just want to realize that if someone fills in a string into this input text and presses return

<h:inputText id="username"value="#{myBean.userName}"  onKeyPress="if(event.keyCode == 13)  document.getElementsByName('selectbutton').doclick();"/>

the t:commandbutton

<t:commandButton id="selectbutton" name="selectbutton" action="#{myBean.select}" value="#{msg['action.select.label']}"  title="#{msg['action.select.tooltip']}" />

is pressed as the user would do.

sorry but cant do anything you proposed.

ben

On Tue, 22 May 2007 08:23:28 -0400, William Hoover wrote
> I think he ment to say: 
>  
> Internet Expolder:
> myInputObj.click();
>  
> Firefox:
> HTMLElement.prototype.click = function() {
>     var evt = this.ownerDocument.createEvent('MouseEvents');
>     evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
>     this.dispatchEvent(evt);
> }
>  
> -----Original Message-----
> From: Benjamin Bratkus [mailto:bratkus@oio.de]
> Sent: Tuesday, May 22, 2007 8:15 AM
> To: MyFaces Discussion
> Subject: Re: howto click a t:commandbutton via js
> 
> i guess you mean the x_onClick() for the submit button ? or do you mean i have to write my own method ? 
> 
> ben 
> 
> p.s. the x_onClick does not work... 
> 
> On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote 
> > try 
> > ... 
> > document.getElementsByName('selectbutton').x_x_onClick();"/> 
> > ... 
> > 
> > On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:hi folks, 
> > 
> > actually i am fighting with my different browsers :P so for firefox 1.x and 
> > 2.x my app works fine but the same side within ie6 do not work. 
> > 
> > means i fill in in a h:inputText a string and press return and i got the next 
> > view by using the button under the inpuText 
> > 
> > ie ignores me :9 
> > 
> > so i thought about something like : 
> > 
> > <div> 
> > <label for="username">#{msg['add.byusername']} </label> 
> > <h:inputText id="username"value="#{myBean.userName}" 
> > x_x_onKeyPress="if(event.keyCode == 13) 
> > document.getElementsByName('selectbutton').doclick();"/> 
> > <!-- get the select button and press it ? -> 
> > </div> 
> > <div class="indent-large"> 
> > <ul class="buttons"> 
> > <li class="select"> 
> > <t:commandButton id="selectbutton" name="selectbutton" 
> > action="#{myBean.select}" value="#{msg['action.select.label']}" 
> > title="#{msg['action.select.tooltip']}" /> 
> > </li> 
> > <li class="cancel"> 
> > <t:commandButton action="#{ myBean.cancel}" immediate="true" 
> > value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}" /> 
> > </li> 
> > </ul> 
> > </div> 
> > 
> > question : how can i press the select button via a js function ? 
> > 
> > best regards, 
> > 
> > ben 
> > 
> > 
> 
> Viele Grüße, best regards, 
> 
> Benjamin Bratkus 
> -- 
> Orientation in Objects GmbH 
> Weinheimer Str. 68 
> D-68309 Mannheim 
> http://www.oio.de 
> Tel. +49(0)621-71839-0 
> Fax +49(0)621-71839-50 
> 
> Amtsgericht Mannheim 
> HRB 38348 
> 
>

Viele Grüße, best regards,

Benjamin Bratkus 
-- 
Orientation in Objects GmbH 
Weinheimer Str. 68 
D-68309 Mannheim 
http://www.oio.de 
Tel. +49(0)621-71839-0 
Fax +49(0)621-71839-50

Amtsgericht Mannheim 
HRB 38348

 

Re: howto click a t:commandbutton via js

Posted by Ayhan Güngör <ag...@gmail.com>.
document.getElementById('selectbutton').onclick();
this will work on IE, Firefox and Opera, if you have a button(id="
selectbutton")



On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:
>
>  *i guess you mean the onClick() for the submit button ? or do you mean i
> have to write my own method ?
>
> ben
>
> p.s. the onclick does not work...
>
>
> On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote*
> > try
> > ...
> > document.getElementsByName('selectbutton').x_onClick();"/>
> > ...
> >
> > On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:
> >
> > hi folks,
> > >
> > > actually i am fighting with my different browsers :P so for firefox
> > 1.x and
> > > 2.x my app works fine but the same side within ie6 do not work.
> > >
> > > means i fill in in a h:inputText a string and press return and i got
> > the next
> > > view by using the button under the inpuText
> > >
> > > ie ignores me :9
> > >
> > > so i thought about something like :
> > >
> > > <div>
> > > <label for="username">#{msg['add.byusername']} </label>
> > > <h:inputText id="username"value="#{myBean.userName}"
> > > x_onKeyPress="if(event.keyCode == 13)
> > > document.getElementsByName('selectbutton').doclick();"/>
> > > <!-- get the select button and press it ? ->
> > > </div>
> > > <div class="indent-large">
> > > <ul class="buttons">
> > > <li class="select">
> > > <t:commandButton id="selectbutton" name="selectbutton"
> > > action="#{myBean.select}" value="#{msg['action.select.label']}"
> > > title="#{msg['action.select.tooltip']}" />
> > > </li>
> > > <li class="cancel">
> > > <t:commandButton action="#{ myBean.cancel}" immediate="true"
> > > value="#{msg['action.cancel.label']}" title="#{msg['
> > action.cancel.tooltip']}" />
> > > </li>
> > > </ul>
> > > </div>
> > >
> > > question : how can i press the select button via a js function ?
> > >
> > > best regards,
> > >
> > > ben
> > >
> > >
>
>
>
>
> Viele Grüße, best regards,
>
> Benjamin Bratkus
> --
> Orientation in Objects GmbH
> Weinheimer Str. 68
> D-68309 Mannheim
> http://www.oio.de
> Tel. +49(0)621-71839-0
> Fax +49(0)621-71839-50
>
> Amtsgericht Mannheim
> HRB 38348
>
>

Re: howto click a t:commandbutton via js

Posted by David Delbecq <de...@oma.be>.
no, it will only call the event of onClick but not necesseraly submit form.

To act a if user clicked on button, just do

document.getElementById('formxX::selectButton').click();


En l'instant précis du 22/05/07 14:15, Benjamin Bratkus s'exprimait en
ces termes:
> *i guess you mean the onClick() for the submit button ? or do you mean
> i have to write my own method ?
>
> ben
>
> p.s. the onclick does not work...
>
>
> On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote*
> > try
> > ...
> > document.getElementsByName('selectbutton').x_onClick();"/>
> > ...
> >
> > On 5/22/07, *Benjamin Bratkus * <bratkus@oio.de
> <ma...@oio.de>> wrote:
>
>     hi folks,
>     >
>     > actually i am fighting with my different browsers :P so for
>     firefox 1.x and
>     > 2.x my app works fine but the same side within ie6 do not work.
>     >
>     > means i fill in in a h:inputText a string and press return and i
>     got the next
>     > view by using the button under the inpuText
>     >
>     > ie ignores me :9
>     >
>     > so i thought about something like :
>     >
>     > <div>
>     > <label for="username">#{msg['add.byusername']} </label>
>     > <h:inputText id="username"value="#{myBean.userName}"
>     > x_onKeyPress="if(event.keyCode == 13)
>     > document.getElementsByName('selectbutton').doclick();"/>
>     > <!-- get the select button and press it ? ->
>     > </div>
>     > <div class="indent-large">
>     > <ul class="buttons">
>     > <li class="select">
>     > <t:commandButton id="selectbutton" name="selectbutton"
>     > action="#{myBean.select}" value="#{msg['action.select.label']}"
>     > title="#{msg['action.select.tooltip']}" />
>     > </li>
>     > <li class="cancel">
>     > <t:commandButton action="#{ myBean.cancel}" immediate="true"
>     > value="#{msg['action.cancel.label']}"
>     title="#{msg['action.cancel.tooltip']}" />
>     > </li>
>     > </ul>
>     > </div>
>     >
>     > question : how can i press the select button via a js function ?
>     >
>     > best regards,
>     >
>     > ben
>     >
>     > 
>
>
>
>
> Viele Grüße, best regards,
>
> Benjamin Bratkus
> -- 
> Orientation in Objects GmbH
> Weinheimer Str. 68
> D-68309 Mannheim
> http://www.oio.de <http://www.oio.de/>
> Tel. +49(0)621-71839-0
> Fax +49(0)621-71839-50
>
> Amtsgericht Mannheim
> HRB 38348
>


RE: howto click a t:commandbutton via js

Posted by William Hoover <wh...@nemours.org>.
I think he ment to say: 
 
Internet Expolder:
myInputObj.click();
 
Firefox:
HTMLElement.prototype.click = function() {
    var evt = this.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    this.dispatchEvent(evt);
}
 
-----Original Message-----
From: Benjamin Bratkus [mailto:bratkus@oio.de]
Sent: Tuesday, May 22, 2007 8:15 AM
To: MyFaces Discussion
Subject: Re: howto click a t:commandbutton via js


i guess you mean the onClick() for the submit button ? or do you mean i have to write my own method ? 

ben 

p.s. the onclick does not work... 


On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote 
> try 
> ... 
> document.getElementsByName('selectbutton').x_onClick();"/> 
> ... 
> 
> On 5/22/07, Benjamin Bratkus < bratkus@oio.de> wrote: 

hi folks, 
> 
> actually i am fighting with my different browsers :P so for firefox 1.x and 
> 2.x my app works fine but the same side within ie6 do not work. 
> 
> means i fill in in a h:inputText a string and press return and i got the next 
> view by using the button under the inpuText 
> 
> ie ignores me :9 
> 
> so i thought about something like : 
> 
> <div> 
> <label for="username">#{msg['add.byusername']} </label> 
> <h:inputText id="username"value="#{myBean.userName}" 
> x_onKeyPress="if(event.keyCode == 13) 
> document.getElementsByName('selectbutton').doclick();"/> 
> <!-- get the select button and press it ? -> 
> </div> 
> <div class="indent-large"> 
> <ul class="buttons"> 
> <li class="select"> 
> <t:commandButton id="selectbutton" name="selectbutton" 
> action="#{myBean.select}" value="#{msg['action.select.label']}" 
> title="#{msg['action.select.tooltip']}" /> 
> </li> 
> <li class="cancel"> 
> <t:commandButton action="#{ myBean.cancel}" immediate="true" 
> value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}" /> 
> </li> 
> </ul> 
> </div> 
> 
> question : how can i press the select button via a js function ? 
> 
> best regards, 
> 
> ben 
> 
> 




Viele Grüße, best regards, 

Benjamin Bratkus 
-- 
Orientation in Objects GmbH 
Weinheimer Str. 68 
D-68309 Mannheim 
http://www.oio.de <http://www.oio.de/>  
Tel. +49(0)621-71839-0 
Fax +49(0)621-71839-50 

Amtsgericht Mannheim 
HRB 38348 



Re: howto click a t:commandbutton via js

Posted by Benjamin Bratkus <br...@oio.de>.
i guess you mean the onClick() for the submit button ? or do you mean i have to write my own method ?

ben

p.s. the onclick does not work...

On Tue, 22 May 2007 14:51:30 +0300, Ayhan Güngör wrote
> try
> ...
> document.getElementsByName('selectbutton').x_onClick();"/>
> ...
> 
> On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:hi folks,
> 
> actually i am fighting with my different browsers :P so for firefox 1.x and
> 2.x my app works fine but the same side within ie6 do not work.
> 
> means i fill in in a h:inputText a string and press return and i got the next
> view by using the button under the inpuText
> 
> ie ignores me :9
> 
> so i thought about something like :
> 
> <div>
> <label for="username">#{msg['add.byusername']} </label>
> <h:inputText id="username"value="#{myBean.userName}"
> x_onKeyPress="if(event.keyCode == 13)
> document.getElementsByName('selectbutton').doclick();"/>
> <!-- get the select button and press it ? ->
> </div>
> <div class="indent-large">
> <ul class="buttons">
> <li class="select">
> <t:commandButton id="selectbutton" name="selectbutton"
> action="#{myBean.select}" value="#{msg['action.select.label']}"
> title="#{msg['action.select.tooltip']}" />
> </li>
> <li class="cancel">
> <t:commandButton action="#{myBean.cancel}" immediate="true"
> value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}" />
> </li>
> </ul>
> </div>
> 
> question : how can i press the select button via a js function ?
> 
> best regards,
> 
> ben
> 
>

Viele Grüße, best regards,

Benjamin Bratkus 
-- 
Orientation in Objects GmbH 
Weinheimer Str. 68 
D-68309 Mannheim 
http://www.oio.de 
Tel. +49(0)621-71839-0 
Fax +49(0)621-71839-50

Amtsgericht Mannheim 
HRB 38348

 

Re: howto click a t:commandbutton via js

Posted by Ayhan Güngör <ag...@gmail.com>.
try
...
document.getElementsByName('selectbutton').onclick();"/>
...

On 5/22/07, Benjamin Bratkus <br...@oio.de> wrote:
>
> hi folks,
>
> actually i am fighting with my different browsers :P so for firefox 1.xand
> 2.x my app works fine but the same side within ie6 do not work.
>
> means i fill in in a h:inputText a string and press return and i got the
> next
> view by using the button under the inpuText
>
> ie ignores me :9
>
> so i thought about something like :
>
> <div>
> <label for="username">#{msg['add.byusername']} </label>
> <h:inputText id="username"value="#{myBean.userName}"
> onkeypress="if(event.keyCode == 13)
> document.getElementsByName('selectbutton').doclick();"/>
> <!-- get the select button and press it ? ->
> </div>
> <div class="indent-large">
> <ul class="buttons">
> <li class="select">
> <t:commandButton id="selectbutton" name="selectbutton"
> action="#{myBean.select}" value="#{msg['action.select.label']}"
> title="#{msg['action.select.tooltip']}" />
> </li>
> <li class="cancel">
> <t:commandButton action="#{myBean.cancel}" immediate="true"
> value="#{msg['action.cancel.label']}" title="#{msg['action.cancel.tooltip']}"
> />
> </li>
> </ul>
> </div>
>
> question : how can i press the select button via a js function ?
>
> best regards,
>
> ben
>
>