You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by SeldonCrisis <nm...@gmail.com> on 2017/03/01 16:14:13 UTC

Re: Display PDF in new tab

Thank you both very much, your answers were quite helpful. And thanks to you
twice Martin, since you wrote the useful article that was linked here as
well. 

Just out of curiousity, is there a button equivalent of resourceLink? I
could just style a link to look like a button through CSS, but I'm assuming
there is a better solution. 

Thanks again 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677215.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Actually, scratch that. My question is now: How do I add Ajax events to
resourceLink so that I can enable/disable certain components after having
served my resource? 

I've tried this HTML trick: 

but I end up with this error: Unable to find component with id
'resourceButton' in [ResourceLink [Component id = resourceLink]] 

and  is not a valid solution. Any suggestions?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677218.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Actually, scratch that. My question is now: How do I add Ajax events to
resourceLink so that I can enable/disable certain components after having
served my resource? 

I've tried this HTML trick:  <button wicket:id="resourceButton"
type="button" name="resourceButton"> <> Im a button</button> 

but I end up with this error: Unable to find component with id
'resourceButton' in [ResourceLink [Component id = resourceLink]] 

and resouceLink.add(resourceButton); is not a valid solution. Any
suggestions?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677217.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Actually, scratch that. My question is now: How do I add Ajax events to
resourceLink so that I can enable/disable certain components after having
served my resource? OR how do I use my resourceReference in an AjaxButton to
actually serve the resource? ResourceLink practically takes care of that for
you. 

I've tried this HTML trick: 


but I end up with this error: Unable to find component with id
'resourceButton' in [ResourceLink [Component id = resourceLink]] 

and 

 is not a valid solution. Any suggestions?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677220.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
NEVERMIND, I figured it out. It's embarassing how easy that was...

<button wicket:id="ByteArrayResourceLink" taget="_blank" type =
"button">Click Me!</button>

Thanks again guys 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677216.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Actually, scratch that. My question is now: How do I add Ajax events to
resourceLink so that I can enable/disable certain components after having
served my resource? OR how do I use my resourceReference in an AjaxButton to
actually serve the resource? ResourceLink practically takes care of that for
you.

I've tried this HTML trick:
<button wicket:id="resourceButton" type="button" name="resourceButton"> <>
Im a button</button> 

but I end up with this error: Unable to find component with id
'resourceButton' in [ResourceLink [Component id = resourceLink]] 

and
resouceLink.add(resourceButton);
 is not a valid solution. Any suggestions?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677219.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Awesome! 



Thanks Martin! 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677266.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Mar 7, 2017 at 9:00 PM, Martin Grigorov <mg...@apache.org>
wrote:

