Re: Problems displaying a PDF from stream

2010-11-02 Thread Alex Zeit
Thank you very much Stefan, it works perfectly!

2010/10/29 Stefan Lindner lind...@visionet.de

 How does your trigger look like? I mean the a or button or input
 type=submit element? Does it trigger a page refresh, means does it start
 a request tot he server? Then you still have a problem with cleared session
 cookie.
 You need something like div
 onclick=openURL(bookmarkableURLWithParameters)/ or  more in detail


div onclick= window.open('http://url.to.servlet.domain', '',
 'scrollbars=yes,location=no,menuBar=no,resizable=yes,status=no,toolbar=no')
 /

 No request cycle is triggered, the page stays untouched you can clear the
 session cookie as often as you like

 I did not proof this but I thin this could be te right way.

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Freitag, 29. Oktober 2010 14:22
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 I mean going to menu Clear private data (in German version it is Neueste
 Chronik löschen). Yes Cookies are also removed.
 For now I implemented my PDF generator as separate Servlet but it has same
 behaviour unless I disable caching:
// Set to expire far in the past.
response.setHeader(Expires, Sat, 6 May 1995 12:00:00 GMT);
if(request.getHeader(User-Agent).contains(MSIE)){
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0,
 pre-check=0);
}else{
// Set standard HTTP/1.1 no-cache headers.
// 29.10.10 OE Not working with IE 7
response.setHeader(Cache-Control, no-store, no-cache,
 must-revalidate);
}
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0, pre-check=0);
// Set standard HTTP/1.0 no-cache header.
response.setHeader(Pragma, no-cache);

 I don't really like this workaround with checking User agnet. But it is
 only way to make it work properly with Firefox and IE.


 2010/10/28 Stefan Lindner lind...@visionet.de

  What do you mean with After clearing chronik? Does this mean that
  the session cookie is lost after After clearing chronik?
  You may take a look at the generated HTML:
 
 
 
  
 Onclick=.?wicket:interface=:5:.:pdfIcon:pdf::ILinkListener::
 
  This refers to a version oft he page that is no longer valid after the
  session is lost. Refreshing the page starts a new session and it works
  again.
  You must (I don't know how at the moment) produce a sort of
  bookemarkable url for this case I think. My guess would be to use a
  separate servlet for this.
 
  Stefan
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 18:21
  An: users@wicket.apache.org
  Betreff: Re: Problems displaying a PDF from stream
 
  Now it works with IE and this is most important thing. Thank you very
 much!
  However the problem with Firefox remains. After clearing chronik while
  Pdf document is open if I click the link comes page expired, after
  refreshing the main page with link if I click link again comes empty
 page.
 
  2010/10/28 Alex Zeit zeita...@googlemail.com
 
   Thanks a lot Stefan I will try it right now
  
  
   2010/10/28 Stefan Lindner lind...@visionet.de
  
   Try this:
  
  
  
  public class MyResourceStreamWriter extends
   AbstractResourceStreamWriter {
  private static final long serialVersionUID = 1L;
  
  public MyResourceStreamWriter() {
  }
  
  @Override
  public void write(final OutputStream output) {
  // ! prduce output here and stream it to
  output
  try {
  output.flush();
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  
  @Override
   public String getContentType() {
  return application/pdf;
  }
  }
  
  
  
  
  
   LinkT pdfLink = new LinkT(pdf) {
  private static final long serialVersionUID = 1L;
  @Override
  public void onClick() {
  ResourceStreamRequestTarget rsrt = new
   ResourceStreamRequestTarget(new MyResourceStreamWriter());
  //rsrt.setFileName(file.pdf); // use this
   if yout want your browser to ask you wheter you want to save the
   cownloaded PDF in fil efile.pdf
  getRequestCycle().setRequestTarget(rsrt);
  }
  };
  
  
  pdfLink.setPopupSettings(new
   PopupSettings(PopupSettings.RESIZABLE
   | PopupSettings.SCROLLBARS));
  add(pdfLink);
  
  
   Stefan

Re: Problems displaying a PDF from stream

2010-11-02 Thread Alex Zeit
Sorry Stefan, I restarted Firefox and checked again - it does not work :-(

2010/11/2 Alex Zeit zeita...@googlemail.com

 Thank you very much Stefan, it works perfectly!

 2010/10/29 Stefan Lindner lind...@visionet.de

 How does your trigger look like? I mean the a or button or input
 type=submit element? Does it trigger a page refresh, means does it start
 a request tot he server? Then you still have a problem with cleared session
 cookie.
 You need something like div
 onclick=openURL(bookmarkableURLWithParameters)/ or  more in detail


div onclick= window.open('http://url.to.servlet.domain', '',
 'scrollbars=yes,location=no,menuBar=no,resizable=yes,status=no,toolbar=no')
 /

 No request cycle is triggered, the page stays untouched you can clear the
 session cookie as often as you like

 I did not proof this but I thin this could be te right way.

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Freitag, 29. Oktober 2010 14:22
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 I mean going to menu Clear private data (in German version it is
 Neueste Chronik löschen). Yes Cookies are also removed.
 For now I implemented my PDF generator as separate Servlet but it has same
 behaviour unless I disable caching:
// Set to expire far in the past.
response.setHeader(Expires, Sat, 6 May 1995 12:00:00 GMT);
if(request.getHeader(User-Agent).contains(MSIE)){
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0,
 pre-check=0);
}else{
// Set standard HTTP/1.1 no-cache headers.
// 29.10.10 OE Not working with IE 7
response.setHeader(Cache-Control, no-store, no-cache,
 must-revalidate);
}
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0, pre-check=0);
// Set standard HTTP/1.0 no-cache header.
response.setHeader(Pragma, no-cache);

 I don't really like this workaround with checking User agnet. But it is
 only way to make it work properly with Firefox and IE.


 2010/10/28 Stefan Lindner lind...@visionet.de

  What do you mean with After clearing chronik? Does this mean that
  the session cookie is lost after After clearing chronik?
  You may take a look at the generated HTML:
 
 
 
  
 Onclick=.?wicket:interface=:5:.:pdfIcon:pdf::ILinkListener::
 
  This refers to a version oft he page that is no longer valid after the
  session is lost. Refreshing the page starts a new session and it works
  again.
  You must (I don't know how at the moment) produce a sort of
  bookemarkable url for this case I think. My guess would be to use a
  separate servlet for this.
 
  Stefan
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 18:21
  An: users@wicket.apache.org
  Betreff: Re: Problems displaying a PDF from stream
 
  Now it works with IE and this is most important thing. Thank you very
 much!
  However the problem with Firefox remains. After clearing chronik while
  Pdf document is open if I click the link comes page expired, after
  refreshing the main page with link if I click link again comes empty
 page.
 
  2010/10/28 Alex Zeit zeita...@googlemail.com
 
   Thanks a lot Stefan I will try it right now
  
  
   2010/10/28 Stefan Lindner lind...@visionet.de
  
   Try this:
  
  
  
  public class MyResourceStreamWriter extends
   AbstractResourceStreamWriter {
  private static final long serialVersionUID = 1L;
  
  public MyResourceStreamWriter() {
  }
  
  @Override
  public void write(final OutputStream output) {
  // ! prduce output here and stream it to
  output
  try {
  output.flush();
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  
  @Override
   public String getContentType() {
  return application/pdf;
  }
  }
  
  
  
  
  
   LinkT pdfLink = new LinkT(pdf) {
  private static final long serialVersionUID = 1L;
  @Override
  public void onClick() {
  ResourceStreamRequestTarget rsrt = new
   ResourceStreamRequestTarget(new MyResourceStreamWriter());
  //rsrt.setFileName(file.pdf); // use this
   if yout want your browser to ask you wheter you want to save the
   cownloaded PDF in fil efile.pdf
  getRequestCycle().setRequestTarget(rsrt);
  }
  };
  
  
  pdfLink.setPopupSettings

Re: Problems displaying a PDF from stream

2010-10-29 Thread Alex Zeit
I mean going to menu Clear private data (in German version it is Neueste
Chronik löschen). Yes Cookies are also removed.
For now I implemented my PDF generator as separate Servlet but it has same
behaviour unless I disable caching:
// Set to expire far in the past.
response.setHeader(Expires, Sat, 6 May 1995 12:00:00 GMT);
if(request.getHeader(User-Agent).contains(MSIE)){
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0,
pre-check=0);
}else{
// Set standard HTTP/1.1 no-cache headers.
// 29.10.10 OE Not working with IE 7
response.setHeader(Cache-Control, no-store, no-cache,
must-revalidate);
}
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0, pre-check=0);
// Set standard HTTP/1.0 no-cache header.
response.setHeader(Pragma, no-cache);

I don't really like this workaround with checking User agnet. But it is only
way to make it work properly with Firefox and IE.


2010/10/28 Stefan Lindner lind...@visionet.de

 What do you mean with After clearing chronik? Does this mean that the
 session cookie is lost after After clearing chronik?
 You may take a look at the generated HTML:


  
 Onclick=.?wicket:interface=:5:.:pdfIcon:pdf::ILinkListener::

 This refers to a version oft he page that is no longer valid after the
 session is lost. Refreshing the page starts a new session and it works
 again.
 You must (I don't know how at the moment) produce a sort of bookemarkable
 url for this case I think. My guess would be to use a separate servlet for
 this.

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 18:21
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 Now it works with IE and this is most important thing. Thank you very much!
 However the problem with Firefox remains. After clearing chronik while Pdf
 document is open if I click the link comes page expired, after refreshing
 the main page with link if I click link again comes empty page.

 2010/10/28 Alex Zeit zeita...@googlemail.com

  Thanks a lot Stefan I will try it right now
 
 
  2010/10/28 Stefan Lindner lind...@visionet.de
 
  Try this:
 
 
 
 public class MyResourceStreamWriter extends
  AbstractResourceStreamWriter {
 private static final long serialVersionUID = 1L;
 
 public MyResourceStreamWriter() {
 }
 
 @Override
 public void write(final OutputStream output) {
 // ! prduce output here and stream it to
 output
 try {
 output.flush();
 } catch (Exception e) {
 e.printStackTrace();
 }
 }
 
 @Override
  public String getContentType() {
 return application/pdf;
 }
 }
 
 
 
 
 
  LinkT pdfLink = new LinkT(pdf) {
 private static final long serialVersionUID = 1L;
 @Override
 public void onClick() {
 ResourceStreamRequestTarget rsrt = new
  ResourceStreamRequestTarget(new MyResourceStreamWriter());
 //rsrt.setFileName(file.pdf); // use this if
  yout want your browser to ask you wheter you want to save the
  cownloaded PDF in fil efile.pdf
 getRequestCycle().setRequestTarget(rsrt);
 }
 };
 
 
 pdfLink.setPopupSettings(new
  PopupSettings(PopupSettings.RESIZABLE
  | PopupSettings.SCROLLBARS));
 add(pdfLink);
 
 
  Stefan
 
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 15:21
  An: users@wicket.apache.org
  Betreff: Re: Problems displaying a PDF from stream
 
  Yes
 
  2010/10/28 Stefan Lindner lind...@visionet.de
 
   Do you want to open the PDF in a separate window? Klick on some
   button and open a new browser window with pdf?
  
   Stefan
  
   -Ursprüngliche Nachricht-
   Von: Alex Zeit [mailto:zeita...@googlemail.com]
   Gesendet: Donnerstag, 28. Oktober 2010 15:14
   An: users@wicket.apache.org
   Betreff: Problems displaying a PDF from stream
  
   While trying to display a PDF document from stream following
   problems
   arrise:
   IE7:
   Resource can not be displaied at all.
  
   Firefox 3.6.12:
   PDF is displaied but if Chronk is cleared in Firefox while document
   is open then it cannot be displaied again. It is possible only
   after restarting Firefox.
  
   No errors in log.
  
   The code:
   public class PdfGen extends WebResource {
  
  public PdfGen

AW: Problems displaying a PDF from stream

2010-10-29 Thread Stefan Lindner
How does your trigger look like? I mean the a or button or input 
type=submit element? Does it trigger a page refresh, means does it start a 
request tot he server? Then you still have a problem with cleared session 
cookie.
You need something like div onclick=openURL(bookmarkableURLWithParameters)/ 
or  more in detail


div onclick= window.open('http://url.to.servlet.domain', '', 
'scrollbars=yes,location=no,menuBar=no,resizable=yes,status=no,toolbar=no') /

No request cycle is triggered, the page stays untouched you can clear the 
session cookie as often as you like

I did not proof this but I thin this could be te right way.

Stefan

-Ursprüngliche Nachricht-
Von: Alex Zeit [mailto:zeita...@googlemail.com] 
Gesendet: Freitag, 29. Oktober 2010 14:22
An: users@wicket.apache.org
Betreff: Re: Problems displaying a PDF from stream

I mean going to menu Clear private data (in German version it is Neueste 
Chronik löschen). Yes Cookies are also removed.
For now I implemented my PDF generator as separate Servlet but it has same 
behaviour unless I disable caching:
// Set to expire far in the past.
response.setHeader(Expires, Sat, 6 May 1995 12:00:00 GMT);
if(request.getHeader(User-Agent).contains(MSIE)){
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0, pre-check=0);
}else{
// Set standard HTTP/1.1 no-cache headers.
// 29.10.10 OE Not working with IE 7
response.setHeader(Cache-Control, no-store, no-cache, 
must-revalidate);
}
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader(Cache-Control, post-check=0, pre-check=0);
// Set standard HTTP/1.0 no-cache header.
response.setHeader(Pragma, no-cache);

I don't really like this workaround with checking User agnet. But it is only 
way to make it work properly with Firefox and IE.


2010/10/28 Stefan Lindner lind...@visionet.de

 What do you mean with After clearing chronik? Does this mean that 
 the session cookie is lost after After clearing chronik?
 You may take a look at the generated HTML:


  
 Onclick=.?wicket:interface=:5:.:pdfIcon:pdf::ILinkListener::

 This refers to a version oft he page that is no longer valid after the 
 session is lost. Refreshing the page starts a new session and it works 
 again.
 You must (I don't know how at the moment) produce a sort of 
 bookemarkable url for this case I think. My guess would be to use a 
 separate servlet for this.

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 18:21
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 Now it works with IE and this is most important thing. Thank you very much!
 However the problem with Firefox remains. After clearing chronik while 
 Pdf document is open if I click the link comes page expired, after 
 refreshing the main page with link if I click link again comes empty page.

 2010/10/28 Alex Zeit zeita...@googlemail.com

  Thanks a lot Stefan I will try it right now
 
 
  2010/10/28 Stefan Lindner lind...@visionet.de
 
  Try this:
 
 
 
 public class MyResourceStreamWriter extends 
  AbstractResourceStreamWriter {
 private static final long serialVersionUID = 1L;
 
 public MyResourceStreamWriter() {
 }
 
 @Override
 public void write(final OutputStream output) {
 // ! prduce output here and stream it to
 output
 try {
 output.flush();
 } catch (Exception e) {
 e.printStackTrace();
 }
 }
 
 @Override
  public String getContentType() {
 return application/pdf;
 }
 }
 
 
 
 
 
  LinkT pdfLink = new LinkT(pdf) {
 private static final long serialVersionUID = 1L;
 @Override
 public void onClick() {
 ResourceStreamRequestTarget rsrt = new 
  ResourceStreamRequestTarget(new MyResourceStreamWriter());
 //rsrt.setFileName(file.pdf); // use this 
  if yout want your browser to ask you wheter you want to save the 
  cownloaded PDF in fil efile.pdf
 getRequestCycle().setRequestTarget(rsrt);
 }
 };
 
 
 pdfLink.setPopupSettings(new 
  PopupSettings(PopupSettings.RESIZABLE
  | PopupSettings.SCROLLBARS));
 add(pdfLink);
 
 
  Stefan
 
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 15:21
  An: users@wicket.apache.org
  Betreff: Re: Problems

Problems displaying a PDF from stream

2010-10-28 Thread Alex Zeit
While trying to display a PDF document from stream following problems
arrise:
IE7:
Resource can not be displaied at all.

Firefox 3.6.12:
PDF is displaied but if Chronk is cleared in Firefox while document is open
then it cannot be displaied again. It is possible only after restarting
Firefox.

No errors in log.

The code:
public class PdfGen extends WebResource {

public PdfGen() {
setCacheable(false);
}

@Override
public IResourceStream getResourceStream() {
IResourceStream resourceStream = new AbstractResourceStreamWriter()
{
private static final long serialVersionUID =
1934248394380163944L;
public void write(OutputStream output) {
testItextDirect(output);
}
public String getContentType() {
return application/pdf;
}
};
return resourceStream;
}

private void testItextDirect(OutputStream output){
try {
Document document = new Document();
PdfWriter.getInstance(document, output);
document.open();
document.add(new Paragraph(Hello World));
document.add(new Paragraph(new Date().toString()));
document.close();
} catch (DocumentException de) {
try {
throw new IOException(de.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}


in the init() of AuthenticatedWebApplication SharedResource added like this:
getSharedResources().add(pdfGen, new PdfGen());

Any help would be highly appreciated
Alex


AW: Problems displaying a PDF from stream

2010-10-28 Thread Stefan Lindner
Do you want to open the PDF in a separate window? Klick on some button and open 
a new browser window with pdf?

Stefan

-Ursprüngliche Nachricht-
Von: Alex Zeit [mailto:zeita...@googlemail.com] 
Gesendet: Donnerstag, 28. Oktober 2010 15:14
An: users@wicket.apache.org
Betreff: Problems displaying a PDF from stream

While trying to display a PDF document from stream following problems
arrise:
IE7:
Resource can not be displaied at all.

Firefox 3.6.12:
PDF is displaied but if Chronk is cleared in Firefox while document is open 
then it cannot be displaied again. It is possible only after restarting Firefox.

No errors in log.

The code:
public class PdfGen extends WebResource {

public PdfGen() {
setCacheable(false);
}

@Override
public IResourceStream getResourceStream() {
IResourceStream resourceStream = new AbstractResourceStreamWriter() {
private static final long serialVersionUID = 1934248394380163944L;
public void write(OutputStream output) {
testItextDirect(output);
}
public String getContentType() {
return application/pdf;
}
};
return resourceStream;
}

private void testItextDirect(OutputStream output){
try {
Document document = new Document();
PdfWriter.getInstance(document, output);
document.open();
document.add(new Paragraph(Hello World));
document.add(new Paragraph(new Date().toString()));
document.close();
} catch (DocumentException de) {
try {
throw new IOException(de.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}


in the init() of AuthenticatedWebApplication SharedResource added like this:
getSharedResources().add(pdfGen, new PdfGen());

Any help would be highly appreciated
Alex

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Problems displaying a PDF from stream

2010-10-28 Thread Alex Zeit
Yes

2010/10/28 Stefan Lindner lind...@visionet.de

 Do you want to open the PDF in a separate window? Klick on some button and
 open a new browser window with pdf?

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 15:14
 An: users@wicket.apache.org
 Betreff: Problems displaying a PDF from stream

 While trying to display a PDF document from stream following problems
 arrise:
 IE7:
 Resource can not be displaied at all.

 Firefox 3.6.12:
 PDF is displaied but if Chronk is cleared in Firefox while document is open
 then it cannot be displaied again. It is possible only after restarting
 Firefox.

 No errors in log.

 The code:
 public class PdfGen extends WebResource {

public PdfGen() {
setCacheable(false);
}

@Override
public IResourceStream getResourceStream() {
IResourceStream resourceStream = new AbstractResourceStreamWriter()
 {
private static final long serialVersionUID =
 1934248394380163944L;
public void write(OutputStream output) {
testItextDirect(output);
}
public String getContentType() {
return application/pdf;
}
};
return resourceStream;
}

private void testItextDirect(OutputStream output){
try {
Document document = new Document();
PdfWriter.getInstance(document, output);
document.open();
document.add(new Paragraph(Hello World));
document.add(new Paragraph(new Date().toString()));
document.close();
} catch (DocumentException de) {
try {
throw new IOException(de.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
}
 }


 in the init() of AuthenticatedWebApplication SharedResource added like
 this:
 getSharedResources().add(pdfGen, new PdfGen());

 Any help would be highly appreciated
 Alex

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




AW: Problems displaying a PDF from stream

2010-10-28 Thread Stefan Lindner
Try this:



public class MyResourceStreamWriter extends 
AbstractResourceStreamWriter {
private static final long serialVersionUID = 1L;

public MyResourceStreamWriter() {
}

@Override
public void write(final OutputStream output) {
// ! prduce output here and stream it to output
try {
output.flush();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public String getContentType() {
return application/pdf;
}
}





LinkT pdfLink = new LinkT(pdf) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
ResourceStreamRequestTarget rsrt = new 
ResourceStreamRequestTarget(new MyResourceStreamWriter());
//rsrt.setFileName(file.pdf); // use this if yout 
want your browser to ask you wheter you want to save the cownloaded PDF in fil 
efile.pdf
getRequestCycle().setRequestTarget(rsrt);
}
};


pdfLink.setPopupSettings(new PopupSettings(PopupSettings.RESIZABLE | 
PopupSettings.SCROLLBARS));
add(pdfLink);


Stefan


-Ursprüngliche Nachricht-
Von: Alex Zeit [mailto:zeita...@googlemail.com] 
Gesendet: Donnerstag, 28. Oktober 2010 15:21
An: users@wicket.apache.org
Betreff: Re: Problems displaying a PDF from stream

Yes

2010/10/28 Stefan Lindner lind...@visionet.de

 Do you want to open the PDF in a separate window? Klick on some button 
 and open a new browser window with pdf?

 Stefan

 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 15:14
 An: users@wicket.apache.org
 Betreff: Problems displaying a PDF from stream

 While trying to display a PDF document from stream following problems
 arrise:
 IE7:
 Resource can not be displaied at all.

 Firefox 3.6.12:
 PDF is displaied but if Chronk is cleared in Firefox while document is 
 open then it cannot be displaied again. It is possible only after 
 restarting Firefox.

 No errors in log.

 The code:
 public class PdfGen extends WebResource {

public PdfGen() {
setCacheable(false);
}

@Override
public IResourceStream getResourceStream() {
IResourceStream resourceStream = new 
 AbstractResourceStreamWriter() {
private static final long serialVersionUID = 
 1934248394380163944L;
public void write(OutputStream output) {
testItextDirect(output);
}
public String getContentType() {
return application/pdf;
}
};
return resourceStream;
}

private void testItextDirect(OutputStream output){
try {
Document document = new Document();
PdfWriter.getInstance(document, output);
document.open();
document.add(new Paragraph(Hello World));
document.add(new Paragraph(new Date().toString()));
document.close();
} catch (DocumentException de) {
try {
throw new IOException(de.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
}
 }


 in the init() of AuthenticatedWebApplication SharedResource added like
 this:
 getSharedResources().add(pdfGen, new PdfGen());

 Any help would be highly appreciated
 Alex

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Problems displaying a PDF from stream

2010-10-28 Thread Alex Zeit
Thanks a lot Stefan I will try it right now

2010/10/28 Stefan Lindner lind...@visionet.de

 Try this:



public class MyResourceStreamWriter extends
 AbstractResourceStreamWriter {
private static final long serialVersionUID = 1L;

public MyResourceStreamWriter() {
}

@Override
public void write(final OutputStream output) {
// ! prduce output here and stream it to output
try {
output.flush();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
 public String getContentType() {
return application/pdf;
}
}





 LinkT pdfLink = new LinkT(pdf) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
ResourceStreamRequestTarget rsrt = new
 ResourceStreamRequestTarget(new MyResourceStreamWriter());
//rsrt.setFileName(file.pdf); // use this if yout
 want your browser to ask you wheter you want to save the cownloaded PDF in
 fil efile.pdf
getRequestCycle().setRequestTarget(rsrt);
}
};


pdfLink.setPopupSettings(new PopupSettings(PopupSettings.RESIZABLE |
 PopupSettings.SCROLLBARS));
add(pdfLink);


 Stefan


 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 15:21
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 Yes

 2010/10/28 Stefan Lindner lind...@visionet.de

  Do you want to open the PDF in a separate window? Klick on some button
  and open a new browser window with pdf?
 
  Stefan
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 15:14
  An: users@wicket.apache.org
  Betreff: Problems displaying a PDF from stream
 
  While trying to display a PDF document from stream following problems
  arrise:
  IE7:
  Resource can not be displaied at all.
 
  Firefox 3.6.12:
  PDF is displaied but if Chronk is cleared in Firefox while document is
  open then it cannot be displaied again. It is possible only after
  restarting Firefox.
 
  No errors in log.
 
  The code:
  public class PdfGen extends WebResource {
 
 public PdfGen() {
 setCacheable(false);
 }
 
 @Override
 public IResourceStream getResourceStream() {
 IResourceStream resourceStream = new
  AbstractResourceStreamWriter() {
 private static final long serialVersionUID =
  1934248394380163944L;
 public void write(OutputStream output) {
 testItextDirect(output);
 }
 public String getContentType() {
 return application/pdf;
 }
 };
 return resourceStream;
 }
 
 private void testItextDirect(OutputStream output){
 try {
 Document document = new Document();
 PdfWriter.getInstance(document, output);
 document.open();
 document.add(new Paragraph(Hello World));
 document.add(new Paragraph(new Date().toString()));
 document.close();
 } catch (DocumentException de) {
 try {
 throw new IOException(de.getMessage());
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 }
  }
 
 
  in the init() of AuthenticatedWebApplication SharedResource added like
  this:
  getSharedResources().add(pdfGen, new PdfGen());
 
  Any help would be highly appreciated
  Alex
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Problems displaying a PDF from stream

2010-10-28 Thread Alex Zeit
Now it works with IE and this is most important thing. Thank you very much!
However the problem with Firefox remains. After clearing chronik while Pdf
document is open if I click the link comes page expired, after refreshing
the main page with link if I click link again comes empty page.

2010/10/28 Alex Zeit zeita...@googlemail.com

 Thanks a lot Stefan I will try it right now


 2010/10/28 Stefan Lindner lind...@visionet.de

 Try this:



public class MyResourceStreamWriter extends
 AbstractResourceStreamWriter {
private static final long serialVersionUID = 1L;

public MyResourceStreamWriter() {
}

@Override
public void write(final OutputStream output) {
// ! prduce output here and stream it to output
try {
output.flush();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
 public String getContentType() {
return application/pdf;
}
}





 LinkT pdfLink = new LinkT(pdf) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
ResourceStreamRequestTarget rsrt = new
 ResourceStreamRequestTarget(new MyResourceStreamWriter());
//rsrt.setFileName(file.pdf); // use this if yout
 want your browser to ask you wheter you want to save the cownloaded PDF in
 fil efile.pdf
getRequestCycle().setRequestTarget(rsrt);
}
};


pdfLink.setPopupSettings(new PopupSettings(PopupSettings.RESIZABLE
 | PopupSettings.SCROLLBARS));
add(pdfLink);


 Stefan


 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 15:21
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 Yes

 2010/10/28 Stefan Lindner lind...@visionet.de

  Do you want to open the PDF in a separate window? Klick on some button
  and open a new browser window with pdf?
 
  Stefan
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 15:14
  An: users@wicket.apache.org
  Betreff: Problems displaying a PDF from stream
 
  While trying to display a PDF document from stream following problems
  arrise:
  IE7:
  Resource can not be displaied at all.
 
  Firefox 3.6.12:
  PDF is displaied but if Chronk is cleared in Firefox while document is
  open then it cannot be displaied again. It is possible only after
  restarting Firefox.
 
  No errors in log.
 
  The code:
  public class PdfGen extends WebResource {
 
 public PdfGen() {
 setCacheable(false);
 }
 
 @Override
 public IResourceStream getResourceStream() {
 IResourceStream resourceStream = new
  AbstractResourceStreamWriter() {
 private static final long serialVersionUID =
  1934248394380163944L;
 public void write(OutputStream output) {
 testItextDirect(output);
 }
 public String getContentType() {
 return application/pdf;
 }
 };
 return resourceStream;
 }
 
 private void testItextDirect(OutputStream output){
 try {
 Document document = new Document();
 PdfWriter.getInstance(document, output);
 document.open();
 document.add(new Paragraph(Hello World));
 document.add(new Paragraph(new Date().toString()));
 document.close();
 } catch (DocumentException de) {
 try {
 throw new IOException(de.getMessage());
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 }
  }
 
 
  in the init() of AuthenticatedWebApplication SharedResource added like
  this:
  getSharedResources().add(pdfGen, new PdfGen());
 
  Any help would be highly appreciated
  Alex
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





AW: Problems displaying a PDF from stream

2010-10-28 Thread Stefan Lindner
What do you mean with After clearing chronik? Does this mean that the session 
cookie is lost after After clearing chronik?
You may take a look at the generated HTML:


Onclick=.?wicket:interface=:5:.:pdfIcon:pdf::ILinkListener::

This refers to a version oft he page that is no longer valid after the session 
is lost. Refreshing the page starts a new session and it works again.
You must (I don't know how at the moment) produce a sort of bookemarkable url 
for this case I think. My guess would be to use a separate servlet for this.

Stefan

-Ursprüngliche Nachricht-
Von: Alex Zeit [mailto:zeita...@googlemail.com] 
Gesendet: Donnerstag, 28. Oktober 2010 18:21
An: users@wicket.apache.org
Betreff: Re: Problems displaying a PDF from stream

Now it works with IE and this is most important thing. Thank you very much!
However the problem with Firefox remains. After clearing chronik while Pdf 
document is open if I click the link comes page expired, after refreshing the 
main page with link if I click link again comes empty page.

2010/10/28 Alex Zeit zeita...@googlemail.com

 Thanks a lot Stefan I will try it right now


 2010/10/28 Stefan Lindner lind...@visionet.de

 Try this:



public class MyResourceStreamWriter extends 
 AbstractResourceStreamWriter {
private static final long serialVersionUID = 1L;

public MyResourceStreamWriter() {
}

@Override
public void write(final OutputStream output) {
// ! prduce output here and stream it to output
try {
output.flush();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
 public String getContentType() {
return application/pdf;
}
}





 LinkT pdfLink = new LinkT(pdf) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
ResourceStreamRequestTarget rsrt = new 
 ResourceStreamRequestTarget(new MyResourceStreamWriter());
//rsrt.setFileName(file.pdf); // use this if 
 yout want your browser to ask you wheter you want to save the 
 cownloaded PDF in fil efile.pdf
getRequestCycle().setRequestTarget(rsrt);
}
};


pdfLink.setPopupSettings(new 
 PopupSettings(PopupSettings.RESIZABLE
 | PopupSettings.SCROLLBARS));
add(pdfLink);


 Stefan


 -Ursprüngliche Nachricht-
 Von: Alex Zeit [mailto:zeita...@googlemail.com]
 Gesendet: Donnerstag, 28. Oktober 2010 15:21
 An: users@wicket.apache.org
 Betreff: Re: Problems displaying a PDF from stream

 Yes

 2010/10/28 Stefan Lindner lind...@visionet.de

  Do you want to open the PDF in a separate window? Klick on some 
  button and open a new browser window with pdf?
 
  Stefan
 
  -Ursprüngliche Nachricht-
  Von: Alex Zeit [mailto:zeita...@googlemail.com]
  Gesendet: Donnerstag, 28. Oktober 2010 15:14
  An: users@wicket.apache.org
  Betreff: Problems displaying a PDF from stream
 
  While trying to display a PDF document from stream following 
  problems
  arrise:
  IE7:
  Resource can not be displaied at all.
 
  Firefox 3.6.12:
  PDF is displaied but if Chronk is cleared in Firefox while document 
  is open then it cannot be displaied again. It is possible only 
  after restarting Firefox.
 
  No errors in log.
 
  The code:
  public class PdfGen extends WebResource {
 
 public PdfGen() {
 setCacheable(false);
 }
 
 @Override
 public IResourceStream getResourceStream() {
 IResourceStream resourceStream = new
  AbstractResourceStreamWriter() {
 private static final long serialVersionUID = 
  1934248394380163944L;
 public void write(OutputStream output) {
 testItextDirect(output);
 }
 public String getContentType() {
 return application/pdf;
 }
 };
 return resourceStream;
 }
 
 private void testItextDirect(OutputStream output){
 try {
 Document document = new Document();
 PdfWriter.getInstance(document, output);
 document.open();
 document.add(new Paragraph(Hello World));
 document.add(new Paragraph(new Date().toString()));
 document.close();
 } catch (DocumentException de) {
 try {
 throw new IOException(de.getMessage());
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 }
  }
 
 
  in the init() of AuthenticatedWebApplication SharedResource added 
  like
  this:
  getSharedResources().add(pdfGen, new PdfGen());
 
  Any help