• Post Reply Bookmark Topic Watch Topic
  • New Topic

Opening in new window/tab is stripping my JSF and Primefaces formatting  RSS feed

 
David LeMmon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to open a another primefaces xhtml file that is part of my project into a separate tab or window. I need it to be able to have multiple independent copies of itself running at the same time.
All of them need to continue to use the same session and theme as the calling XHTML file.

My code opens the the xhtml in a different tab and has data from the database however it looks like it is not JSF/primefaces but unformatted/stripped/pure html. For example a tabview shows up as a bulleted list then below it it has what is in each tab in order of the tabs.



I'm not sure what I am doing wrong.

Here is the code that starts the call to open the window:


Here is the bean code that actually opens the file:



Here is the code that is opened:
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. JSF is not a platform that takes kindly to running in multiple windows/tabs.

2. Neither am I, for what it's worth. If you want to chase me (as a potential customer) away from your business, start popping open multiple windows.

3. Rule #1 for JSF: The more JSF-specific code in your app, the more likely you're doing it wrong. Without actually making the effort (see above), I'm about 95% certain that if I wanted to do what you are doing, I could do it all with POJO JSF without grabbing internal data structures.

4. Anddd.... The reason your code fails (discounting all of the above). You have confused a resource with a URL. JSF dispatches URLs, not resources, so you would not be using ".xhtml" as your target suffix.
 
David LeMmon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sigh, As you can probably tell I'm new to JSF and Primefaces, so I hope my questions don't come across as totally clueless.

The requirements that I was given for this screen tell me to make the page independent from the page that launched it, but maintain the same session with database the and allow for multiple instances of it that have different data in a data grid. I know that this is normally bad form is JSF, but what can I do? I've looked at multiple example of how to launch a new window and cobbled together what I have here.
Is there a better way of doing this?



BTW, I forgot to re-add the <h:head /> line to the xhtml file before I posted this thread. That has been taken care of.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF really doesn't like that.

Before I go into details, though, I should point out that if you are holding database sessions between web page requests, no matter how many or few the windows, you are strangling your webserver. Database sessions should exist ONLY as long as it takes to do the database operation within the request process and no longer. That's what connections pools are for.

The reason why JSF doesn't like multiple windows/tabs is that for a given instance of a web browser program, all windows and tabs share the same HTTP Session (which is not the same thing as a database session). You don't have any real choice in that. But since JSF managed beans at View and Session scope are all in the same HTTP session, you cannot create a separate backing bean for each open page. And if you have multiple pages against a backing bean at the same time, it's much the same as non-thread-safe access to traditional classes. Because changing the backing bean in one window will not automatically update any of the other windows (HTTP doesn't work like that), and so the other windows will now have stale data in them, which, if it's posted back against the backing bean can undo the previous changes without warning. In other words, a real mess unless a lot of care is taken. And, you can't just say "synchronized" on a backing bean for that kind of stuff, because not only will stale clients still exist regardless, but any synchronization will cease once the response is posted.

If you need multiple windows because you want some sort of "pop-up" (modal) dialog to allow editing object details, consider using one of the JSF extension libraries that actually supports modal dialogs. However, you should be aware that such dialogs get around the multiple window problem by popping up within their parent window, not as independent windows.
 
David LeMmon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,

if you are holding database sessions between web page requests

Sorry I used the wrong terminology. I did mean the HTTP Session and not the database session. As a newby I sometimes get my terminology mixed up causing plenty of confusion.

I have looked at dialogues and other options that are trapped within their parent window and they just wouldn't work for what I am working on. I wish that they did.

From what you said it seems to me that the best option might be to start a new HTTP session when each instance the page is called. Of course this adds authentication as well as other concerns to the list of things to take care of.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot start a new HTTP session on each page. The client (browser) doesn't work that way. It keeps a single jsessionid for every window and tab for that server. The only way you could have multiple sessions to the same J2EE server would be to disable cookies, use URL rewriting, and construct a rat's nest of schizophrenic logic that among other things would have to log in over and over and over again.

JSF really, really doesn't like what you're proposing. You may be better off using a non-Java application. Or at least a non-JSF one.
 
David LeMmon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sigh.... Thank you for your time and patience helping me.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!