Can you show the complete code of your MyPdfResource class? Ernesto
On Tue, Nov 16, 2010 at 5:24 PM, <[email protected]> wrote: > Hello Ernesto, > > I use the classes from your link > https://cwiki.apache.org/WICKET/displaying-content-eg-pdf-excel-word-in-an-iframe.html > > The PDF-File is displayed only when I use the constructor of panel with a > parameter, even when both constructors do the same. > What am I doing wrong? > > public class MyPdfPanel extends Panel > { > public FileDisplayPage() > { > add(renderFileContent("mypdf")); > } > > private MyPdfPanel renderFileContent(String id) > { > > return new MyPdfPanel(id); // it works > //return new MyPdfPanel(id, getRenderFileContentModel(), > getFileNameModel(), getContentTypeModel()); //it does not work > } > .. > } > > > public class MyPdfPanel extends Panel > { > > public MyPdfPanel(String id) > { > super(id); > setRenderBodyOnly(true); > add(new DocumentInlineFrame("mypdf", new MyPdfResource())); > } > > public MyPdfPanel(String id, IModel fileContentModel, IModel fileNameModel, > IModel contentTypeModel) > { > super(id); > > file = (byte[]) fileContentModel.getObject(); > String fileName = (String) fileNameModel.getObject(); > String contentType = (String) contentTypeModel.getObject(); > setRenderBodyOnly(true); > add(new DocumentInlineFrame("mypdf", new MyPdfResource())); > > //I will do later following call. I commented out for testing > //add(new DocumentInlineFrame("mypdf", new MyPdfResource(file, > contentType, fileName))); > } > > } > > Regards > Mehmet > > > -----Ursprüngliche Nachricht----- > Von: Ernesto Reinaldo Barreiro [mailto:[email protected]] > Gesendet: Donnerstag, 11. November 2010 09:29 > An: [email protected] > Betreff: Re: panel can not be refreshed > > The approach described in [1] used to work for me some time ago. > > Regards, > > Ernesto > > 1-https://cwiki.apache.org/WICKET/displaying-content-eg-pdf-excel-word-in-an-iframe.html > > On Thu, Nov 11, 2010 at 9:19 AM, <[email protected]> wrote: >> Can someone help me? >> When the constructor DocEditPage is called, the variables file, file name >> and content type are null. These variables set to be later. But the panel is >> not refreshed. >> >> -----Ursprüngliche Nachricht----- >> Von: Kaplankiran, Mehmet >> Gesendet: Mittwoch, 10. November 2010 13:09 >> An: [email protected] >> Betreff: panel can not be refreshed >> >> Hello, >> >> I have implemented iframe and can view documents. Unfortunately, only in the >> class MyPdfResource hard-coded filename (example: private string filename = >> "test.pdf";) can be displayed. >> The files can not be refreshed. I hope someone can help me. >> >> greetings, Mehmet >> >> HTML: >> <div wicket:id="mypdf" border="1" width="900px" height="400px"></div> >> >> ++++++++++++++++++++++++++++++ class DocEditPage >> ++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++ >> ++++++++++++++++++++++++++++++ ++++++++++++ >> public class DocEditPage extends MainTemplate { >> >> private byte[] file; >> private String fileName; >> private String contentType; >> >> ... >> public DocEditPage(PageParameters params) >> { >> ... >> add(renderFileContent("mypdf")); >> } >> ... >> >> private MyPdfPanel renderFileContent(String id) >> { >> return new MyPdfPanel(id, getRenderFileContentModel(), >> getContentTypeModel(), getFileNameModel); >> } >> ... >> private IModel getRenderFileContentModel() >> { >> >> return new AbstractReadOnlyModel() >> { >> �...@override >> public Object getObject() >> { >> return file; >> } >> }; >> } >> >> private IModel getContentTypeModel() >> { >> return new AbstractReadOnlyModel() >> { >> �...@override >> public Object getObject() >> { >> return contentType; >> } >> }; >> } >> >> private IModel getFileNameModel() >> { >> return new AbstractReadOnlyModel() >> { >> �...@override >> public Object getObject() >> { >> return fileName; >> } >> }; >> } >> >> ... >> >> private DISTree disTree(String id) >> { >> return new DISTree(id) >> { >> �...@override >> public void selectNode(AjaxRequestTarget >> target, DISTreeNode node) >> { >> //set file and contentType; >> ... >> DocEditPage.this.contentType = >> content.getContentType(); >> DocEditPage.this.file = >> content.getOrbLk(); >> } >> } >> } >> >> } >> >> ++++++++++++++++++++++++++++++ class MyPdfPanel >> ++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++ >> ++++++++++++++++++++++++++++++ ++++++++++++ >> public class MyPdfPanel extends Panel >> { >> >> public MyPdfPanel(String id, IModel fileContentModel, IModel >> fileNameModel, IModel contentTypeModel) >> { >> //super(id, fileContentModel); >> super(id); >> >> file = (byte[]) fileContentModel.getObject(); >> String fileName = (String) fileNameModel.getObject(); >> String contentType = (String) >> contentTypeModel.getObject(); >> setRenderBodyOnly(true); >> add(new DocumentInlineFrame("mypdf", new >> MyPdfResource(file, contentType, fileName))); >> } >> >> } >> >> ++++++++++++++++++++++++++++++ class MyPdfResource >> ++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++ >> ++++++++++++++++++++++++++++++ ++++++++++++ >> public class MyPdfResource extends DynamicWebResource { >> private static final long serialVersionUID = 1L; ... >> private byte[] file; >> private String contentType = "application/pdf"; >> private String fileName = "test.pdf"; ... >> public MyPdfResource(byte[] file, String contenttype, String >> filename) >> { >> if (file != null) >> this.file = file; >> if (contenttype != null && >> !"".equalsIgnoreCase(contenttype)) >> contentType = contenttype; >> if (filename != null && !"".equalsIgnoreCase(filename)) >> fileName = filename; >> } >> ... >> } >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
