• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening Multiple Windows from a Single JSF CommandButton click

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, all,

I have a situation, that I'm not sure is possible and I wanted feedback on. I have a JSF page with a commandButton on it. When the user clicks that button, they want code to execute in the eventhandler class that will generate a PDF file and display that PDF in a new window. They also want a Crystal Report to be run via the Crystal JRC API and have that displayed in a second window. So, in the requirements, on clicking this one button, they expect to have three browser windows open up(one with the original screen, one with a PDF, and one with a Crystal Report viewer). Plus, though, I need to update the main screen to notify the user in the application that some database processing was successful. Is this AT ALL possible or should I tell them to go ride a bike?

Mike Brubaker
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

It's possible.

What have you tried so far?

What h:commandButton attributes would help you acheive this? JSF 1.2 tlddocs
 
Mike Brubaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I haven't tried anything yet, because I can't see how it would be done in my mind. What properties of the h:commandButton tag are you referring to?
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example, when you click on any HTML anchor element <a>, you can code it to open the link in the same window, or have it open in a separate window using the HTML attribute: target="_blank"

Does h:commandButton have this kind of attribute? No.

What else does it have? It has an "action" attribute. Would that work? Possibly. What about the HTML attributes "onclick" ?

Assuming you already know how to work with the PDF and Crystal Reports APIs, there are several ways to go about opening new browser windows. They either require Javascript or your PDF/Crystal pages to be Servlets accessible via a URL.

My opinion is this sounds like poor design, having one button open two other windows, but, everyone has different opinions.

Recall that when you use the action attribute of a h:commandButton in JSF, you are setting a string value explicitly, or returning a string value from a method binding, used for page navigation.
 
Mike Brubaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would be a better design, if you don't mind? It would be a lot easier to have three separate buttons, one to do the DB update, one to generate the PDF and one to run the report, but I'm not sure my users will want to make three mouse clicks. Is that what you are referring to about the poor design? I'm open for any suggestions, believe me.

 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I said, that was my opinion.

I'm not a big fan of popping open multiple windows because then your users can leave them open all day. What happens when they leave them open and click that DB update button again for the same record? Now you have 5 windows open? Which window is the now current PDF/Crystal report?

I don't know your requirements and I don't need to, I was just giving my opinion based on what I read.
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could have an "onclick" function, in addition to your action, for your command button that uses Javascript to open the other two windows.

I've also read where the navigation action of the button opens a page that has Javascript in the body onload() event that opens the other two windows and closes itself.

Or, your button could navigate to the PDF page, which has Javascript in it's body onload() event to open the Crystal page, vice versa.

Or, your button could navigate to a page that contains two frames, one frame has the PDF the other frame has the Crystal report. That's not 3 pages though, maybe your users will complain about efficiency?

All of these seem like they would do the same thing.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTTP is based on the Request/Response paradigm. One request results in one response.

To open multiple windows (which won't work on my browser because I have it set to open tabs instead), you'd need multiple requests in order to get the different responses, one per window.

To do that you'll need to do it at the client side via a JavaScript function, since - like I said, one request, one response. HTTP doesn't permit a server to "volunteer" output, whether you're using JSF or not.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic