Has anyone ever had this happen to them? You load a JSF page, and you click on a submit button, and all it does is refresh the page.
Does anyone know why that happens?
rajani varma
Ranch Hand
Joined: Dec 21, 2006
Posts: 30
posted
0
Hello Tammy, There can be lot of reasons for this to happen, 1. If there is no action attribute defined 2. If there are any validation errors in the page, then the action method in the bean is not invoked and just the page refreshes. 3. If Navigation is not defined in the facesConfig.xml, then the same page refreshes....
Hope this helps you...
-Rajani
Tammy Easterby
Greenhorn
Joined: Jan 31, 2007
Posts: 28
posted
0
hi rajani,
thank you very much for the info.
the action is defined. when you click a button, the action is supposed to fire, and then the same page is supposed to come back with refreshed data. so i guess all that's left is maybe there's a validation error on the page. does that sound reasonable? and how would i check that?
- tammy
Remko Strating
Ranch Hand
Joined: Dec 28, 2006
Posts: 893
posted
0
Add a <h:messages /> tag to your page for displaying validation messages.
OK. I added <h:messages and there aren't any. So I'm doing some System.out's and discovered that it looks like it's doing an extra "restore view" cycle.
I'm using an SDO to talk to the database. So it calls the methods to fetch the information TWICE on the first button click, thereby resetting anything that was entered on the form. On the second button click, the method to fetch info from the database is called once, and the information entered on the form is saved.
Any ideas?
Ravindra Rawat
Ranch Hand
Joined: Dec 09, 2004
Posts: 34
posted
0
Try using immediate="true" on the submit button. If it works then probably it has something to do with validations.
Are there any valueChangeListeners on the page? if yes, try adding Sysouts there, Also check if FacesContext.responseComplete is being invoked anywhere in bean?
This is your third and last request to fix your display name.
We're a friendly group, but we do require members to have valid display names.
Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.
Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning
thanks, Dave
Tammy Easterby
Greenhorn
Joined: Jan 31, 2007
Posts: 28
posted
0
Thanks, everyone, for your help. I did try immediate="true" on the submit button. That didn't work. Everyone who mentioned validations was correct. As soon as I added a numeric validation to the fields I was trying to capture it was fine. I think JSF goes through the validations phase whether you are doing error checking or not. If you are *not* doing error checking, it will hit this phase and refresh the page on you. Good to know.
Thanks again, everyone.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.