You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Leis, Matthias - SID-NLKM" <Ma...@sid.sachsen.de> on 2010/05/20 09:46:26 UTC

Click CommandButton from BackingBean

Hi!
 
Is it possible to click a <h:commandButton> from JavaCode?
 
Code I have so far:
 
public void clickButton() {

FacesContext currentInstance = FacesContext.getCurrentInstance();

UIComponent component =
currentInstance.getViewRoot().findComponent("submit");

if (component instanceof HtmlCommandButton) {

    HtmlCommandButton submit = (HtmlCommandButton)component;

   }

}

This method is called by another button. The button I want to click is
hidden on purpose. Now I need something like submit.click(). Is there a
way?
 
Thanks for any help :)

AW: Click CommandButton from BackingBean

Posted by "Leis, Matthias - SID-NLKM" <Ma...@sid.sachsen.de>.
Hi Tobias,

The webservice responses by redirecting me to another webserver... It's simpler with the webform. But I consider to follow your suggestion, because it's indeed a lot more clean :)
 


Staatsbetrieb Sächsische Informatik Dienste -
Niederlassung Kamenz
Macherstr. 63
01917 Kamenz
E-Mail: Matthias.Leis@sid.sachsen.de

-----Ursprüngliche Nachricht-----
Von: users-return-56622-Matthias.Leis=sid.sachsen.de@myfaces.apache.org [mailto:users-return-56622-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Eisenträger, Tobias
Gesendet: Donnerstag, 20. Mai 2010 16:38
An: MyFaces Discussion
Betreff: AW: Click CommandButton from BackingBean

Hello Matthias,

why don't you just submit the form normally to your webserver and let the webserver post to the web service? - This would probably be a lot more clean - architecture wise. 


Mit freundlichen Grüßen 


Tobias Eisenträger

Softwareentwickler
Dokumentenmanagement/Workflow/Internet, AKB 8125 
ARAG IT GmbH
ARAG Platz 1, 40472 Düsseldorf
Tel.: +49 (0)211 964-1937
tobias.eisentraeger@arag.de
www.ARAG.de

Aufsichtsratsvorsitzender:

Gerd Peskes
Vorstand:
Dr. Paul-Otto Faßbender (Vors.),
Dr. Jan-Peter Horst,
Dr. Johannes Kathan, Werner Nicoll,
Hanno Petersen, Dr. Joerg Schwarze
Sitz und Registergericht:
Düsseldorf, HRB 1371
USt-ID-Nr.: DE 119 355 995


> -----Ursprüngliche Nachricht-----
> Von: Leis, Matthias - SID-NLKM [mailto:Matthias.Leis@sid.sachsen.de]
> Gesendet: Donnerstag, 20. Mai 2010 15:59
> An: MyFaces Discussion
> Betreff: AW: Click CommandButton from BackingBean
> 
> My Use Case:
> I have a html-form to make a post request to some webservice by clicking
> the submit-button.
> 
> My Problem:
> I am using a t:panelTabbedPane. I have to use a plain html-form, because
> the value of the action-attribute is the URL of the webservice (and as far
> as I know there is no way to define this value in a h:form).
> For some reasons (I guess because of the t:panelTabbedPane) a plain html-
> form isn't displayed on the page, when placed inside the
> t:panelTabbedPane. Outside of the t:panelTabbedPane it works. So I put
> this form outside of the t:panelTabbedPane and hide it per css. But the
> button that triggers the post request has to be inside the
> t:panelTabbedPane, so my idea was: html-form outside, visible button
> inside, visible button "clicks" hidden button. But this doesn't work. But
> if I place my visible button outside the t:panelTabbedPane (with the
> actionListener code you provided) it works... But it's senseless, because
> outside of the t:panelTabbedPane my plain html-form works anyway.
> 
> 
> Staatsbetrieb Sächsische Informatik Dienste -
> Niederlassung Kamenz
> Macherstr. 63
> 01917 Kamenz
> E-Mail: Matthias.Leis@sid.sachsen.de
> 
> -----Ursprüngliche Nachricht-----
> Von: users-return-56620-Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> [mailto:users-return-56620-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Vinod
> Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 15:15
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
> 
> I didnt quite follow you. could you please explain more..
> explain your use case as well
> 
> On Thu, May 20, 2010 at 5:07 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
> 
> > Thanks, it works! :)
> >
> > Another problem arises... It doesn't work inside a t:panelTabbedPane.
> > By the way, this problem was the reason for the hidden button. The
> visible
> > button was should be inside the t:panelTabbedPane, which then clicks the
> > hidden button outside the t:panelTabbedPane. Argh
> >
> >
> > Staatsbetrieb Sächsische Informatik Dienste -
> > Niederlassung Kamenz
> > Macherstr. 63
> > 01917 Kamenz
> > E-Mail: Matthias.Leis@sid.sachsen.de
> >
> > -----Ursprüngliche Nachricht-----
> > Von: users-return-56618-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> > users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > Auftrag von Vinod Krishnan
> > Gesendet: Donnerstag, 20. Mai 2010 13:20
> > An: MyFaces Discussion
> > Betreff: Re: Click CommandButton from BackingBean
> >
> > it should be like
> >
> > hiddenButton.queueEvent(new ActionEvent(hiddenButton));
> >
> > On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
> > Matthias.Leis@sid.sachsen.de> wrote:
> >
> > > Vinod, thank you for your post.
> > > I'm not sure, if I completely understood you, but I tried the
> following.
> > >
> > > The visible button has now an actionListener. In this actionListener I
> do
> > > hidden.queueEvent(e);
> > >
> > > Where "hidden" is the hidden CommandButton (the one I want to click
> > > programmatically) and "e" is the ActionEvent of my visible
> CommandButton
> > > (the one that has the actionListener).
> > >
> > > When I click the visible CommandButton, the application runs in a
> loop,
> > > where the console repeats:
> > >
> > > "[FlowActionListener] No action event detected"
> > >
> > > over and over.
> > >
> > > Where did I get you wrong?
> > >
> > > Thanks again! :)
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: users-return-56614-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> > [mailto:
> > > users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > > Auftrag von Vinod Krishnan
> > > Gesendet: Donnerstag, 20. Mai 2010 10:53
> > > An: MyFaces Discussion
> > > Betreff: Re: Click CommandButton from BackingBean
> > >
> > > yes you can do that using a binding for the second button and do it
> like
> > > queuing the event in the actionlistener of the first button
> > >
> > > getButton1().queueEvent(new ActionEvent(getButton2()));
> > >
> > > On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> > > Matthias.Leis@sid.sachsen.de> wrote:
> > >
> > > > Hi!
> > > >
> > > > Is it possible to click a <h:commandButton> from JavaCode?
> > > >
> > > > Code I have so far:
> > > >
> > > > public void clickButton() {
> > > >
> > > > FacesContext currentInstance = FacesContext.getCurrentInstance();
> > > >
> > > > UIComponent component =
> > > > currentInstance.getViewRoot().findComponent("submit");
> > > >
> > > > if (component instanceof HtmlCommandButton) {
> > > >
> > > >    HtmlCommandButton submit = (HtmlCommandButton)component;
> > > >
> > > >   }
> > > >
> > > > }
> > > >
> > > > This method is called by another button. The button I want to click
> is
> > > > hidden on purpose. Now I need something like submit.click(). Is
> there a
> > > > way?
> > > >
> > > > Thanks for any help :)
> > > >
> > >
> >

