Hi, Please provide a mini/quickstart application. Thanks!
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Wed, Dec 23, 2015 at 1:11 AM, durairaj t <durairaj....@gmail.com> wrote: > Hi Martin - > > I tried INLINE as you suggested, it is not working. > > I need to stream the byteArrayResource in model window not in the browser, > > I'm trying to do the following in wicket 1.5 > > 1. WebMarkupContainer pdfPanel = new WebMarkupContainer(); > 2. add(pdfPanel); > 3. pdfPanel.add(new CustomizedWebComponent("id", new > BytearrayStreamResource("application/pdf",null)){ > > // code to return BytearrayStreamResource > }); > > 4. resource.onResourceRequested(); replaced with getRequestCycle(). > scheduleRequestHandlerAfterCurrent(newResourceRequestHandler(byteArrayResource,null)) > - its not working in WebMarkupContainer. As you mentioned its streaming > in browser. > > > *Expected result: * > > Hierarchy: Page-> WebMarkupContainer -> WebComponent ->BytearrayStreamResource > for pdf. > > *Actual result:* > > Hierarchy: Page-> BytearrayStreamResource for pdf. (Streaming directly > in the page), > > Menu option: It is nothing but a navigation panel with the buttons. It > will be loaded while doing page authentication.It is default behavior for > all the authenticated page. > HTML: I'm using <object wicket:id="pdfReport" height="98%" width="100%" > style="POSITION: absolute;z-index:-1;display:block;" ></object> > > > This issue entirely stopped my progress in migration. > > Please let me know if you need more details. > > > > Thank you! > > > On Tue, Dec 22, 2015 at 3:26 AM, Martin Grigorov <mgrigo...@apache.org> > wrote: > >> Hi, >> >> On Mon, Dec 21, 2015 at 5:11 PM, durairaj t <durairaj....@gmail.com> >> wrote: >> >>> Hi Martin, >>> >>> Thank you for your response. >>> >>> I have tried to explain the issue more clear than before. Please refer >>> the below details. >>> >>> >>> This is regarding Wicket 1.4 to 1.5 migration. >>> >>> *Requirement: *Generate pdf as child within parent - preserve parent >>> window using onRequestResource. >>> >>> *1.4 Code Design:* >>> I have Form component with WebMarkupContainer (containing Menu options - >>> buttons) as parent and WebComponent (implementing IResourceListner) as >>> child. >>> The WebComponent has onResourceRequested implemented with Custom class >>> to generate pdf via DynamicWebResource. >>> >>> Here is code snippet for onResourceRequested() >>> >>> pdfPanel.add(new EmbeddedPDFComponent("pdfReport", null) { >>> >>> public void onResourceRequested() { >>> CustomWebDynamicResource pdfResource = new CustomWebDynamicResource() { >>> >>> /** >>> * >>> */ >>> private static final long serialVersionUID = 1L; >>> >>> @Override >>> protected ResourceState getResourceState() { >>> return new ResourceState() { >>> >>> @Override >>> public String getContentType() { >>> return "application/pdf"; >>> } >>> >>> @Override >>> public byte[] getData() { >>> data = generatePdfIr(); >>> return data; >>> } >>> >>> }; >>> } >>> >>> }; >>> pdfResource.onResourceRequested(); >>> >>> } >>> }.setOutputMarkupId(true).setMarkupId("pdfReport")); >>> >>> Here is CustomWebDynamicResource() class: >>> >>> public abstract class CustomWebDynamicResource extends >>> DynamicWebResource { >>> >>> // Constructor and other default methods for setting >>> /** >>> * @see WebResource#setHeaders(WebResponse) >>> */ >>> protected void setHeaders(WebResponse response) >>> { >>> super.setHeaders(response); >>> response.setDateHeader("Expires", -1); >>> response.setHeader("Pragma", "public"); >>> response.setHeader("Cache-Control", "public"); >>> } >>> } >>> >>> >>> *Above is replace as below (with Wicket 1.5):* >>> >>> getRequestCycle().scheduleRequestHandlerAfterCurrent(new >>> ResourceRequestHandler(byteArrayResource, null)); >>> >>> *Problem:* >>> >>> With above code, the pdf is being generated but the parent menu options >>> are no longer available. It seems the above code is replacing the parent. >>> If I remove above line, I can see the menu options but pdf is no longer >>> generated. >>> >> >> What do you mean with "the parent menu are no longer available" ? >> With "getRequestCycle().scheduleRequestHandlerAfterCurrent(new >> ResourceRequestHandler(byteArrayResource, null));" you tell Wicket to >> stream the byteArrayResource to the browser. >> If you use "Content-Disposition: ATTACHEMENT" then the browser will show >> a dialog asking the user whether to save the file or to open it with the >> default software (e.g. Adobe Actobat). >> If you use "Content-Disposition: INLINE" then the browser will try to >> show the file by using a plugin, i.e. open the .pdf in the browser if >> possible. >> In both cases the parent component should not be affected. Either the >> page is at its old state (ATTACHMENT) or completely replaced (INLINE). >> >> >>> >>> >>> Thank you! >>> >>> >>> On Mon, Dec 21, 2015 at 9:24 AM, Martin Grigorov <mgrigo...@apache.org> >>> wrote: >>> >>>> Hi, >>>> >>>> To be able to help you I'll have to setup a project with 1.4 and try to >>>> migrate it. >>>> It is not clear in your mail what exactly is the problem. The code >>>> snippets are rather long and it hard to guess. >>>> Also the code snippets are hard to read. It would be better to use some >>>> pastebin service with proper indents and maybe even code coloring. >>>> >>>> Martin Grigorov >>>> Wicket Training and Consulting >>>> https://twitter.com/mtgrigorov >>>> >>>> On Mon, Dec 21, 2015 at 3:14 PM, durairaj t <durairaj....@gmail.com> >>>> wrote: >>>> >>>>> Can any one help on this issue? >>>>> >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: durairaj t <durairaj....@gmail.com> >>>>> Date: Fri, Dec 18, 2015 at 4:29 PM >>>>> Subject: Wicket migration 1.4 to 1.5.13 issue with WebmarkupContainer >>>>> /WebComponent/ByteArrayResource >>>>> To: users@wicket.apache.org >>>>> >>>>> >>>>> Hi Team - >>>>> >>>>> >>>>> How to change the below wicket version1.4 code to 1.5.13 , I tried >>>>> with WebComponent(String ,IModel<?> model), it doesn't work. >>>>> >>>>> When I'm using the below code its placing the pdf content in the form >>>>> component but not in the WebmarkupContainer. >>>>> *getRequestCycle().scheduleRequestHandlerAfterCurrent(new >>>>> ResourceRequestHandler(byteArrayResource,null));* >>>>> >>>>> Thanks for any help. >>>>> >>>>> *xyzPage.java* >>>>> >>>>> *------------------------------------------------------------------------------* >>>>> >>>>> pdfPanel = new WebMarkupContainer("pdfPanel") { >>>>> public boolean isVisible() { >>>>> return irMode != IRMODE.EDIT; >>>>> } >>>>> }; >>>>> pdfPanel.setOutputMarkupId(true); >>>>> pdfPanel.setMarkupId("pdfPanel"); >>>>> pdfPanel.setOutputMarkupPlaceholderTag(true); >>>>> add(pdfPanel); >>>>> >>>>> pdfPanel.add(new EmbeddedPDFComponent("pdfReport", null) { >>>>> /** >>>>> * >>>>> */ >>>>> private static final long serialVersionUID = 1L; >>>>> transient byte[] data = null; >>>>> >>>>> public boolean isVisible() { >>>>> return irMode != IRMODE.EDIT; >>>>> } >>>>> >>>>> @Override >>>>> public boolean showToolbar() { >>>>> return false;// irMode == IRMODE.PRINT; >>>>> } >>>>> >>>>> public void onResourceRequested() { >>>>> DynamicWebResource pdfResource = new DynamicWebResource() { >>>>> >>>>> /** >>>>> * >>>>> */ >>>>> private static final long serialVersionUID = 1L; >>>>> >>>>> @Override >>>>> protected ResourceState getResourceState() { >>>>> // TODO Auto-generated method stub >>>>> return new ResourceState() { >>>>> >>>>> @Override >>>>> public String getContentType() { >>>>> return "application/pdf"; >>>>> } >>>>> >>>>> @Override >>>>> public byte[] getData() { >>>>> if (data == null { >>>>> try { >>>>> data = generatePdfIr(); >>>>> refreshPrint = false; >>>>> } catch (Exception e) { >>>>> // TODO Auto-generated catch block >>>>> e.printStackTrace(); >>>>> } >>>>> } >>>>> return data; >>>>> } >>>>> >>>>> }; >>>>> } >>>>> >>>>> }; >>>>> pdfResource.onResourceRequested(); >>>>> >>>>> } >>>>> }.setOutputMarkupId(true).setMarkupId("pdfReport")); >>>>> >>>>> moduleForm.ClearBooleanFlags(); >>>>> >>>>> } >>>>> >>>>> *EmbeddedPDFComponent.java:* >>>>> >>>>> public class EmbeddedPDFComponent extends WebComponent implements >>>>> IResourceListener >>>>> { >>>>> >>>>> private static final long serialVersionUID = 1L; >>>>> protected final DynamicWebResource resource; >>>>> >>>>> /** >>>>> * Construcxt. >>>>> * >>>>> * @param componentID >>>>> * component componentID >>>>> * @param resource >>>>> * the resource >>>>> */ >>>>> public EmbeddedPDFComponent(String componentID, DynamicWebResource >>>>> resource) >>>>> { >>>>> super(componentID); >>>>> this.resource = resource; >>>>> } >>>>> >>>>> /** >>>>> * @see wicket.IResourceListener#onResourceRequested() >>>>> */ >>>>> public void onResourceRequested() >>>>> { >>>>> resource.onResourceRequested(); >>>>> } >>>>> >>>>> /** >>>>> * @see wicket.Component#onComponentTag(wicket.markup.ComponentTag) >>>>> */ >>>>> protected void onComponentTag(ComponentTag tag) >>>>> { >>>>> if (!"object".equalsIgnoreCase(tag.getName())) >>>>> { >>>>> findMarkupStream().throwMarkupException( >>>>> "Component " >>>>> + getId() + " must be applied to a tag of type 'object' not " >>>>> + tag.toUserDebugString()); >>>>> } >>>>> if(showToolbar()) >>>>> tag.put("data", >>>>> >>>>> getResponse().encodeURL(urlFor(IResourceListener.INTERFACE))+"#toolbar=1&statusbar=0&messages=0&navpanes=" >>>>> + (showNavPane()?"1":"0")); >>>>> else >>>>> tag.put("data", >>>>> >>>>> getResponse().encodeURL(urlFor(IResourceListener.INTERFACE))+"#toolbar=0&statusbar=0&messages=0&navpanes=" >>>>> + (showNavPane()?"1":"0")); >>>>> tag.put("type","application/pdf"); >>>>> super.onComponentTag(tag); >>>>> } >>>>> public boolean showToolbar(){ >>>>> return false; >>>>> } >>>>> public boolean showNavPane(){ >>>>> return false; >>>>> } >>>>> } >>>>> >>>> >>>> >>> >> >