-
1. Re: open a browser tab by using navigation rule
asookazian Mar 9, 2010 7:19 PM (in response to thiagu.m)Good question. Well I tried some clicking around in the itext Seam example and I noticed that none of the links open the PDF in a new tab or window. Also, when I right-click and select open in a new tab in FF3, the PDF opens in a new tab but the focus does not change from the original tab.
As far as opening a new tab from pages.xml, I've never heard of that but that would be cool...
Anyways, check this out: http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html_single/#itext.document
Note that there is no attribute for newTab or newWindow. Most likely we need to file a JIRA enhancement request for this unless somebody knows of a good solution...
-
2. Re: open a browser tab by using navigation rule
kblief.kblief.gmail.com Mar 9, 2010 9:04 PM (in response to thiagu.m)I had to do something similar, but had to make a call to a cgi and return that PDF to a new tab/window (I couldn't convince my boss to just use itext in seam.)
What I ended up doing was having a s:div with a render tag that was backed by a boolean value on the backer bean.
<s:div rendered="#{backingBean.makeReport} > </s:div>
Then inside the s:div tag I put a little javascript and a form to post to the document I needed to create. I used jQuery to submit the form.
<s:div rendered="#{backingBean.makeReport} id="makeForm"> <script type="text/javascript" > jQuery(document).ready(function(){ jQuery('#form').submit(function(){ var new_window = "new_window"; window.open('',new_window,''); this.target = new_window; return true; }); jQuery('#form').submit(); }); </script> <form action="/report.seam" id="form" method="post"> </form> </s:div>
I then had a a4j:commandButton that flipped the flag to render the s:div which would submit the form and create the report.
<a4j:commandButton type="button" action="#{backingBean.renderReport}" value="Create Report" onclick="disableButton(this);" reRender="makeForm" /> <s:div rendered="#{backingBean.makeReport} id="makeForm"> <script type="text/javascript" > jQuery(document).ready(function(){ jQuery('#form').submit(function(){ var new_window = "new_window"; window.open('',new_window,''); this.target = new_window; return true; }); jQuery('#form').submit(); }); </script> <form action="/report.seam" id="form" method="post"> </form> </s:div>
The backing bean is something like this
private Boolean makeReport = false; ... public void renderReport(){ setMakeReport(true); } public void setMakeReport(Boolean makeReport) { this.makeReport = makeReport; } public Boolean getMakeReport(){ return this.makeReport; }
if you disable the button onclick it will stop people from regenerating the report.
function disableButton(button) { jQuery(button).attr("disabled","disabled"); }
Then in the report.page.xml file you can call the method that creates the report in the <action execute="#{ReportBean.generate}" />
This may or may not help you, but it allowed me to put PDFs in popups.