AW: Click CommandButton from BackingBean

Posted by Eisenträger, Tobias <To...@arag.de>.
Hello Matthias,

why don't you just submit the form normally to your webserver and let the webserver post to the web service? - This would probably be a lot more clean - architecture wise. 


Mit freundlichen Grüßen 


Tobias Eisenträger

Softwareentwickler
Dokumentenmanagement/Workflow/Internet, AKB 8125 
ARAG IT GmbH
ARAG Platz 1, 40472 Düsseldorf
Tel.: +49 (0)211 964-1937
tobias.eisentraeger@arag.de
www.ARAG.de

Aufsichtsratsvorsitzender:

Gerd Peskes
Vorstand:
Dr. Paul-Otto Faßbender (Vors.),
Dr. Jan-Peter Horst,
Dr. Johannes Kathan, Werner Nicoll,
Hanno Petersen, Dr. Joerg Schwarze
Sitz und Registergericht:
Düsseldorf, HRB 1371
USt-ID-Nr.: DE 119 355 995


> -----Ursprüngliche Nachricht-----
> Von: Leis, Matthias - SID-NLKM [mailto:Matthias.Leis@sid.sachsen.de]
> Gesendet: Donnerstag, 20. Mai 2010 15:59
> An: MyFaces Discussion
> Betreff: AW: Click CommandButton from BackingBean
> 
> My Use Case:
> I have a html-form to make a post request to some webservice by clicking
> the submit-button.
> 
> My Problem:
> I am using a t:panelTabbedPane. I have to use a plain html-form, because
> the value of the action-attribute is the URL of the webservice (and as far
> as I know there is no way to define this value in a h:form).
> For some reasons (I guess because of the t:panelTabbedPane) a plain html-
> form isn't displayed on the page, when placed inside the
> t:panelTabbedPane. Outside of the t:panelTabbedPane it works. So I put
> this form outside of the t:panelTabbedPane and hide it per css. But the
> button that triggers the post request has to be inside the
> t:panelTabbedPane, so my idea was: html-form outside, visible button
> inside, visible button "clicks" hidden button. But this doesn't work. But
> if I place my visible button outside the t:panelTabbedPane (with the
> actionListener code you provided) it works... But it's senseless, because
> outside of the t:panelTabbedPane my plain html-form works anyway.
> 
> 
> Staatsbetrieb Sächsische Informatik Dienste -
> Niederlassung Kamenz
> Macherstr. 63
> 01917 Kamenz
> E-Mail: Matthias.Leis@sid.sachsen.de
> 
> -----Ursprüngliche Nachricht-----
> Von: users-return-56620-Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> [mailto:users-return-56620-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Vinod
> Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 15:15
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
> 
> I didnt quite follow you. could you please explain more..
> explain your use case as well
> 
> On Thu, May 20, 2010 at 5:07 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
> 
> > Thanks, it works! :)
> >
> > Another problem arises... It doesn't work inside a t:panelTabbedPane.
> > By the way, this problem was the reason for the hidden button. The
> visible
> > button was should be inside the t:panelTabbedPane, which then clicks the
> > hidden button outside the t:panelTabbedPane. Argh
> >
> >
> > Staatsbetrieb Sächsische Informatik Dienste -
> > Niederlassung Kamenz
> > Macherstr. 63
> > 01917 Kamenz
> > E-Mail: Matthias.Leis@sid.sachsen.de
> >
> > -----Ursprüngliche Nachricht-----
> > Von: users-return-56618-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> > users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > Auftrag von Vinod Krishnan
> > Gesendet: Donnerstag, 20. Mai 2010 13:20
> > An: MyFaces Discussion
> > Betreff: Re: Click CommandButton from BackingBean
> >
> > it should be like
> >
> > hiddenButton.queueEvent(new ActionEvent(hiddenButton));
> >
> > On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
> > Matthias.Leis@sid.sachsen.de> wrote:
> >
> > > Vinod, thank you for your post.
> > > I'm not sure, if I completely understood you, but I tried the
> following.
> > >
> > > The visible button has now an actionListener. In this actionListener I
> do
> > > hidden.queueEvent(e);
> > >
> > > Where "hidden" is the hidden CommandButton (the one I want to click
> > > programmatically) and "e" is the ActionEvent of my visible
> CommandButton
> > > (the one that has the actionListener).
> > >
> > > When I click the visible CommandButton, the application runs in a
> loop,
> > > where the console repeats:
> > >
> > > "[FlowActionListener] No action event detected"
> > >
> > > over and over.
> > >
> > > Where did I get you wrong?
> > >
> > > Thanks again! :)
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: users-return-56614-
> Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> > [mailto:
> > > users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > > Auftrag von Vinod Krishnan
> > > Gesendet: Donnerstag, 20. Mai 2010 10:53
> > > An: MyFaces Discussion
> > > Betreff: Re: Click CommandButton from BackingBean
> > >
> > > yes you can do that using a binding for the second button and do it
> like
> > > queuing the event in the actionlistener of the first button
> > >
> > > getButton1().queueEvent(new ActionEvent(getButton2()));
> > >
> > > On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> > > Matthias.Leis@sid.sachsen.de> wrote:
> > >
> > > > Hi!
> > > >
> > > > Is it possible to click a <h:commandButton> from JavaCode?
> > > >
> > > > Code I have so far:
> > > >
> > > > public void clickButton() {
> > > >
> > > > FacesContext currentInstance = FacesContext.getCurrentInstance();
> > > >
> > > > UIComponent component =
> > > > currentInstance.getViewRoot().findComponent("submit");
> > > >
> > > > if (component instanceof HtmlCommandButton) {
> > > >
> > > >    HtmlCommandButton submit = (HtmlCommandButton)component;
> > > >
> > > >   }
> > > >
> > > > }
> > > >
> > > > This method is called by another button. The button I want to click
> is
> > > > hidden on purpose. Now I need something like submit.click(). Is
> there a
> > > > way?
> > > >
> > > > Thanks for any help :)
> > > >
> > >
> >

