previous bean modification next and modification not visible
Hi,
I have a succession of jsf pages. On the first I set values of my managed bean then I click next. On the second I set other values. If I return on the first page and change the values I reinitialize the values of the second page but if I click on the next button the changes are not visible.
If someone can help me it will be great.
[355 byte] By [
Baltaara] at [2007-11-27 1:35:06]

# 1
Hmm... It might be the way you are re-initializing the values. Or it could be that the page is being cached by the browser.
Put this inside the HEAD tag of all your pages:
<!-- Don't cache pages -->
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
If that's not working, then please post your "reinitialization" code.
CowKing
# 2
This doesn't work. So here is the reinitialization code :
protected void cleanStep2()
{
this.label = null;
webigeoCharts.clear();
}
The method is called in this called when I click on next button of the first page.
I put a println in the method so I know the reinitialization was done but when I click on next the problem is my getters of label and threeDimensional are not called.
# 3
I thought it works but I dreamt
# 4
I know you said my cache HTML doesn't work, but this is just screaming of browser cache problems. Before you do your next test run, add the HTML posted above, and completely clear your browser cache. Then click into your application after deploying it.
The thing that is bothering me is that your bean methods are not being called when you load the second page again. Somethings caching somewhere.
CowKing
# 5
I have already tested to clear the cache of my web browser.
It is worse when I put the code above in my pages.
Actually, the first and second pages are in a popup. When the popup is closed I clear the managed bean.
But with this code, when I open the popup after it was closed, when I arrived on my second page the label are still this I entered the first time.
Without this code it is null like my managed bean is a new.
# 6
Oh, it's in a pop-up. Well, that makes things different. You probably use onclick with a window.open call? The popup gets executed before your action method. So that code to reset your bean isn't run until after the window has already loaded.
A few people in this forum have run into the same problems. This is the best topic I could find in 5 minutes that relates to your issue.
http://forum.java.sun.com/thread.jspa?threadID=5130404
Use the search function on the forums to find more tormented souls.
CowKing
# 7
My code to reset my bean is executed during the unload of my popup. Furthermore if i don't put the metatag for the cache, if I create a new bean it's a new. The problem i have is just during the edition.
Example :
I create a new object. I'm on my first page.
I check a checkbox. I click on next. I set the different fields. I click on previous.
I check another checkbox. I click on next which reset all the variables called in my second page.
But this time the getters of my variables are not called so the values aren't resetted. They have their previous values
# 8
Ok...
When in your described process do you fire the pop-ups?
I'm also confused by this statement:
>My code to reset my bean is executed during the unload of my popup.
Really? How do you access the bean via JavaScript? Pop-ups and JavaScript are all client side technologies. It can't access the server side.
CowKing
# 9
On unload I call a javascript function which click on a jsf button which call a java action which reset the bean.It's as simple.
# 10
That clarifies the last part. But you didn't answer my question.
>When in your described process do you fire the pop-ups?
Take me through it step by step, like you did a couple posts ago. But go into more detail. Usually the "devil is in the details."
Also, since you did answer the last part... Can you confirm that your reset code (cleanStep2) is definitely being called at the right time? Because a) the method is protected. Which means only the bean itself should be able to call it (which is possible, but only if you're not telling me the whole story) and b) your clicking a button on a page that is unloading. I'm not sure the order JavaScript goes here, but is the page gone by the time you try to click the button?
CowKing
# 11
On the second page I have a button. When i click on it I call a method. This method set a boolean to true. On the load of this page, I have a javascript function which close the popup if the boolean is on true. And so the function which reset my bean is called.
But this is not this step which is a problem to me. Itworks well.
This is the action called on the button of my first page which is a problem to me when I have modify some variables previously setted because the getters of my second page are not called.
Example :
a b c
I check a.
I go on my second page. The getters are called.
I put "test" as title.
I go on my first page.
I check b. (so I reset the title)
I go on my second page.
The title is still "test". <-- Here is the problem because the getters are not called.
# 12
The problem may not be related with page cache.What is the scope of your backing bean? From you last post, it sounds like a session scope backing bean. If the scope is in session, it will use the cache value instead of reinvoke the getter.
# 13
This is the session scope. How can I do to reinvoke the getter. With the request scope I have too problems
# 14
Baltaar, this is very frustrating. Either I am not making myself clear, or you are not listening. Please search the forums for pop-ups, follow the link I already gave you, and fix your JavaScript. I'm convinced you are simply not executing things in the right order, or are resetting values after the response has already been committed.
Here's why... The following code works for me.
Page1 just has a next button on it. I click it to get to a second page.
Page2 has a selectBooleanCheckbox, and a back button. Page2:
<h:form id="form">
<h:commandLink id="backButtonImgTop" type="submit"
action="#{navigationBean.back}" >
<h:graphicImage id="backImgTop" value="/images/b_previous.gif"
alt="Return" height="18" width="18" />
</h:commandLink>
<h:selectBooleanCheckbox id="tcAgree"
value="#{commonInfoBean.accept}" validator="#{commonInfoBean.termsAccepted}" />
</h:form>
I click the tcAgree checkbox to true and click the back button. NavigationBean runs the button click code. It resets the checkbox value to false. NavigationBean.back:
public String back() {
if (AppLogger.isDebugEnabled()) {
AppLogger.debug("Navigation Back called by IP: '" + getIP() + "'...");
}
String previous = "Page1";
//DEBUGGING
CommonInfoBean cb = (CommonInfoBean)getBeanFromContext(COMMON_INFO_BEAN_NAME);
cb.setAccept(false);
//DEBUGGING
//return the last page viewed by the user
return previous;
}
From the first page (Page1) I click to next to go to the second page. The value has been appropriately reset. Here's my output...
[Apr 23, 14:07:44] DEBUG AppLogger.debug() - Navigation Next called by IP: '127.0.0.1'...
isAccept called. Value=false
[4/23/07 14:07:51:423 PDT] 1b050a5c SystemOutO isAccept called. Value=false
[4/23/07 14:07:51:423 PDT] 1b050a5c SystemOutO setAccept called. Value=true
[Apr 23, 14:07:51] DEBUG AppLogger.debug() - Navigation Back called by IP: '127.0.0.1'...
setAccept called. Value=false
[Apr 23, 14:19:55] DEBUG AppLogger.debug() - Navigation Next called by IP: '127.0.0.1'...
isAccept called. Value=false
All the beans I used are session scoped. I DID NOT include any JavaScript. My point is simply to say that it works without JavaScript and pop-ups in the way.
Baltaar, your problem is in your JavaScript like I've been trying to say all along.
CowKing
# 15
I have no javascript called when I click on next button and on previous button. Furthermore On my second page, I have a label, a checkbox and a datable with 3 columns. The datatable is well reseted. This is just the label and the checkbox. I can send you the code if you want.
For the way to open my popup it's simple.
My managed bean is null. I open a popup. The bean is created. Then I check a checkbox. I click next. Then I set a label. The I click previous. I change the checkbox. I click on next. In the method of next I reset the label. Then I arrive on the second page but the label getter is not called.
In edition it's different. I do like that (Advances techniques).
http://wiki.apache.org/myfaces/JavascriptOpenNewWindow
# 16
I tried the above example with resetting things when Page1 next is clicked. It still worked for me.
Thank you for clarifying two very important pieces of information:
1) You have no JavaScript between the two pages.
2) Your page is partially reset (datatable but not label and checkbox).
Hmm... Maybe, instead of setting your label to null, set it to a blank string (""). And the checkbox should default to false or true? Make sure you don't reset it to null, but to the actual default.
Can you post the pertinent pieces of the following code:
1) The next button of your first pages JSP, and the back button of your second pages JSP.
2) The action method or action listener that executes when the next button of your first JSP is clicked. And the same for the back button of your second JSP.
3) The corresponding navigation-rules in the faces-config.xml file.
4) The label, datatable and checkbox JSP from the second page.
Thanks,
CowKing
# 17
This came from the attribute immediate which was true. I put false and now it works. Is there any way to put the attribute to false and it works.