Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Just a small observation that might help. Move code from PdfViewer contructor to onInitialize. This makes URL generation safer although it doesn't explain why your code worked until 6.12.0. I guess it depends on the mount path of your page. Most probably it is /wicket/bookmarkable/... On Mar 14, 2015 7:37 PM, Bruce Lombardi brlom...@gmail.com wrote: Interesting, When I run your code I see that the url is as you say: ./wicket/resource/org.apache.wicket.Application/pdfProducer Whereas in my working code (wicket version 6.12) it is: ./resource/org.apache.wicket.Application/pdfProducer And in my non-working code (wicket versions 6.13 - 6.19) it is: ../resource/org.apache.wicket.Application/pdfProducer If I remove the first dot from the url with the debuggerthen run from there the pdf appears as it should. I wonder why they are different in the two projects and why I'm getting .. with later versions. I'm also wondering if there is another library that is somehow incompatible with later versions of Wicket. I think the only library we use that interacts with Wicket is wicket bootstrap - currently as below (but I've tried other version): dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-core/artifactId version0.9.8/version /dependency dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-extensions/artifactId version0.9.8/version /dependency I will add these dependencies to your quickstart and see if it makes a difference. Bruce
Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
For the moment, this issue has put me behind schedule so I need to move on, but I will try to get back to it and open an issue later. Thanks again. Bruce Sent from my iPad On Mar 15, 2015, at 3:59 PM, Andrea Del Bene an.delb...@gmail.com wrote: Good! It would be nice to understand what caused this change from 6.12.0 to 6.13.0 but this requires a quickstart to reproduce the specific problem. If you have the time and the chance to create such quickstart you can open an issue on JIRA. Thanks Andrea, Your small observation was important. After moving the code into the onInitialize method everything started working. The url produced is ./resource/org.apache.wicket.Application/pdfProducer and not . ./resource/org.apache.wicket.Application/pdfProducer. I also test the wicket-bootstrap theory, but that does not seem to be involved. I will use this fix. Since this works should I still open a JIRA issue? Thanks again, Bruce -Original Message- From: Andrea Del Bene [mailto:an.delb...@gmail.com] Sent: Sunday, March 15, 2015 10:00 AM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Just a small observation that might help. Move code from PdfViewer contructor to onInitialize. This makes URL generation safer although it doesn't explain why your code worked until 6.12.0. I guess it depends on the mount path of your page. Most probably it is /wicket/bookmarkable/... On Mar 14, 2015 7:37 PM, Bruce Lombardi brlom...@gmail.com wrote: Interesting, When I run your code I see that the url is as you say: ./wicket/resource/org.apache.wicket.Application/pdfProducer Whereas in my working code (wicket version 6.12) it is: ./resource/org.apache.wicket.Application/pdfProducer And in my non-working code (wicket versions 6.13 - 6.19) it is: ../resource/org.apache.wicket.Application/pdfProducer If I remove the first dot from the url with the debuggerthen run from there the pdf appears as it should. I wonder why they are different in the two projects and why I'm getting .. with later versions. I'm also wondering if there is another library that is somehow incompatible with later versions of Wicket. I think the only library we use that interacts with Wicket is wicket bootstrap - currently as below (but I've tried other version): dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-core/artifactId version0.9.8/version /dependency dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-extensions/artifactId version0.9.8/version /dependency I will add these dependencies to your quickstart and see if it makes a difference. Bruce - 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Good! It would be nice to understand what caused this change from 6.12.0 to 6.13.0 but this requires a quickstart to reproduce the specific problem. If you have the time and the chance to create such quickstart you can open an issue on JIRA. Thanks Andrea, Your small observation was important. After moving the code into the onInitialize method everything started working. The url produced is ./resource/org.apache.wicket.Application/pdfProducer and not . ./resource/org.apache.wicket.Application/pdfProducer. I also test the wicket-bootstrap theory, but that does not seem to be involved. I will use this fix. Since this works should I still open a JIRA issue? Thanks again, Bruce -Original Message- From: Andrea Del Bene [mailto:an.delb...@gmail.com] Sent: Sunday, March 15, 2015 10:00 AM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Just a small observation that might help. Move code from PdfViewer contructor to onInitialize. This makes URL generation safer although it doesn't explain why your code worked until 6.12.0. I guess it depends on the mount path of your page. Most probably it is /wicket/bookmarkable/... On Mar 14, 2015 7:37 PM, Bruce Lombardi brlom...@gmail.com wrote: Interesting, When I run your code I see that the url is as you say: ./wicket/resource/org.apache.wicket.Application/pdfProducer Whereas in my working code (wicket version 6.12) it is: ./resource/org.apache.wicket.Application/pdfProducer And in my non-working code (wicket versions 6.13 - 6.19) it is: ../resource/org.apache.wicket.Application/pdfProducer If I remove the first dot from the url with the debuggerthen run from there the pdf appears as it should. I wonder why they are different in the two projects and why I'm getting .. with later versions. I'm also wondering if there is another library that is somehow incompatible with later versions of Wicket. I think the only library we use that interacts with Wicket is wicket bootstrap - currently as below (but I've tried other version): dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-core/artifactId version0.9.8/version /dependency dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-extensions/artifactId version0.9.8/version /dependency I will add these dependencies to your quickstart and see if it makes a difference. Bruce - 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: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
I guess it depends on the mount path of your page. Most probably it is /wicket/bookmarkable/... On Mar 14, 2015 7:37 PM, Bruce Lombardi brlom...@gmail.com wrote: Interesting, When I run your code I see that the url is as you say: ./wicket/resource/org.apache.wicket.Application/pdfProducer Whereas in my working code (wicket version 6.12) it is: ./resource/org.apache.wicket.Application/pdfProducer And in my non-working code (wicket versions 6.13 - 6.19) it is: ../resource/org.apache.wicket.Application/pdfProducer If I remove the first dot from the url with the debuggerthen run from there the pdf appears as it should. I wonder why they are different in the two projects and why I'm getting .. with later versions. I'm also wondering if there is another library that is somehow incompatible with later versions of Wicket. I think the only library we use that interacts with Wicket is wicket bootstrap - currently as below (but I've tried other version): dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-core/artifactId version0.9.8/version /dependency dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-extensions/artifactId version0.9.8/version /dependency I will add these dependencies to your quickstart and see if it makes a difference. Bruce -Original Message- From: Andrea Del Bene [mailto:an.delb...@gmail.com] Sent: Saturday, March 14, 2015 11:58 AM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I've created a quickstart based on your code but I can't reproduce the issue. I've shared it on Dropbox: https://www.dropbox.com/s/qmolvzvp9a0xplf/ResourceIssue.tar.gz?dl=0 The only thing I've noted is that your resource url doesn't have starting segment 'wicket', i.e my resource url is: ./wicket/resource/org.apache.wicket.Application/pdfProducer Maybe you have some custom setting for wicket segments ('wicket', 'bookmark', etc...)? The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce - 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: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Bruce, Apologies for my short answers of yesterday: texting from a mobile device is not very confortable. Would this class https://github.com/reiern70/antilia-bits/blob/master/content-iframe/src/main/java/com/antilia/iframe/DocumentInlineFrame.java be of some help for your use case? On Fri, Mar 13, 2015 at 11:03 PM, Bruce Lombardi brlom...@gmail.com wrote: The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 4:17 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, This is your code: WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; There is nothing Component specific here. Except #getSession(), but you can use Session.get() and cast it. It is the same. If you need the component to be able to generate the PDF bytes then you need to implement IResourceListener interface. In #onResourceRequested() you can generate the bytes and write them to the Response: getResponse().write(byte[]). The change you need to do is in #urlFor(): urlFor(ResourceListener.INTERFACE, parameters)) Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 8:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Interesting, When I run your code I see that the url is as you say: ./wicket/resource/org.apache.wicket.Application/pdfProducer Whereas in my working code (wicket version 6.12) it is: ./resource/org.apache.wicket.Application/pdfProducer And in my non-working code (wicket versions 6.13 - 6.19) it is: ../resource/org.apache.wicket.Application/pdfProducer If I remove the first dot from the url with the debuggerthen run from there the pdf appears as it should. I wonder why they are different in the two projects and why I'm getting .. with later versions. I'm also wondering if there is another library that is somehow incompatible with later versions of Wicket. I think the only library we use that interacts with Wicket is wicket bootstrap - currently as below (but I've tried other version): dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-core/artifactId version0.9.8/version /dependency dependency groupIdde.agilecoders.wicket/groupId artifactIdwicket-bootstrap-extensions/artifactId version0.9.8/version /dependency I will add these dependencies to your quickstart and see if it makes a difference. Bruce -Original Message- From: Andrea Del Bene [mailto:an.delb...@gmail.com] Sent: Saturday, March 14, 2015 11:58 AM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I've created a quickstart based on your code but I can't reproduce the issue. I've shared it on Dropbox: https://www.dropbox.com/s/qmolvzvp9a0xplf/ResourceIssue.tar.gz?dl=0 The only thing I've noted is that your resource url doesn't have starting segment 'wicket', i.e my resource url is: ./wicket/resource/org.apache.wicket.Application/pdfProducer Maybe you have some custom setting for wicket segments ('wicket', 'bookmark', etc...)? The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce - 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: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Hi, I've created a quickstart based on your code but I can't reproduce the issue. I've shared it on Dropbox: https://www.dropbox.com/s/qmolvzvp9a0xplf/ResourceIssue.tar.gz?dl=0 The only thing I've noted is that your resource url doesn't have starting segment 'wicket', i.e my resource url is: ./wicket/resource/org.apache.wicket.Application/pdfProducer Maybe you have some custom setting for wicket segments ('wicket', 'bookmark', etc...)? The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Thanks Andrea. I'll work with your quickstart and see what I can find. Bruce -Original Message- From: Andrea Del Bene [mailto:an.delb...@gmail.com] Sent: Saturday, March 14, 2015 11:58 AM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I've created a quickstart based on your code but I can't reproduce the issue. I've shared it on Dropbox: https://www.dropbox.com/s/qmolvzvp9a0xplf/ResourceIssue.tar.gz?dl=0 The only thing I've noted is that your resource url doesn't have starting segment 'wicket', i.e my resource url is: ./wicket/resource/org.apache.wicket.Application/pdfProducer Maybe you have some custom setting for wicket segments ('wicket', 'bookmark', etc...)? The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce - 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: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource { private static final long serialVersionUID = -2245331056747467763L; final byte[] pdfByteArray; public PdfResourceProducer(byte[] pdfByteArray) { super(); this.pdfByteArray = pdfByteArray; if(pdfByteArray == null) { System.out.println(PdfResourceProducer constructor called with null byte array.); } } @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType(application/pdf); // resourceResponse.setTextEncoding(utf-8); resourceResponse.setContentLength((int)pdfByteArray.length); resourceResponse.disableCaching(); //do not allow resource to be cached.
Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Pass the info as parameters on the request to the mounted resource? On Fri, Mar 13, 2015 at 7:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource { private static final long serialVersionUID = -2245331056747467763L; final byte[] pdfByteArray; public PdfResourceProducer(byte[] pdfByteArray) { super(); this.pdfByteArray = pdfByteArray; if(pdfByteArray == null) { System.out.println(PdfResourceProducer constructor called with null byte array.); } } @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse();
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Thanks Martin. I'm not getting any WARN messages in the logs. I'll take a look at mounting the resource. Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource { private static final long serialVersionUID = -2245331056747467763L; final byte[] pdfByteArray; public PdfResourceProducer(byte[] pdfByteArray) { super(); this.pdfByteArray = pdfByteArray; if(pdfByteArray == null) { System.out.println(PdfResourceProducer constructor called with null byte array.); } } @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType(application/pdf); // resourceResponse.setTextEncoding(utf-8); resourceResponse.setContentLength((int)pdfByteArray.length); resourceResponse.disableCaching(); //do not allow resource to be cached. resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { try { OutputStream outputStream = attributes.getResponse() .getOutputStream(); outputStream.write(pdfByteArray);
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Thanks Ernesto, I don't know how to pass a byte[] as a parameter. Bruce -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Friday, March 13, 2015 2:20 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Pass the info as parameters on the request to the mounted resource? On Fri, Mar 13, 2015 at 7:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource { private static final long serialVersionUID = -2245331056747467763L; final byte[] pdfByteArray; public PdfResourceProducer(byte[] pdfByteArray) { super(); this.pdfByteArray = pdfByteArray; if(pdfByteArray == null) {
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 4:17 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, This is your code: WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; There is nothing Component specific here. Except #getSession(), but you can use Session.get() and cast it. It is the same. If you need the component to be able to generate the PDF bytes then you need to implement IResourceListener interface. In #onResourceRequested() you can generate the bytes and write them to the Response: getResponse().write(byte[]). The change you need to do is in #urlFor(): urlFor(ResourceListener.INTERFACE, parameters)) Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 8:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
That's not really possible. The pdf is produced by itext from a template with lots of parameter. It would require too large a change in the code and would couple the pdfViewer panel too closely to the domain code. If, as Martin suggests, the automatic registering of the resource is not being done in the ResourceReferenceRegistry maybe there is something I could do to register and then unregister the resource similar to the way it must have been done in 6.12.. Bruce -Original Message- From: reiern70 [mailto:reier...@gmail.com] Sent: Friday, March 13, 2015 3:40 PM To: users@wicket.apache.org Subject: RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Passing something that allows you to produce the byte []? Sent from Samsung Mobile Original message From: Bruce Lombardi brlom...@gmail.com Date:13/03/2015 20:20 (GMT+01:00) To: users@wicket.apache.org Subject: RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Thanks Ernesto, I don't know how to pass a byte[] as a parameter. Bruce -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Friday, March 13, 2015 2:20 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Pass the info as parameters on the request to the mounted resource? On Fri, Mar 13, 2015 at 7:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf();
Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Please create a quickstart application and attach it to JIRA. Thanks! Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Sat, Mar 14, 2015 at 12:03 AM, Bruce Lombardi brlom...@gmail.com wrote: The problem (which I think is a bug) is in the way the url is produced. The line String url = (String)RequestCycle.get().urlFor(resourceReference, null); Produces the url to use for the resource ref. In the non-working version it returns: ../resource/org.apache.wicket.Application/pdfProducer If I set a breakpoint just after this line and I manually remove the first dot in the string using the debugger to get: ./resource/org.apache.wicket.Application/pdfProducer and then let the code continue to run, my pdf appears correctly. The debug trace also shows the correct uri. 2015-03-13 17:59:30,292 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,298 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,301 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 17:59:30,305 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Maybe someone knows how to fix this? I could strip the first dot as a workaround in the mean time. Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 4:17 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, This is your code: WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; There is nothing Component specific here. Except #getSession(), but you can use Session.get() and cast it. It is the same. If you need the component to be able to generate the PDF bytes then you need to implement IResourceListener interface. In #onResourceRequested() you can generate the bytes and write them to the Response: getResponse().write(byte[]). The change you need to do is in #urlFor(): urlFor(ResourceListener.INTERFACE, parameters)) Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 8:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Thanks Martin an others. I am always impressed with the helpfulness of the people on this list. I will look into what you suggest. In the meantime I'm trying to find out more information about the differences between versions and I set the logger level to DEBUG and obtained the traces below from working and non-working versions. Maybe this will help shed some light on what is happening. I see some differences like uri for working version starts with /wicket/resource but non-working version starts with /resource/ but I don't know what the differences mean. Maybe someone know about this change? If the difference in the way resource reference registration works between 6.12 and 6.13 is an unintended change in behavior between versions, it seems like it should be fixed. If it is an intended change, then it should be documented. Working Version 6.12 Debug trace 2015-03-13 16:12:35,585 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference/webjars/bootstrap/2.3.2/css/bootstrap-ver-1378733671227.css' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' 2015-03-13 16:12:35,648 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:12:35,648 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:12:35,648 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/wicket/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:12:35,648 DEBUG - CompoundRequestMapper - One compatible mapper found for URL 'wicket/resource/org.apache.wicket.Application/pdfProducer' - 'Mapper: org.apache.wicket.core.request.mapper.ResourceReferenceMapper; Score: 1' Non-Working Version 6.13 Debug trace 2015-03-13 16:01:47,826 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - CompoundRequestMapper - No compatible mapper found for URL 'resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - ServletWebRequest - Calculating context relative path from: context path '', filterPrefix '', uri '/resource/org.apache.wicket.Application/pdfProducer' 2015-03-13 16:01:47,826 DEBUG - RequestCycle - No suitable handler found for URL resource/org.apache.wicket.Application/pdfProducer, falling back to container to process this request -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 4:17 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, This is your code: WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; There is nothing Component specific here. Except #getSession(), but you can use Session.get() and cast it. It is the same. If you need the component to be able to generate the PDF bytes then you need to implement IResourceListener interface. In #onResourceRequested() you can generate the bytes and write them to the Response: getResponse().write(byte[]). The change you need to do is in #urlFor(): urlFor(ResourceListener.INTERFACE, parameters)) Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 8:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the
RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Passing something that allows you to produce the byte []? Sent from Samsung Mobile Original message From: Bruce Lombardi brlom...@gmail.com Date:13/03/2015 20:20 (GMT+01:00) To: users@wicket.apache.org Subject: RE: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Thanks Ernesto, I don't know how to pass a byte[] as a parameter. Bruce -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Friday, March 13, 2015 2:20 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Pass the info as parameters on the request to the mounted resource? On Fri, Mar 13, 2015 at 7:15 PM, Bruce Lombardi brlom...@gmail.com wrote: Martin, I'm looking into mounting the resource but there is something that I don't understand. Currently I am creating the resource in my panel and passing the pdf I want to display into the constructor of the resource. If I mount the resource, how do I provide it with the dynamically generated pdf? I don't even see a way of getting a hold of the resourceReference object created and mounted in the WebApplication init() method. Perhaps I need to also register it as an application-shared resource, then access it in my panel constructor and add the pdf there? Bruce -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Friday, March 13, 2015 12:53 PM To: users@wicket.apache.org Subject: Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13 Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource {
Re: PDF viewed in panel via ResourceReference works in 6.12 but not in 6.13
Hi, I think I see what happens. The ResRef is created as a local variable to create the url and then discarded. Wicket has something called ResourceReferenceRegistry. When a ResRef is used to create an url to it it is automatically registered in the registry. It seems after 6.13 there is no such auto-registration for your ResRef for some reason. You should have some WARNs in the logs. I see nothing component specific in your ResRef so I'd #mountResource() it. This way it will be always available. Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Mar 13, 2015 at 6:40 PM, Bruce Lombardi brlom...@gmail.com wrote: I have a PdfViewer page that contains a panel that displays a dynamically generated PDF using a resource reference. This works fine in Wicket 6.12.0, but when I upgrade to 6.13.0 it stops working (just changed Maven dependency - no code changes). No errors are displayed and the html is generated exactly as it is with 6.12, but the pdf does not show up in the page. By setting a breakpoint in Eclipse I have determined that code in the resource that produces the response (newResourceResponse) is never called in 6.13. After migrating to the latest version (6.19) I still get the problem. I've looked at the release notes for version 6.13 and see some changes related to IResource but nothing that looks related to this problem. I'm hoping someone has seen something similar. Here is some of the relevant code: PdfViewer .html - just has reference to panel div wicket:id=pdfPanel/div PdfPane.html - just has object reference Raw HTML object wicket:id=pdf data= border=1 width=80% height=80%/object Generated HTML - seen with view source in browser object data=./resource/org.apache.wicket.Application/pdfProducer border=1 width=80% height=80%/object PdfPanel.java - has setup for resource reference public class PdfPanel extends Panel { private static final long serialVersionUID = 1L; public PdfPanel(String id) { super(id); ResourceReference resourceReference = new ResourceReference( pdfProducer) { private static final long serialVersionUID = 1L; @Override public IResource getResource() { WebDocsSession session = (WebDocsSession)getSession(); final byte[] pdf = session.getPdf(); if(pdf == null) System.out.println(PdfPanel session.getPdf returned null); PdfResourceProducer pdfResourceProducer = new PdfResourceProducer(pdf); return pdfResourceProducer; } }; String url = (String)RequestCycle.get().urlFor(resourceReference, null); MarkupContainer wmc = new WebMarkupContainer(pdf); wmc.add(new AttributeModifier(data, url)); add(wmc); } PdfProducer.java - implements the Resource public class PdfResourceProducer extends AbstractResource { private static final long serialVersionUID = -2245331056747467763L; final byte[] pdfByteArray; public PdfResourceProducer(byte[] pdfByteArray) { super(); this.pdfByteArray = pdfByteArray; if(pdfByteArray == null) { System.out.println(PdfResourceProducer constructor called with null byte array.); } } @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType(application/pdf); // resourceResponse.setTextEncoding(utf-8); resourceResponse.setContentLength((int)pdfByteArray.length); resourceResponse.disableCaching(); //do not allow resource to be cached. resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { try { OutputStream outputStream = attributes.getResponse() .getOutputStream(); outputStream.write(pdfByteArray); outputStream.flush(); } catch (IOException e) { throw new WicketRuntimeException( Problems writing pdf to response...); } } }); return resourceResponse; }