AW: Click CommandButton from BackingBean

Posted by "Leis, Matthias - SID-NLKM" <Ma...@sid.sachsen.de>.
My Use Case:
I have a html-form to make a post request to some webservice by clicking the submit-button.

My Problem:
I am using a t:panelTabbedPane. I have to use a plain html-form, because the value of the action-attribute is the URL of the webservice (and as far as I know there is no way to define this value in a h:form).
For some reasons (I guess because of the t:panelTabbedPane) a plain html-form isn't displayed on the page, when placed inside the t:panelTabbedPane. Outside of the t:panelTabbedPane it works. So I put this form outside of the t:panelTabbedPane and hide it per css. But the button that triggers the post request has to be inside the t:panelTabbedPane, so my idea was: html-form outside, visible button inside, visible button "clicks" hidden button. But this doesn't work. But if I place my visible button outside the t:panelTabbedPane (with the actionListener code you provided) it works... But it's senseless, because outside of the t:panelTabbedPane my plain html-form works anyway.


Staatsbetrieb Sächsische Informatik Dienste -
Niederlassung Kamenz
Macherstr. 63
01917 Kamenz
E-Mail: Matthias.Leis@sid.sachsen.de

-----Ursprüngliche Nachricht-----
Von: users-return-56620-Matthias.Leis=sid.sachsen.de@myfaces.apache.org [mailto:users-return-56620-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Vinod Krishnan
Gesendet: Donnerstag, 20. Mai 2010 15:15
An: MyFaces Discussion
Betreff: Re: Click CommandButton from BackingBean

I didnt quite follow you. could you please explain more..
explain your use case as well

On Thu, May 20, 2010 at 5:07 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Thanks, it works! :)
>
> Another problem arises... It doesn't work inside a t:panelTabbedPane.
> By the way, this problem was the reason for the hidden button. The visible
> button was should be inside the t:panelTabbedPane, which then clicks the
> hidden button outside the t:panelTabbedPane. Argh
>
>
> Staatsbetrieb Sächsische Informatik Dienste -
> Niederlassung Kamenz
> Macherstr. 63
> 01917 Kamenz
> E-Mail: Matthias.Leis@sid.sachsen.de
>
> -----Ursprüngliche Nachricht-----
> Von: users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> Auftrag von Vinod Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 13:20
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
>
> it should be like
>
> hiddenButton.queueEvent(new ActionEvent(hiddenButton));
>
> On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
>
> > Vinod, thank you for your post.
> > I'm not sure, if I completely understood you, but I tried the following.
> >
> > The visible button has now an actionListener. In this actionListener I do
> > hidden.queueEvent(e);
> >
> > Where "hidden" is the hidden CommandButton (the one I want to click
> > programmatically) and "e" is the ActionEvent of my visible CommandButton
> > (the one that has the actionListener).
> >
> > When I click the visible CommandButton, the application runs in a loop,
> > where the console repeats:
> >
> > "[FlowActionListener] No action event detected"
> >
> > over and over.
> >
> > Where did I get you wrong?
> >
> > Thanks again! :)
> >
> > -----Ursprüngliche Nachricht-----
> > Von: users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> [mailto:
> > users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > Auftrag von Vinod Krishnan
> > Gesendet: Donnerstag, 20. Mai 2010 10:53
> > An: MyFaces Discussion
> > Betreff: Re: Click CommandButton from BackingBean
> >
> > yes you can do that using a binding for the second button and do it like
> > queuing the event in the actionlistener of the first button
> >
> > getButton1().queueEvent(new ActionEvent(getButton2()));
> >
> > On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> > Matthias.Leis@sid.sachsen.de> wrote:
> >
> > > Hi!
> > >
> > > Is it possible to click a <h:commandButton> from JavaCode?
> > >
> > > Code I have so far:
> > >
> > > public void clickButton() {
> > >
> > > FacesContext currentInstance = FacesContext.getCurrentInstance();
> > >
> > > UIComponent component =
> > > currentInstance.getViewRoot().findComponent("submit");
> > >
> > > if (component instanceof HtmlCommandButton) {
> > >
> > >    HtmlCommandButton submit = (HtmlCommandButton)component;
> > >
> > >   }
> > >
> > > }
> > >
> > > This method is called by another button. The button I want to click is
> > > hidden on purpose. Now I need something like submit.click(). Is there a
> > > way?
> > >
> > > Thanks for any help :)
> > >
> >
>

