File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Execute backing bean method on another page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Execute backing bean method on another page?" Watch "Execute backing bean method on another page?" New topic

Execute backing bean method on another page?

Kristian Jones

Joined: Jun 26, 2008
Posts: 6
Hi all
I would appreciate any suggesstions on the following scenario. I have the following.

Page 1:
Command Button

Page 2:

When a user presses the command button on page 1 I wish to execute PrePopulateFields() and then direct the user to that page or redirect the user then call PrePopulateFields(); I'm not fussy so long as the fields displayed are updated.

Can anyone tell me whether this is possible and how to do it.

Thanks in advance
[ June 26, 2008: Message edited by: Bear Bibeault ]
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
Is the Command Button's action listener in the same Backing Bean as "PrePopulateFields" function? If so, just call the function in the command button's action listener's function. If they are in separate Backing Beans (I don't why it should be), take the instance of the BB from the faces context and execute the function.

I hope I understood the question correctly.

Regards,<br />Joe<br /> <br />"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."<br />--Martin Golding
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17280

I also am unclear.

You can have one backing bean reference another backing bean by using the faces-config file to inject the referenced bean into the referencing bean.

However, if you're expecting to click a button in one web browser window or tab and have the properties updated in another window or tab, that's not possible. JSF is using HTTP and HTTP requires that all responses come back to the same place that the request came from.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Execute backing bean method on another page?
It's not a secret anymore!