Hi *,

i've read alot on this topic. But i couldn't find a complete example so far.
Here is what i do so far:

In a page i have a modal window defined:

final ModalWindow mwCapacitySchemeMonitor = new
ModalWindow(CMP_CAPACITY_SCHEME_MONITOR);
mwCapacitySchemeMonitor.setPageMapName(CMP_CAPACITY_SCHEME_MONITOR + "-1");
mwCapacitySchemeMonitor.setCookieName(CMP_CAPACITY_SCHEME_MONITOR + "-1");
mwCapacitySchemeMonitor.setPageCreator(new ModalWindow.PageCreator() {
  public Page createPage() {
    return new CapacitySchemePage();
  }
});
pForm.add(mwCapacitySchemeMonitor);

A link is "calling" the window:
add(new AjaxLink(CMP_CAPACITY_SCHEME_LINK) {
  public void onClick(AjaxRequestTarget pTarget) {
    mwCapacitySchemeMonitor.show(pTarget);
  }
}.add(new Label(CMP_CAPACITY_SCHEME_LABEL, new
ResourceModel(CMP_CAPACITY_SCHEME_LABEL))));

And the page looks like this:
public CapacitySchemePage() {
  super();
  add(new Label("title", new ResourceModel("title")));
  add(new ResourceLink("lnkCapacityScheme", new DynamicWebResource() {
    protected void setHeaders(WebResponse pResponse) {
      super.setHeaders(pResponse);
    }
    protected ResourceState getResourceState() {
      return new ResourceState() {
        public String getContentType() {
          return "application/pdf";
        }
        public byte[] getData() {
          IResourceStream resourceStream = new
PackageResourceStream(CapacitySchemePage.class, 
                    "res/capacityScheme.pdf");
          ByteArrayOutputStream b = new ByteArrayOutputStream();
          int i = -1;
          try {
             while ((i = resourceStream.getInputStream().read()) != -1) {
               b.write(i);
             }
           } catch (IOException e) {
             throw new WicketRuntimeException(e);
           } catch (ResourceStreamNotFoundException e) {
             throw new WicketRuntimeException(e);
           }
           return b.toByteArray();
         }
      };
    }
  }));
}

The problem is that i only see the pdf after clicking the ResourceLink
"lnkCapacityScheme".
But i would like to achieve that the pdf is display immidiatly after the
window is opened.

How can i achieve that? A code snipped is welcome.

Thanks
Per

-- 
View this message in context: 
http://www.nabble.com/Example-for-presenting-pdf-in-modal-window-tp21666757p21666757.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to