Re: Click CommandButton from BackingBean

Posted by Vinod Krishnan <vi...@gmail.com>.
I didnt quite follow you. could you please explain more..
explain your use case as well

On Thu, May 20, 2010 at 5:07 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Thanks, it works! :)
>
> Another problem arises... It doesn't work inside a t:panelTabbedPane.
> By the way, this problem was the reason for the hidden button. The visible
> button was should be inside the t:panelTabbedPane, which then clicks the
> hidden button outside the t:panelTabbedPane. Argh
>
>
> Staatsbetrieb Sächsische Informatik Dienste -
> Niederlassung Kamenz
> Macherstr. 63
> 01917 Kamenz
> E-Mail: Matthias.Leis@sid.sachsen.de
>
> -----Ursprüngliche Nachricht-----
> Von: users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> Auftrag von Vinod Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 13:20
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
>
> it should be like
>
> hiddenButton.queueEvent(new ActionEvent(hiddenButton));
>
> On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
>
> > Vinod, thank you for your post.
> > I'm not sure, if I completely understood you, but I tried the following.
> >
> > The visible button has now an actionListener. In this actionListener I do
> > hidden.queueEvent(e);
> >
> > Where "hidden" is the hidden CommandButton (the one I want to click
> > programmatically) and "e" is the ActionEvent of my visible CommandButton
> > (the one that has the actionListener).
> >
> > When I click the visible CommandButton, the application runs in a loop,
> > where the console repeats:
> >
> > "[FlowActionListener] No action event detected"
> >
> > over and over.
> >
> > Where did I get you wrong?
> >
> > Thanks again! :)
> >
> > -----Ursprüngliche Nachricht-----
> > Von: users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org
> [mailto:
> > users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> > Auftrag von Vinod Krishnan
> > Gesendet: Donnerstag, 20. Mai 2010 10:53
> > An: MyFaces Discussion
> > Betreff: Re: Click CommandButton from BackingBean
> >
> > yes you can do that using a binding for the second button and do it like
> > queuing the event in the actionlistener of the first button
> >
> > getButton1().queueEvent(new ActionEvent(getButton2()));
> >
> > On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> > Matthias.Leis@sid.sachsen.de> wrote:
> >
> > > Hi!
> > >
> > > Is it possible to click a <h:commandButton> from JavaCode?
> > >
> > > Code I have so far:
> > >
> > > public void clickButton() {
> > >
> > > FacesContext currentInstance = FacesContext.getCurrentInstance();
> > >
> > > UIComponent component =
> > > currentInstance.getViewRoot().findComponent("submit");
> > >
> > > if (component instanceof HtmlCommandButton) {
> > >
> > >    HtmlCommandButton submit = (HtmlCommandButton)component;
> > >
> > >   }
> > >
> > > }
> > >
> > > This method is called by another button. The button I want to click is
> > > hidden on purpose. Now I need something like submit.click(). Is there a
> > > way?
> > >
> > > Thanks for any help :)
> > >
> >
>

