You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ann Baert <an...@tvh.be> on 2010/10/13 16:09:26 UTC
DownloadLink with AjaxIndicator
I would like to add an ajaxindicator on a DownloadLink.
How can I do this?
But because DownloadLink isn't ajax, I tried the following:
AjaxLink downloadLink = new AjaxLink("id") {
@Override
public void onClick(AjaxRequestTarget target) {
}
};
downloadLink.add(new AjaxEventBehavior("onclick") {
@Override
public void onEvent(final AjaxRequestTarget target) {
RequestCycle.get().setRequestTarget(new IRequestTarget() {
public void detach(RequestCycle requestCycle) {
}
public Object getLock(RequestCycle requestCycle) {
return null;
}
public void respond(RequestCycle requestCycle) {
WebResponse r = (WebResponse) requestCycle.getResponse();
r.setAttachmentHeader("header.ext");
r.setContentType("application/contentype");
...
Streams.copy(bais, r.getOutputStream());
target.appendJavascript("...");
}
});
}
@Override
protected CharSequence getEventHandler() {
AppendingStringBuffer handler = new AppendingStringBuffer();
handler.append("...");
handler.append(super.getEventHandler());
return handler;
}
});
add(downloadLink);
Thanks
Ann
**** DISCLAIMER ****
http://www.tvh.com/newen2/emaildisclaimer/default.html
"This message is delivered to all addressees subject to the conditions
set forth in the attached disclaimer, which is an integral part of this
message."
Re: DownloadLink with AjaxIndicator
Posted by Altuğ Bilgin Altıntaş <al...@gmail.com>.
my below example codes works on http://jquery.malsup.com/block/
//******************************************************
public class BlockerBehaviour {
@SuppressWarnings("unused")
private String componentId;
public BlockerBehaviour(String componentId) {
this.componentId = componentId;
}
public String getJSBlock() {
String JS = " $(document).ready(function() {\n" +
" $.blockUI({ message: '<h1><img
src=\"images/ajax_indicator.gif\" /> "+ new
ResourceModel("please.wait").getObject()+"</h1>' });\n" +
"}) ;";
return JS;
}
public String getJSUnBlock() {
String JS = " $(document).ready(function() {\n" +
" $.unblockUI(); " +
"}) ;";
return JS;
}
}
//*******************************************************************************
public abstract class MyAjaxIndicatorButton extends AjaxButton {
private static final long serialVersionUID = 1L;
public MyAjaxIndicatorButton (String id) {
super(id);
}
@Override
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
private static final long serialVersionUID = 1L;
@Override
public CharSequence decorateOnFailureScript(CharSequence script)
{
return script + " " + new
BlockerBehaviour(getId()).getJSUnBlock();
}
@Override
public CharSequence decorateScript(CharSequence script) {
return script + " " + new
BlockerBehaviour(getId()).getJSBlock();
}
@Override
public CharSequence decorateOnSuccessScript(CharSequence script)
{
return script + " " + new
BlockerBehaviour(getId()).getJSUnBlock();
}
};
} ;
}
2010/10/13 Ann Baert <an...@tvh.be>
> I would like to add an ajaxindicator on a DownloadLink.
> How can I do this?
>
> But because DownloadLink isn't ajax, I tried the following:
>
> AjaxLink downloadLink = new AjaxLink("id") {
>
> @Override
> public void onClick(AjaxRequestTarget target) {
>
> }
> };
> downloadLink.add(new AjaxEventBehavior("onclick") {
>
> @Override
> public void onEvent(final AjaxRequestTarget target) {
> RequestCycle.get().setRequestTarget(new IRequestTarget() {
>
> public void detach(RequestCycle requestCycle) {
> }
>
> public Object getLock(RequestCycle requestCycle) {
> return null;
> }
>
> public void respond(RequestCycle requestCycle) {
> WebResponse r = (WebResponse) requestCycle.getResponse();
> r.setAttachmentHeader("header.ext");
> r.setContentType("application/contentype");
>
> ...
> Streams.copy(bais, r.getOutputStream());
>
> target.appendJavascript("...");
> }
> });
>
> }
>
> @Override
> protected CharSequence getEventHandler() {
> AppendingStringBuffer handler = new AppendingStringBuffer();
> handler.append("...");
> handler.append(super.getEventHandler());
> return handler;
> }
> });
> add(downloadLink);
>
>
>
> Thanks
> Ann
> **** DISCLAIMER ****
>
> http://www.tvh.com/newen2/emaildisclaimer/default.html
>
> "This message is delivered to all addressees subject to the conditions
> set forth in the attached disclaimer, which is an integral part of this
> message."
>
Re: DownloadLink with AjaxIndicator
Posted by MZ...@osc.state.ny.us.
AjaxIndicatorAppender?
http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/ajax/markup/html/AjaxIndicatorAppender.html
From: Ann Baert <an...@tvh.be>
To: users@wicket.apache.org
Date: 10/13/2010 10:09 AM
Subject: DownloadLink with AjaxIndicator
I would like to add an ajaxindicator on a DownloadLink.
How can I do this?
But because DownloadLink isn't ajax, I tried the following:
AjaxLink downloadLink = new AjaxLink("id") {
@Override
public void onClick(AjaxRequestTarget target) {
}
};
downloadLink.add(new AjaxEventBehavior("onclick") {
@Override
public void onEvent(final AjaxRequestTarget target) {
RequestCycle.get().setRequestTarget(new IRequestTarget() {
public void detach(RequestCycle requestCycle) {
}
public Object getLock(RequestCycle requestCycle) {
return null;
}
public void respond(RequestCycle requestCycle) {
WebResponse r = (WebResponse) requestCycle.getResponse();
r.setAttachmentHeader("header.ext");
r.setContentType("application/contentype");
...
Streams.copy(bais, r.getOutputStream());
target.appendJavascript("...");
}
});
}
@Override
protected CharSequence getEventHandler() {
AppendingStringBuffer handler = new AppendingStringBuffer();
handler.append("...");
handler.append(super.getEventHandler());
return handler;
}
});
add(downloadLink);
Thanks
Ann
**** DISCLAIMER ****
http://www.tvh.com/newen2/emaildisclaimer/default.html
"This message is delivered to all addressees subject to the conditions
set forth in the attached disclaimer, which is an integral part of this
message."
Notice: This communication, including any attachments, is intended solely
for the use of the individual or entity to which it is addressed. This
communication may contain information that is protected from disclosure
under State and/or Federal law. Please notify the sender immediately if
you have received this communication in error and delete this email from
your system. If you are not the intended recipient, you are requested not
to disclose, copy, distribute or take any action in reliance on the
contents of this information.