本文整理汇总了Java中org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler.setContentDisposition方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceStreamRequestHandler.setContentDisposition方法的具体用法?Java ResourceStreamRequestHandler.setContentDisposition怎么用?Java ResourceStreamRequestHandler.setContentDisposition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler
的用法示例。
在下文中一共展示了ResourceStreamRequestHandler.setContentDisposition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRequest
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onRequest() {
HttpResourceStream stream = getResourceStream();
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(stream);
String key = StringUtils.isNotBlank(fileKey) ? fileKey + "_" : "";
String ext = "";
if (StringUtils.isNotBlank(mimeType)) {
String extByMimeType = MIME_TYPES_LOADER.getFileExt(mimeType);
ext = StringUtils.isBlank(extByMimeType) ? ".bin" : ("." + extByMimeType);
}
String fileName = key + (stream.getFilename() == null ? name : stream.getFilename()) + ext;
handler.setFileName(fileName);
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
示例2: onClick
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onClick() {
final InputStream stream = getModelObject();
if (stream == null) {
throw new IllegalStateException(getClass().getName() + " failed to retrieve a File object from model");
}
InputStreamResourceStream resourceStream = new InputStreamResourceStream(stream);
// maybe file name and display name should be seperated?
ResourceStreamRequestHandler requestHandler = new ResourceStreamRequestHandler(resourceStream,
String.valueOf(getBody().getObject()));
requestHandler.setContentDisposition(ContentDisposition.ATTACHMENT);
getRequestCycle().scheduleRequestHandlerAfterCurrent(requestHandler);
}
示例3: onRequest
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onRequest() {
final ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(),
getFileName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
示例4: onRequest
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onRequest()
{
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(
getResourceStream(), getFileName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
示例5: commonInit
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
void commonInit()
{
downloadBehavior = new AbstractAjaxBehavior()
{
private static final long serialVersionUID = 3472918725573624819L;
@Override
public void onRequest()
{
String name = filename != null ? filename.getObject() : null;
// If no filename has been set explicitly, try to get it from the resource
IResourceStream is = AjaxDownloadLink.this.getModelObject();
if (name == null) {
if (is instanceof FileResourceStream) {
name = ((FileResourceStream) is).getFile().getName();
}
else if (is instanceof FileSystemResourceStream) {
name = ((FileSystemResourceStream) is).getPath().getFileName().toString();
}
}
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(
AjaxDownloadLink.this.getModelObject(), name);
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
};
add(downloadBehavior);
}
示例6: onRequest
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onRequest() {
final ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(this.getResourceStream(), this.getFileName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
this.getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
示例7: onRequest
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入方法依赖的package包/类
@Override
public void onRequest() {
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(), getFileDisplayName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}