AW: Click CommandButton from BackingBean

Posted by "Leis, Matthias - SID-NLKM" <Ma...@sid.sachsen.de>.
Thanks, it works! :)

Another problem arises... It doesn't work inside a t:panelTabbedPane. 
By the way, this problem was the reason for the hidden button. The visible button was should be inside the t:panelTabbedPane, which then clicks the hidden button outside the t:panelTabbedPane. Argh


Staatsbetrieb Sächsische Informatik Dienste -
Niederlassung Kamenz
Macherstr. 63
01917 Kamenz
E-Mail: Matthias.Leis@sid.sachsen.de

-----Ursprüngliche Nachricht-----
Von: users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org [mailto:users-return-56618-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Vinod Krishnan
Gesendet: Donnerstag, 20. Mai 2010 13:20
An: MyFaces Discussion
Betreff: Re: Click CommandButton from BackingBean

it should be like

hiddenButton.queueEvent(new ActionEvent(hiddenButton));

On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Vinod, thank you for your post.
> I'm not sure, if I completely understood you, but I tried the following.
>
> The visible button has now an actionListener. In this actionListener I do
> hidden.queueEvent(e);
>
> Where "hidden" is the hidden CommandButton (the one I want to click
> programmatically) and "e" is the ActionEvent of my visible CommandButton
> (the one that has the actionListener).
>
> When I click the visible CommandButton, the application runs in a loop,
> where the console repeats:
>
> "[FlowActionListener] No action event detected"
>
> over and over.
>
> Where did I get you wrong?
>
> Thanks again! :)
>
> -----Ursprüngliche Nachricht-----
> Von: users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> Auftrag von Vinod Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 10:53
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
>
> yes you can do that using a binding for the second button and do it like
> queuing the event in the actionlistener of the first button
>
> getButton1().queueEvent(new ActionEvent(getButton2()));
>
> On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
>
> > Hi!
> >
> > Is it possible to click a <h:commandButton> from JavaCode?
> >
> > Code I have so far:
> >
> > public void clickButton() {
> >
> > FacesContext currentInstance = FacesContext.getCurrentInstance();
> >
> > UIComponent component =
> > currentInstance.getViewRoot().findComponent("submit");
> >
> > if (component instanceof HtmlCommandButton) {
> >
> >    HtmlCommandButton submit = (HtmlCommandButton)component;
> >
> >   }
> >
> > }
> >
> > This method is called by another button. The button I want to click is
> > hidden on purpose. Now I need something like submit.click(). Is there a
> > way?
> >
> > Thanks for any help :)
> >
>

