struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guojun Zhu" <zgg...@gmail.com>
Subject Re: Programming help for a "print" function
Date Thu, 06 Nov 2008 19:39:13 GMT
Thank you very much.  That works for me.  I changed the media type to
"text/plain" and forward what is in the textarea directly and it works
fine in IE and firefox.  (some format problems in Opera though, need
to check safari later).  Have a great day!

sincerely
Zhu, Guojun

On Thu, Nov 6, 2008 at 10:50 AM, Gundersen, Richard
<Richard.Gundersen@london-scottish.com> wrote:
> I've just done the same thing - although it's nothing to do with Struts
>
>        var a = window.open('','','width=500,height=400');
>        a.document.open("text/html");
> a.document.write(document.getElementById('receipt').innerHTML);
>        a.document.close();
>        a.print();
>        a.close();
>
> Basically, a popup is opened, the content is pulled from a div in the
> parent window with an ID called 'receipt' and that's what gets printed,
> then the popup is closed.
>
> Richard Gundersen
> Java Developer
>
> Email: richard.gundersen@london-scottish.com
> Phone: 01618302398
> Fax: 01618342536
> London Scottish Bank plc
> 24 Mount Street
> Manchester
> M2 3LS
>
> -----Original Message-----
> From: Guojun Zhu [mailto:zggame@gmail.com]
> Sent: Thursday, November 06, 2008 4:40 PM
> To: Struts Users Mailing List
> Subject: Programming help for a "print" function
>
> Hi,
>
> I am new to struts and using Struts 1.2.9 (old version, but not my
> decision).  I have a view page in jsp set up to display a report I
> generated on-fly.  I have use setRequestAtrribute() to put  report (
> plain text string with only "\n" line-break) as a attribute in the
> action and get it from the jsp page and show it in a "textarea".  I
> put it this way for user to copy and paste the content in textarea
> into a text editor easily.
>
>  Now we want to put a print link/button for the report.  I have a few
> questions.
>
> 1 Javascript only has "window.print()" which print the whole window.
> Can it print things only in the textarea?
>
> 2  If I cannot, I probably need to pop-up a new window with a
> print-friendly page and invoke "window.print()" there.  Is that the
> correct way to do?
>
> 3. The report generating is expensive and  it has a generating time in
> the report.  So I do not wan to generate it again.  I wan to pass it
> into the print-page instead.    how can I pass the report from the
> original page to the pop-up print page?  Do I have to change the
> report into "session" attribute?
>
> 4. Since the plain text spring with line-break "\n" will not show up
> correctly in the browser, I need to change the report and put the
> format as "<br/>".  So I need to have two versions report generated.
> Is that the good way to go?  Or maybe I can generate one xml file and
> apply different css?
>
> I am sorry, the questions are not directly related to struts.  But I
> am not sure whether struts provide some better mechanism to accomplish
> this.  I am new to the server-side programing.  Can anyone point a
> good forum or usenet where I can get some help for subject like these?
>  Thanks.
>
> Sincerely
> Zhu, Guojun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> As a responsible corporate citizen, London Scottish Bank plc asks you to consider the
environment before printing this email.
>
> *** Disclaimer ***
>
> This electronic communication is confidential and for the exclusive use of the addressee.
It may contain private and confidential information. The information, attachments and opinions
contained in this E-mail are those of its author only and do not necessarily represent those
of London Scottish Bank PLC or any other members of the London Scottish Group.
>
> If you are not the intended addressee, you are prohibited from any disclosure, distribution
or further copying or use of this communication or the information in it or taking any action
in reliance on it. If you have received this communication in error please notify the Information
Security Manager at ISM@London-Scottish.com as soon as possible and delete the message from
all places in your computer where it is stored.
>
> We utilise virus scanning software but we cannot guarantee the security of electronic
communications and you are advised to check any attachments for viruses. We do not accept
liability for any loss resulting from any corruption or alteration of data or importation
of any virus as a result of receiving this electronic communication.
>
> Replies to this E-mail may be monitored for operational or business reasons. London Scottish
Bank PLC is authorised and regulated by the Financial Services Authority.
>
>
> London Scottish Bank plc, Registered Office: 201 Deansgate, Manchester M3 3NW Registered
Number 973008 England.
>
> Subsidiary Companies:-
>
> London Scottish Finance Limited, Registered Office: 201 Deansgate, Manchester M3 3NW
Registered Number 233259 England.
>
> London Scottish Broking Limited, Registered Office: 201 Deansgate, Manchester M3 3NW
Registered Number 230110 England.
>
> Robinson Way & Company Limited, Registered Office: 201 Deansgate, Manchester M3 3NW
Registered Number 885896 England.
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message