>
> On Tue, Mar 7, 2017 at 5:09 PM, SeldonCrisis <nm...@gmail.com> wrote:
>
>> Sure, I can do that! *BUT* in exchange, I'll need /a little/ more help...
>>
>> I basically used the solution that Ernesto had provided for us, I just
>> needed to spend some time understanding how it worked:
>> AJAX update and file download in one blow
>> <https://cwiki.apache.org/confluence/display/WICKET/AJAX+
>> update+and+file+download+in+one+blow>
>>
>> And here is how I implemented it (I am using SAP Crystal Reports for
>> docgen,
>> in case anyone was curious)
>>
>> *First, I created my own custom resource.*
>>
>> /returnStream()/ had to be implemented because /AJAXDownload/, the class
>> provided to us by Ernesto, is using the hook method /getResourceStream()/,
>> which expects an /IResourceStream/ object.
>>
>> *Second, I implemented Ernestos class. I've posted the link, please refer
>> to
>> that for the code.*
>> *Important*: you can change the way the resource is provided (in window/as
>> download) in the /onRequest()/ method of /AJAXDownload/ as such:
>>
>>
>> *Third, I used my resource and Ernestos AjaxBehavior in conjunction on the
>> same button, so I was able to initiate a download AND change the
>> visibility
>> of components with the same input event: *
>>
>> And that was it. Much easier than I had made it out to be, I was just
>> intimidated because I'm a wicket noob.
>>
>> *BUT Here is my new problem*: I still need the resource to be displayed
>> in a
>> new tab as opposed to as a download or in the same window. As you can
>> see, I
>> tried implementing
>> but it still wont work. Keep in mind that I would really like for this to
>> be
>> a button. I know I could just style a link to look like a button with CSS,
>> but that is a work-around solution (one that I'm not very fond of). There
>> must be a way, but at this point I'm a little stumped. Any ideas?
>>
>
> In https://issues.apache.org/jira/browse/WICKET-6286 we introduce an
> improved version of AjaxDownload.
> It supports downloading via redirect as the original version and via
> iframe, this one supports callbacks.
> I wonder whether by using a third approach, window.open(), we could add
> support for your use case too.
> Let me try !
>

It works !

Added the functionality with
https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=bb46817


>
>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.n
>> 4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677260.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Display PDF in new tab

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Mar 7, 2017 at 5:09 PM, SeldonCrisis <nm...@gmail.com> wrote:

> Sure, I can do that! *BUT* in exchange, I'll need /a little/ more help...
>
> I basically used the solution that Ernesto had provided for us, I just
> needed to spend some time understanding how it worked:
> AJAX update and file download in one blow
> <https://cwiki.apache.org/confluence/display/WICKET/
> AJAX+update+and+file+download+in+one+blow>
>
> And here is how I implemented it (I am using SAP Crystal Reports for
> docgen,
> in case anyone was curious)
>
> *First, I created my own custom resource.*
>
> /returnStream()/ had to be implemented because /AJAXDownload/, the class
> provided to us by Ernesto, is using the hook method /getResourceStream()/,
> which expects an /IResourceStream/ object.
>
> *Second, I implemented Ernestos class. I've posted the link, please refer
> to
> that for the code.*
> *Important*: you can change the way the resource is provided (in window/as
> download) in the /onRequest()/ method of /AJAXDownload/ as such:
>
>
> *Third, I used my resource and Ernestos AjaxBehavior in conjunction on the
> same button, so I was able to initiate a download AND change the visibility
> of components with the same input event: *
>
> And that was it. Much easier than I had made it out to be, I was just
> intimidated because I'm a wicket noob.
>
> *BUT Here is my new problem*: I still need the resource to be displayed in
> a
> new tab as opposed to as a download or in the same window. As you can see,
> I
> tried implementing
> but it still wont work. Keep in mind that I would really like for this to
> be
> a button. I know I could just style a link to look like a button with CSS,
> but that is a work-around solution (one that I'm not very fond of). There
> must be a way, but at this point I'm a little stumped. Any ideas?
>

In https://issues.apache.org/jira/browse/WICKET-6286 we introduce an
improved version of AjaxDownload.
It supports downloading via redirect as the original version and via
iframe, this one supports callbacks.
I wonder whether by using a third approach, window.open(), we could add
support for your use case too.
Let me try !


>
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677260.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Sure, I can do that! *BUT* in exchange, I'll need /a little/ more help...  

I basically used the solution that Ernesto had provided for us, I just
needed to spend some time understanding how it worked: 
AJAX update and file download in one blow
<https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow>  

And here is how I implemented it (I am using SAP Crystal Reports for docgen,
in case anyone was curious)

*First, I created my own custom resource.*

/returnStream()/ had to be implemented because /AJAXDownload/, the class
provided to us by Ernesto, is using the hook method /getResourceStream()/,
which expects an /IResourceStream/ object. 

*Second, I implemented Ernestos class. I've posted the link, please refer to
that for the code.*
*Important*: you can change the way the resource is provided (in window/as
download) in the /onRequest()/ method of /AJAXDownload/ as such:


*Third, I used my resource and Ernestos AjaxBehavior in conjunction on the
same button, so I was able to initiate a download AND change the visibility
of components with the same input event: *

And that was it. Much easier than I had made it out to be, I was just
intimidated because I'm a wicket noob. 

*BUT Here is my new problem*: I still need the resource to be displayed in a
new tab as opposed to as a download or in the same window. As you can see, I
tried implementing 
but it still wont work. Keep in mind that I would really like for this to be
a button. I know I could just style a link to look like a button with CSS,
but that is a work-around solution (one that I'm not very fond of). There
must be a way, but at this point I'm a little stumped. Any ideas?


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677260.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Better than thanks, which are accepted with gratitude, would be also
sharing your solution :-) So, that also other guys could benefit ;-)

On Fri, Mar 3, 2017 at 4:13 PM, SeldonCrisis <nm...@gmail.com> wrote:

> Got it figured out. Thank you everyone for your help
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677240.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Got it figured out. Thank you everyone for your help  

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677240.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I'd recommend you to use plain JS to make the Label visible.
AjaxButton yourAjaxButtonWithResource = new AjaxButton("button) {
  @Override protected void updateAjaxAttributes(AjaxRequestAttributes
attributes) {
      attributes.getAjaxCallListeners().add(new
AjaxCallListener().onBeforeSend("$('#labelId').show()"));
  }
  ...
}

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Mar 2, 2017 at 7:29 PM, SeldonCrisis <nm...@gmail.com> wrote:

> OK, thanks Ernesto and everyone else.
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677230.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
OK, thanks Ernesto and everyone else. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677230.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
See.

https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow

There was some work to move such functionality to wicket core. You need
some variation of it, I guess.

On Mar 2, 2017 17:30, "SeldonCrisis" <nm...@gmail.com> wrote:

> Yes, sorry for the spam. I kept forgetting to enclose the html in . My
> fault.
>
> OK, so ideally I want to create an AjaxButton that when pressed would serve
> my custom resource (extending ByteArrayResource) in a new tab and
> simultaneously setEnabled(true) and setVisible(true) on a Label in my page.
> Right now I'm using a ResourceLink and ResourceReference to display my
> resource in a new tab. But I cannot add Ajax Events to ResourceLinks
> onClick, and I want a Button not a Link.
>
> Sorry, RTFM definitely applies here, but I don't know if I need to read
> about wickets requestCycle to accomplish this or something else. I'm trying
> to mess around with ITargetRespondListener for now, but I'm not sure if I'm
> on the right track.
>
> --
> View this message in context: http://apache-wicket.1842946.n
> 4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677227.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Yes, sorry for the spam. I kept forgetting to enclose the html in . My fault. 

OK, so ideally I want to create an AjaxButton that when pressed would serve
my custom resource (extending ByteArrayResource) in a new tab and
simultaneously setEnabled(true) and setVisible(true) on a Label in my page.
Right now I'm using a ResourceLink and ResourceReference to display my
resource in a new tab. But I cannot add Ajax Events to ResourceLinks
onClick, and I want a Button not a Link. 

Sorry, RTFM definitely applies here, but I don't know if I need to read
about wickets requestCycle to accomplish this or something else. I'm trying
to mess around with ITargetRespondListener for now, but I'm not sure if I'm
on the right track. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677227.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Got lost with some many self responses :-) What do you want to achieve now?
AJAX + SHOW PDF?