Re: Click CommandButton from BackingBean

Posted by Vinod Krishnan <vi...@gmail.com>.
it should be like

hiddenButton.queueEvent(new ActionEvent(hiddenButton));

On Thu, May 20, 2010 at 4:41 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Vinod, thank you for your post.
> I'm not sure, if I completely understood you, but I tried the following.
>
> The visible button has now an actionListener. In this actionListener I do
> hidden.queueEvent(e);
>
> Where "hidden" is the hidden CommandButton (the one I want to click
> programmatically) and "e" is the ActionEvent of my visible CommandButton
> (the one that has the actionListener).
>
> When I click the visible CommandButton, the application runs in a loop,
> where the console repeats:
>
> "[FlowActionListener] No action event detected"
>
> over and over.
>
> Where did I get you wrong?
>
> Thanks again! :)
>
> -----Ursprüngliche Nachricht-----
> Von: users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org[mailto:
> users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im
> Auftrag von Vinod Krishnan
> Gesendet: Donnerstag, 20. Mai 2010 10:53
> An: MyFaces Discussion
> Betreff: Re: Click CommandButton from BackingBean
>
> yes you can do that using a binding for the second button and do it like
> queuing the event in the actionlistener of the first button
>
> getButton1().queueEvent(new ActionEvent(getButton2()));
>
> On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
> Matthias.Leis@sid.sachsen.de> wrote:
>
> > Hi!
> >
> > Is it possible to click a <h:commandButton> from JavaCode?
> >
> > Code I have so far:
> >
> > public void clickButton() {
> >
> > FacesContext currentInstance = FacesContext.getCurrentInstance();
> >
> > UIComponent component =
> > currentInstance.getViewRoot().findComponent("submit");
> >
> > if (component instanceof HtmlCommandButton) {
> >
> >    HtmlCommandButton submit = (HtmlCommandButton)component;
> >
> >   }
> >
> > }
> >
> > This method is called by another button. The button I want to click is
> > hidden on purpose. Now I need something like submit.click(). Is there a
> > way?
> >
> > Thanks for any help :)
> >
>

