You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marcos Prieto <ma...@gmail.com> on 2007/07/26 17:35:48 UTC

Call bean method

Hi,

I´m new to JSF  and I can´t figure out how to do this:

I want to open a jsf page in a pop up from another jsf and call a method
from a bean before the pop-up page is rendered.

I tried  to open the pop-up with commandButton (with onclick) and put the
method in the actionListener property but in order to get the event I think
the form must be submitted so the parent page reloads itself and the pop up
window is rendered before the event is handled so the effects of the method
cant be seen in the popup.

I tried to set the type of the button to "button" (instead of submit) but in
this way the event is never fired.

I can't put the method call in the bean constructor  either because is a
session bean.

So is there any way to get the method executed before the pop up is rendered
and without reloading the first page?

Thank you.

P.S. Sorry for my crappy English :S

Re: Call bean method

Posted by Alexander Wallace <aw...@rwmotloc.com>.
one way could be to put an element with a rendered attribute, which  
points to a boolean method in your bean... have the boolean method  
execute what you want...

hope this helps!

On Jul 26, 2007, at 10:35 AM, Marcos Prieto wrote:

> Hi,
>
> I´m new to JSF  and I can´t figure out how to do this:
>
> I want to open a jsf page in a pop up from another jsf and call a  
> method from a bean before the pop-up page is rendered.
>
> I tried  to open the pop-up with commandButton (with onclick) and  
> put the method in the actionListener property but in order to get  
> the event I think the form must be submitted so the parent page  
> reloads itself and the pop up window is rendered before the event  
> is handled so the effects of the method cant be seen in the popup.
>
> I tried to set the type of the button to "button" (instead of  
> submit) but in this way the event is never fired.
>
> I can't put the method call in the bean constructor  either because  
> is a session bean.
>
> So is there any way to get the method executed before the pop up is  
> rendered and without reloading the first page?
>
> Thank you.
>
> P.S. Sorry for my crappy English :S
>
>
>
>


Re: Call bean method

Posted by Simon Lessard <si...@gmail.com>.
Hello Marcos,

This will requires quite some work if you want to do this with basic JSF
libraries as using JavaScript hooks won't work to call the server with a
simple #{bean.method} expression. However, if you use Trinidad (or Shale I
believe) you'll have built-in support for this using launchListener feature.


Regards,

~ Simon

On 7/26/07, Marcos Prieto <ma...@gmail.com> wrote:
>
> Hi,
>
> I´m new to JSF  and I can´t figure out how to do this:
>
> I want to open a jsf page in a pop up from another jsf and call a method
> from a bean before the pop-up page is rendered.
>
> I tried  to open the pop-up with commandButton (with onclick) and put the
> method in the actionListener property but in order to get the event I think
> the form must be submitted so the parent page reloads itself and the pop up
> window is rendered before the event is handled so the effects of the method
> cant be seen in the popup.
>
> I tried to set the type of the button to "button" (instead of submit) but
> in this way the event is never fired.
>
> I can't put the method call in the bean constructor  either because is a
> session bean.
>
> So is there any way to get the method executed before the pop up is
> rendered and without reloading the first page?
>
> Thank you.
>
> P.S. Sorry for my crappy English :S
>
>
>
>
>