On Wed, Mar 1, 2017 at 10:41 PM, SeldonCrisis <nm...@gmail.com> wrote:

> I've already seen this reference document, but I skipped over it thinking
> it
> did not apply to my problem (Probably as a result of my lack of Wicket
> experience). I will go ahead and carefully read through it again to see if
> I
> can figure this out. Thanks!
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677224.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
I've already seen this reference document, but I skipped over it thinking it
did not apply to my problem (Probably as a result of my lack of Wicket
experience). I will go ahead and carefully read through it again to see if I
can figure this out. Thanks! 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677224.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Display PDF in new tab

Posted by Claudia Hirt <hi...@gmx.de>.
Hi,
Maybe this solution could help you:
https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow

Von meinem iPhone gesendet

> Am 01.03.2017 um 21:20 schrieb SeldonCrisis <nm...@gmail.com>:
> 
> Actually, scratch that. My question is now: How do I add Ajax events to
> resourceLink so that I can enable/disable certain components after having
> served my resource? OR how do I use my resourceReference in an AjaxButton to
> actually serve the resource? ResourceLink practically takes care of that for
> you. 
> 
> I've tried this HTML trick: 
> 
> 
> but I end up with this error: Unable to find component with id
> 'resourceButton' in [ResourceLink [Component id = resourceLink]] 
> 
> and 
> 
> is not a valid solution. Any suggestions?
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677222.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

Re: Display PDF in new tab

Posted by SeldonCrisis <nm...@gmail.com>.
Actually, scratch that. My question is now: How do I add Ajax events to
resourceLink so that I can enable/disable certain components after having
served my resource? OR how do I use my resourceReference in an AjaxButton to
actually serve the resource? ResourceLink practically takes care of that for
you. 

I've tried this HTML trick: 


but I end up with this error: Unable to find component with id
'resourceButton' in [ResourceLink [Component id = resourceLink]] 

and 

 is not a valid solution. Any suggestions?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Display-PDF-in-new-tab-tp4677202p4677222.html
Sent from the Users forum mailing list archive at Nabble.com.

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