AW: Click CommandButton from BackingBean

Posted by "Leis, Matthias - SID-NLKM" <Ma...@sid.sachsen.de>.
Vinod, thank you for your post.
I'm not sure, if I completely understood you, but I tried the following.

The visible button has now an actionListener. In this actionListener I do
hidden.queueEvent(e);

Where "hidden" is the hidden CommandButton (the one I want to click programmatically) and "e" is the ActionEvent of my visible CommandButton (the one that has the actionListener).

When I click the visible CommandButton, the application runs in a loop, where the console repeats:

"[FlowActionListener] No action event detected" 

over and over.

Where did I get you wrong?

Thanks again! :)

-----Ursprüngliche Nachricht-----
Von: users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org [mailto:users-return-56614-Matthias.Leis=sid.sachsen.de@myfaces.apache.org] Im Auftrag von Vinod Krishnan
Gesendet: Donnerstag, 20. Mai 2010 10:53
An: MyFaces Discussion
Betreff: Re: Click CommandButton from BackingBean

yes you can do that using a binding for the second button and do it like
queuing the event in the actionlistener of the first button

getButton1().queueEvent(new ActionEvent(getButton2()));

On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Hi!
>
> Is it possible to click a <h:commandButton> from JavaCode?
>
> Code I have so far:
>
> public void clickButton() {
>
> FacesContext currentInstance = FacesContext.getCurrentInstance();
>
> UIComponent component =
> currentInstance.getViewRoot().findComponent("submit");
>
> if (component instanceof HtmlCommandButton) {
>
>    HtmlCommandButton submit = (HtmlCommandButton)component;
>
>   }
>
> }
>
> This method is called by another button. The button I want to click is
> hidden on purpose. Now I need something like submit.click(). Is there a
> way?
>
> Thanks for any help :)
>

Re: Click CommandButton from BackingBean

Posted by Vinod Krishnan <vi...@gmail.com>.
yes you can do that using a binding for the second button and do it like
queuing the event in the actionlistener of the first button

getButton1().queueEvent(new ActionEvent(getButton2()));

On Thu, May 20, 2010 at 1:16 PM, Leis, Matthias - SID-NLKM <
Matthias.Leis@sid.sachsen.de> wrote:

> Hi!
>
> Is it possible to click a <h:commandButton> from JavaCode?
>
> Code I have so far:
>
> public void clickButton() {
>
> FacesContext currentInstance = FacesContext.getCurrentInstance();
>
> UIComponent component =
> currentInstance.getViewRoot().findComponent("submit");
>
> if (component instanceof HtmlCommandButton) {
>
>    HtmlCommandButton submit = (HtmlCommandButton)component;
>
>   }
>
> }
>
> This method is called by another button. The button I want to click is
> hidden on purpose. Now I need something like submit.click(). Is there a
> way?
>
> Thanks for any help :)
>