Hi,

I had to deal with something similar (not exactly the same problem) and  
I think you could do the following:

1-Mount a bookmarkable page 
(mountBookmarkablePage("/mypdf",MyPdfPage.class));
2-On my MyPdfPage.hmtl have a markup

<div style="padding: 15px 5px 5px 5px;">
<div><span wicket:id="message"></span></div>    
<iframe wicket:id="iframe" src="xxx.html" width="98%" height="400" 
align="center">
    Your browser doesn't support iframes
</iframe>
</div>

3- MyPdfPage.java you have something similar to (this just a sketch):

import java.util.HashMap;

import org.apache.wicket.Resource;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

import com.abbott.aeres.core.web.button.BaseDocumentResource;
import com.abbott.aeres.core.web.button.FinalDocumentResource;
import com.isencia.sherpa.web.resource.ResourceInlineFrame;

public class MyPdfPage extends WebPage {
   
    public MyPdfPage() {
        final ResourceReference reference = new 
ResourceReference("myPdfDocument.pdf");       
        HashMap<String, String> params = new HashMap<String, String>();
       
        final boolean haveAdocument = haveADocument();// check if I have 
a document
        String docId = "xxx";
        params.put(MyDocumentResource.ID, docId);       
        final String finalId = docId;

        Label message = new Label("message", "Don't have a PDF, sorry!") {
            private static final long serialVersionUID = 1L;

           
            @Override
            public boolean isVisible() {       
                return !haveAdocument;
            }
        };
           
        new ResourceInlineFrame(this, "iframe", reference, params) {
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                return haveAdocument;
            }
        };
    }
}

3-final ResourceReference reference = new 
ResourceReference("myPdfDocument.pdf");  makes reference to a dynamic 
resource reference you mount at application level as

getSharedResources().add("myPdfDocument.pdf", new MyDocumentResource());

it is important that it ends in ".pdf" otherwise IE will refuse to open 
it in an iframe (if someone knows a better way please tell me about;-).
MyDocumentResource is a class extending DynamicWebResource that 
generates the PDF based on some params (see above). Make sure you 
overide the setHeaders
method and put the response.setHeader("Content-Disposition", "inline; 
filename=\"" + name + "\""); otherwise IE will not open it in the iframe

4-The listing of ResourceInlineFrame is:

public class ResourceInlineFrame extends WebMarkupContainer
{
    private static final long serialVersionUID = 1L;

    private ResourceReference reference;
   
    private HashMap<String, String> params;
   
    public ResourceInlineFrame(MarkupContainer parent, final String id, 
ResourceReference reference)
    {
        this(parent, id, reference, null);       
    }
   
   
   
    public ResourceInlineFrame(MarkupContainer parent, final String id, 
ResourceReference reference, HashMap<String, String> params)
    {
        super(parent, id);
        if(reference == null)
        {
            throw new IllegalArgumentException("Invalid Resource 
Reference");
        }
        this.reference = reference;
        this.params = params;
    }

    protected CharSequence getURL()
    {
        StringBuffer url = new StringBuffer();
        url.append(urlFor(reference));
        if(params != null && !params.isEmpty()) {
            url.append("?");
            Iterator<String> it = params.keySet().iterator();
            while(it.hasNext()) {
                String key = it.next();
                url.append(key);
                url.append("=");
                url.append(params.get(key));
                if(it.hasNext())
                    url.append("&");
            }
        }       
        return url;
    }

 
    @Override
    protected final void onComponentTag(final ComponentTag tag)
    {
        checkComponentTag(tag, "iframe");

        // Set href to link to this frame's frameRequested method
        CharSequence url = getURL();

        // generate the src attribute
        tag.put("src", Strings.replaceAll(url, "&", "&amp;"));

        super.onComponentTag(tag);
    }


 
    public HashMap<String, String> getParams() {
        return params;
    }


    public void setParams(HashMap<String, String> params) {
        this.params = params;
    }
}

Hope this is of some help...

Ernesto


Tishkin, Eugene wrote:
> I have a page with links. Each link has to work like this:
>  
> When it's clicked, it opens popup window and if there is a PDF file it 
> points to -  show it in the window, otherwise show a message in the 
> same window.
>  
> Any ideas are greatly appreciated.
>  
> Thank you
> ----------------------------------------------------
> Eugene Tishkin
>  
>
>
> This e-mail and any attachments may contain confidential information. Any
> distributing, copying or reliance upon the contents of this e-mail by 
> anyone other
> than the intended recipient is strictly prohibited. If you have 
> received this e-mail
> accidentally, please delete it and notify the sender. Although this 
> message has been
> screened for viruses, we cannot guarantee that our virus scanner will 
> detect all
> viruses and take no responsibility for any damage or loss that may be 
> caused by its
> contents.
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to