| Author |
Call a method when I go to another page JSF
|
Mario Gimenez
Ranch Hand
Joined: Mar 23, 2010
Posts: 38
|
|
Hi!.
I have a web application using jsf.
I have beanA in session and beanB in session
My problem is this.
I have a pageA and a pageB. in PageA a have a selectOneMenu component and in the Bean - @PostConstruct method I call a query to load an arraylist for the selectOneMenu,
In PageA I can delete , update and create new item for this list.
In pageB I must use this list (but I use another bean in session ). but here's the problem. because the bean is in session this list can't update whit the new values and I can't change session to request.
DO you have any ideas for solving this?
My idea is when I go to one page to another, update the data. I used binding but didn't work for me.
I want to do this:
When I stay in page B and I want to go to page A the value of the selectOneMenu update.
the code is this.
pageB
cargarComboEtiquetas is called in the @PostConstruct
and page A is the same. in pageA I only update, create and delete values for my list.
I hope I explain my problem.
I need help!!!
|
 |
Brendan Healey
Ranch Hand
Joined: May 12, 2009
Posts: 218
|
|
Instead of building the list with @PostConstruct, why not use a preRenderView event:
Then your updating page persists new values to the database, you navigate to the other page and the preRenderView
event fires, reloading from the database.
Regards,
Brendan.
p.s. the f:event tag needs to go inside f:metadata tags. This event fires on ajax postback and it's a good idea to check
if it's an ajax request and return early, if so desired.
|
 |
Mario Gimenez
Ranch Hand
Joined: Mar 23, 2010
Posts: 38
|
|
Hi
Thanks for your help!
I try that solution but it doesn't work for me.
I need to know in which place of the page I must put this line. Inside f:view or inside f:form ? or another place...
I go to page A to B but this event never stop in setupPage. Can you help me please?
Thanks!!!
|
 |
Brendan Healey
Ranch Hand
Joined: May 12, 2009
Posts: 218
|
|
Hi, this is the structure you require, note that the f:viewParam is a workaround for a horrible bug and it won't do any
harm:
Regards,
Brendan.
|
 |
Mario Gimenez
Ranch Hand
Joined: Mar 23, 2010
Posts: 38
|
|
thanks a lot!.
It's works only whit f:event inside the view!.
|
 |
Brendan Healey
Ranch Hand
Joined: May 12, 2009
Posts: 218
|
|
There you go then. Have a good day.
|
 |
 |
|
|
subject: Call a method when I go to another page JSF
|
|
|