Hi, We have the following code: static public ResourceLink getResourceLink(String id,byte[] data,final String title,String contentType){ ResourceLink resourceLink = new ResourceLink(id, new CustomResource(data,contentType,title)){ private static final long serialVersionUID = 1L;
@Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { replaceComponentTagBody(markupStream, openTag, title); } }; //resourceLink.add(new Label("title",new Model(title))); return resourceLink; } and CustomResource is: public class CustomResource extends Resource{ String filename = ""; ByteArrayResource byteArrayResource = null; public CustomResource (byte[] data,String contentType,String filename){ byteArrayResource = new ByteArrayResource(contentType,data,filename); this.filename = filename; } public IResourceStream getResourceStream() { return byteArrayResource.getResourceStream(); //return getFile(); //return getAttachment(); } } when the user presses a link of a file named: myFile.doc a save dialog is opened and the file name is ui.doc I looked into the code and found that in Resource#onResourceRequested there's the line: cycle.setRequestTarget(new ResourceStreamRequestTarget(resourceStream)); When I debugged and changed the value of fileName in ResourceStreamRequestTarget to bla.doc I got the bla.doc in the save dialog. We use Wicket 1.3.6 How can I call the constructor of ResourceStreamRequestTarget with the file name? Another question, Is there a way to get the content type out of the file without hard coding? now we have this: private String getContentType(String fileName){ fileName = fileName.toLowerCase(); String contentType = null; if (fileName.endsWith(".doc")) { contentType = "application/msword"; } else if (fileName.endsWith(".html") || fileName.endsWith(".txt") || fileName.endsWith(".log") || fileName.endsWith(".properties")) { contentType = "text/html"; } else if (fileName.endsWith(".pdf")) { contentType = "application/pdf"; } else if (fileName.endsWith(".xls")) { contentType = "application/vnd.ms-excel"; } else if (fileName.endsWith(".pot") || fileName.endsWith(".pps") || fileName.endsWith(".ppt")) { contentType = "application/vnd.ms-powerpoint"; } else if (fileName.endsWith(".zip")) { contentType = "application/x-zip-compressed"; } else if (fileName.endsWith(".jpg")) { contentType = "image/jpeg"; } else if (fileName.endsWith(".png")) { contentType = "image/png"; } else if (fileName.endsWith(".gif")) { contentType = "image/gif"; } else if (fileName.endsWith(".mp3")) { contentType = "audio/mpeg"; } else if (fileName.endsWith(".bmp")) { contentType = "image/bmp"; } else { // try { // contentType ="text/"+fileName.substring(fileName.lastIndexOf(".")+1); // } catch (Exception e) { // } } return contentType; } BTW, I've noticed that there's DownloadLink. Should we use this? Thanks Eyal Golan egola...@gmail.com Visit: http://jvdrums.sourceforge.net/ LinkedIn: http://www.linkedin.com/in/egolan74 P Save a tree. Please don't print this e-mail unless it's really necessary