• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF fix for selection of 0 index of drop down chrome browser

 
Pablo Ramirez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsf form which has a drop down. When I select any value in drop down it shows related details. When I use chrome browser, and I press back space key it comes back to the page, it keeps the value selected which was selected earlier, but in the firefox, IE it keeps the zero index selected. The same code is not working for chrome browser.

I would like the zero index to be selected in the drop down in previous page in chrome browser also when back space key is pressed. Can anyone tell me a fix for this.

Regards,
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What scope is the managed bean?
 
Pablo Ramirez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a @ViewScoped.
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pablo Ramirez wrote:When I use chrome browser, and I press back space key it comes back to the page


How come it shows the "same" page when you hit the back key?

page0 -> page1 (change drop down then hot back key) -> page1?
 
Pablo Ramirez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it shows page0 but page0 has drop down and i want the zero index of the drop down to be selected which is happening in firefox and IE but in chrome the value which was select earlier on page0 before moving to page1 remains selected on pressing the back space key.
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I see. Is it only the drop down menu have this issue, are the other (eg text, checkbox, radio) fields have values when you hit back?

Given the managed bean is ViewScope, I believe it will run the bean's default constructor every time the view is loaded, making the fields reset to null or 0 accordingly. But since hitting back may not be triggering the constructor, you can try verifying this by:
* make a default constructor for page0 managed bean
* print something to console inside
* run the code as usually, the first time will definitely have output
* change stuff, go to page1 then click back
* check if the print statement execute again

If not then "clicking back" does not trigger constructor.

Beside from my experience with browsers, if it works on firefox, chrome should be the same. Yet IE can cause trouble.
 
Pablo Ramirez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its only the dropdown menu. I will check what you said. But if clicking back does not trigger the constructor what is the workaround ? It happens only in chrome. I have another exactly same kind of page in jsp the same thing is happening there also on selecting the value from dropdown. I am using chrome 34 version.

Regards
 
Pablo Ramirez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have tried printing message in default constructor. The debugger does print the message in the console written in the default constructor. But can anyone tell me any fix for this issue.


Regards,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!