This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking if main page has changed  RSS feed

 
Neha Mahajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 managed beans(one for the main JSF page and one for the one opened in a popup).
I need to check if the main page has changed when i submit on the popup. Both beans are in request scope.
How to do it??
 
prakash pawar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Neha,

Can you please explain your problem in detail.

Regards
Prakash Pawar
 
Neha Mahajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am working with JSF and EJB3.0.
From a page in my application, I click on a link that opens a popup window(a JSF page).
I can minimize the popup and do actions on main page. However when I submit on the popup, i need to check if the main page has changed on the basis of some session variable may be. If say this variable indicates a change i throw an error.
Both the backup bean are in request scope. So how do I access this main page's backing bean in my popup's backing bean??

Such an implementation can be done in javascript by using window.opener and check some flag and throw a javascript alert but I am not allowed to use javascript.

If something is still unclear please point it out.
 
prakash pawar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neha

If i am getting it right you are opening the popup from link

so you can pass all those field (where you need validation on click of submit button) as a query string.

if there is any issue let me know.

Regards,
Prakash Pawar.

 
Neha Mahajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not getting it right. Read the post carefully.
I mean to say that i've already sent whatever I need to the popup using the request parameters. However, while the popup is open I can minimize it and make some actions on the main page from which I had opened the popup. If any such actions happen on the main page I need to retrieve that in the already opened popup and throw an error on a submit that the main page has changed.
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're not allowed to use JavaScript, you're pretty much out of luck.

I don't like popup pages, I have popup pages set to display in tabs, not as separate windows, but that's just my way of working and it's only important in that I'm not the only one who feels that way, so consider carefully before using popup pages to make sure you don't annoy important people.

Regardless of my own personal preferences, the reason I say you're out of luck is that HTTP is a request/response protocol. and JSF is based on HTTP. When I say request/response, I mean that everything that happens happens because a client makes a request and the server returns a response. To the same client that made the request. And, in this context, the word client means "the page that the request came from", not the browser application as a whole.

You can make a request whose reponse opens up a whole new (popup) window instead of the default action of displaying in the same page that the request came from. You can even name that target, so that if a target window with the same name exists already, whatever contents that target window had will be replaced with the new response.

What you cannot do is make a request in one page and update 2 separate pages from the same request. One request, one response. That's the architecturally-defined limit for HTTP. And never, ever, under any circumstances is an HTTP server permitted to send an unsolicited response to anywhere. Every response must come in answer to a request.

So it's architecturally impossible to submit a page and have both that page and a popup page both update off the same submit operation. To achieve that effect, you WILL need transcending tricks such as JavaScript. The next-closest solution is also a trick, which is to set a meta tag in the popup so that it periodically polls (via its own HTTP request) for updates in the backing bean. You can do that without JavaScript, but it's going to make the window "blink" periodically. And that can be even more annoying than a popup is to begin with.
 
Radu Mircea
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I believe that using Rich Faces could be another solution, but as i understood you don't use it.

 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Radu Mircea wrote:Hi ,

I believe that using Rich Faces could be another solution, but as i understood you don't use it.



The problem is, unless the prohibition is only on explicit JavaScript, RichFaces is out, too. It generates JavaScript to do its magic. Also, if you're thinking about the RichFaces popup dialog, that particular control doesn't show in a new window - at least by default. It actually overlays and blocks input to the page that contains it.
 
Neha Mahajan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the responses.

For the time being I have ultimately used javascript to retrieve a hidden variable from the parent window and based on that shown a message on the JSF popup page.
But I had to embed lot of javascript calls in the backing beans.

I would stil want some better solutions if possible.
I'm using Icefaces. Tim talked about RichFaces. What's the difference? Can Icefaces help?? Sorry I'm a novice in Icefaces also So got to ask..
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RichFaces and IceFaces are comparable products, both of which extend the capabilities of core JSF and both of which make it easier to use AJAX with JSF.

I'm out of date on specific features in IceFaces, so I can't address details, but the two products are a lot alike.
 
Radu Mircea
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also don't have experience with IceFaces but as Tim sad there are no such great differences between these two products, they do like the same things...

What about JQuery, try to use it, instead of standard javascript ;). May be they will allow it ;).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!