tags:

views:

2564

answers:

7

Hi folks,

I`m new to JSF world please help me out in generating a pop up window in the page.

Here is my requirement I will be having a list of links in my master page(parent) on click of each link I need to show a pop up which contains some details, which I need to get from DB in the pop up mbean. I will have few buttons in my pop up and for each and every action I will be having a DB operation accordingly. I have tried out different ways and I failed.

The problem that I'm facing is when pop up loading for the first time it's well and good and projecting the values as expected. But for the second time it showing the new values in the init funtion and i cant see the new values on the screen insted its showing the first pop up values.

:confused: please help me....

Thanks in anticipation


Thanks & Regards, Shivaji Byrapaneni.

A: 

So (if I understand your problem correctly) the problem is that the second time the modified values of the bean are not making their way to the front end?

I'm surprised that this changes depending on whether it's in a pop-up or not.

Some thoughts:

  • Presumably when you open this pop-up you are just accessing a page i.e. http://localhost:8080/myApp/myPopupURL?
  • Is the mbean (when you say mbean you mean a java object you access with #{name.javaBeanField} right?) request or session scoped?
  • What are you doing to get this result? Are you clicking the pop-up link, then clicking the link again (expected the already opened pop-up to refresh)? Or are you clicking the link, closing the pop-up and clicking the link again? Or are you clicking the link and then refreshing the pop-up?

I don't have a working JSF setup going at the moment, but if I did I would try creating a single JSF page with a link. That link would open a popup which would point to a static URL (like the example above). The static URL would map to a really simple mbean that did something simple, like show an int that is a random number between 1 and a million.

Getting that working would at least exclude the possibilty of anything else being wrong. I have sometimes had issues with JSF randomly eating exceptions and having the page refresh with old values (since the life-cycle did not complete).

SCdF
A: 

Not really sure if it's standard JSF (i'm pretty sure it isn't, actually), but you should have an isPostBack() method in your backing beans that allows you to know if you're loading the page for the first time or are reloading it after an action; if you could use the isPostBack() method, you would be able to load the values from the DB only on the first page load without overwriting the modified values after the actions.

Raibaz
A: 

Seems like cache related to me but check the following:

  • Have you debugged and seen the correct values in the bean;
  • Have you made sure that it is form that bean that the values are fetched;
  • Are you sure that the browser hits the server the second time?; and
  • Have you parsed the logs (and activated them!) and made sure there are no errors?
Loki
+1  A: 

Have you checked your faces-config.xml file to make sure your bean is in request scope ?

<managed-bean-scope>request</managed-bean-scope>

If you bean is in session or application scope, the bean is not re-created each time you refresh the page so the values in the bean would not change.

Mark Robinson
A: 

It would be useful to know how are you showing the popup and if you are using some JSF component to do it. If you are just showing a hidden div (or anything that you load once when the master page loads) you may not be rendering that div again so the data is not actualized.

Averroes
A: 

I am not such a big programmer for JSF, but I guess you need JavaScript to trigger popups on click event.JSF is a server side Java framework, so it might not be able to open a new window.I am not sure for this answer. used to use this link to learn JSF thought: http://www.javapassion.com/handsonlabs/jsfsimpleapps/#Exercise%5F1

P.M
A: 

MyFaces Orchestra has support for multi-window applications out-of-the-box.

Bozho