Save file dialog - possible?

Hi! I need to save a file to the clients local file system, so it would be nice if he could choose the directory and file name. I know it;s possible in PHP, so I believe there is something similar in JSF (JSP maybe?). Actually, my application uses ADF Faces but it could work. Thanks for any clues!

You can use the MIME type which will use the browser to pop up the dialog box. I've used this with saving an Excel file through POI and it works well.
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
try {
HttpServletResponse resp = (HttpServletResponse)externalContext.getResponse();
ServletOutputStream out = resp.getOutputStream();
// SET THE MIME TYPE
resp.setContentType("application/vnd.ms-excel");
// set content dispostion to inline in
// case the open/save dialog needs to appear
resp.addHeader("content-disposition", "inline; filename=" + this.getFileName());
wb.write(out);
out.flush();
out.close();
facesContext.responseComplete();
} catch (FileNotFoundException fne) {
} catch (IOException ioe) {
ioe.toString());
}

Similar Messages

  • Save File Dialog KO

    Hi,
    I’m using the Save File Dialog KO (AW7) and would like
    to set a user selectable default directory. I’ve tried
    entering a variable set with the appropriate path in the
    ‘Begin Browsing From - Other’ text box in the KO setup
    but this doesn’t seem to work. Is it possible to do this?
    Thanks.
    Chris

    Instead of using the KO, call the function tmsSaveImageFile()
    in a calc script. (The KO has already loaded the function for you).
    Remember to distribute the u32 with your file, as you would have
    had to with the KO anyhow.
    -- Ron.

  • How to open a save file dialog box in form

    hi
    all
    I have prob in form desing , i have open the save file dialog box , how to open a save dialog box
    and path of the select file to save in disk
    help
    thx

    hi
    user this query when-button-pressed trigger
    :txtfile := GET_FILE_NAME(directory_name =>'d:\ali_raza\backup\', file_filter=> 'DMP Files (*.dmp)|*.dmp|');
    Rizwan

  • Save File-Dialog not responding

    In every document-style app (Pages, TextEdit etc.) the save file dialog suggests iCloud as default destination to save to. When I click the Drop-Down to select another location the whole application hangs and shows me the marvelous marble of death.
    Is there anybody else experiencing this? How could this be solved?
    (Behaviour seen on 10.8.2 but also on 10.8.1)

    to make things clearer a screenshot of the dialog I'm talking about. this happens everywhere such a generic save file dialog appears.

  • Finder in Save file dialog Safari crash

    Ever since I upgraded to Snow Leopard at launch, Safari 4 doesn't seem to like me searching in the save file dialog box. It doesn't seem to matter whether or not I actually save the file, and I made a screen recording to show what happens here:
    http://www.youtube.com/watch?v=YFKkPI2vGr8
    I've reset Safari, and I repaired my disk permissions after loading up Snow Leopard. What gives? This is really annoying when I want to get to a folder fast, and dragging and dropping image files to folders seems to cause them to open in different Preview windows (or not even open at all).
    Any help would be much appreciated. This is seriously making me consider going back to Firefox or just going with Chrome - this crash doesn't happen with either of them!

    The problems are caused by third party input managers/enhancers that have not yet been updated by their developers to comply with the standards used by Safari 3.2.1. and/or Safari 4.
    In your case these are:
    com.zang.RegexKit 0.6.0 (0.6.0) <71374A4A-3B24-4759-E994-AB9E135345CB> /Library/InputManagers/Safari AdBlock/Safari AdBlock Loader.bundle/Contents/PlugIns/Safari AdBlock.bundle/Contents/MacOS/../Frameworks/RegexKit.framework/Versions/A/Regex Kit
    You fill find them in one or either of these folders:
    Home/Library/Input Managers
    Hard Disk/library/Input Managers
    Hard Disk/Library/Application Support
    although the exact location is indicated in your crash report as quoted above - look under 'Binary Images'.
    Close Safari and delete them, then restart Safari and it should be working normally. Alternatively drag them to the desktop and restart Safari. then add them back one at a time, restarting Safari every time, until you find the one (or more) causing the crash.
    Check with the developers of the plug-ins in question for updates that are Safari 4 compliant.

  • Save File dialog from dll is not appearing to the front of TestStand window

    Hi all,
    I am calling a C#.net dll from a step in TestStand sequence. A function is called which pops up a Save File dialog. This Save File dialog is appearing only behind other windows. There is an overload for the showDialog function that takes the owner form as argument. My dll doesnot have a form. I would like to know how can I pass the TestStand form as owner to this Save File dialog object.
    Thanks in advance

    Biju,
    You can build create the implement the IWin32Window interface and get the handle of TestStand window. I have created an example you can check out.
    Regards,
    Song Du
    Systems Software
    National Instruments R&D
    Attachments:
    Class1.cs ‏1 KB

  • How to incorporate File name and timestamp automatically into select and save file dialog box?

    Hello,
    i am trying to incorporate the file name which is inputed by the user along with the timestamp into the selected and save file dialog box. Can you help?
    Thanks
    Solved!
    Go to Solution.

    You can pass a default file name to the 'File Dialog' Express VI.
    Use the 'selected path' output to open the file.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    FileDialog.vi ‏21 KB

  • Save File Dialog problem

    Hello ! I'm new with java so dont be to rude plz ;) ...
    First, my situation :
    I have a jsp that calls a servlet that get data from a database. After that I have to take these data and write them in a .txt file by calling a Save File Dialog. What I've done for now is to put
    response.setContentType("application/msword");
    response.setHeader("Content-Disposition",
    "attachment; filename=\""+fileName+"\"");
    in my servlet after created my file.
    My problem :
    The Save File Dialog shown but if I save the file, it contains the code of my jsp page. I suppose that I have to "bind" the file and the response, but how do I do that ??
    Or if you have a better way to do it ...
    Thx a lot !

    Here's some changes ...
    I'm now able to get the file with a Save File Dialog, but I also get my jsp code in the top of my page.
    Here's my code :
    String fileName = "MyData.txt";
    File myFile = (File)request.getAttribute("file");
    /*cyc.mypackage.DataDefects ddDefects = bConn.getddMyDefects();
    cyc.mypackage.Export exp = new cyc.mypackage.Export();
    File myFile = exp.createDataFile(ddDefects, fileName);*/
    String value = "attachment; filename=\"" + myFile.getName() + "\";" ;
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition",value);
    response.setContentLength((int)myFile.length());
    BufferedInputStream fif = new BufferedInputStream(new FileInputStream(myFile.getAbsolutePath()));
    int data;
    while((data = fif.read()) != -1)
    out.write(data);
    fif.close();
    and the result is :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link href="./css/Cyclic.css" type="text/css" rel="stylesheet">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>Infos</title>
    </head>
    <body>
    <form id="fInfos" method="POST" action="./Login.jsp" >
    <input type="submit" value="Unconnect" />
    </form>
    <form id=...>
    ( ... I dont put all cause the code is too long ...)
    </form>
    212007778197.9059295654296875-1600
    212007779245.207000732421875-1600
    212007779927.3587188720703125-1600
    212007774641.695709228515625-960
    (... rest of my good data)
    Does anybody knows how to get rid of the jsp code ??

  • Suggest a filename extension in a save file dialog

    Hello guys,
    does any of you know, how to suggest the user a certain filename extension in a save file dialog?
    I'm using both the normal save file dialog:
         javax.swing.JFileChooser.showSaveDialog,
    and the Java Web Start save file dialog:
         javax.jnlp.FileSaveService.saveFileDialog.
    For both ways I seem not to be able to suggest the user a certain extension for the filename.
    For the normal dialog, I call setFileFilter on the JFileChooser instance.
    The filter shows up in the dialog, and is used by default, but when the user types a name and approves, the returned filename does not have the extension added.
    Of course I can add the extension programmaticaly, but not when inside the JAWS sandbox.
    For the JAWS dialog, I pass an array containing my extension, but it is ignored as if I didn't specify any extensions. The API specs already say that this parameter "might be ignored by the JNLP Client".
    So how to tell the user what extension to use?
    More people must have encountered this problem.
    I'm making an application that saves and opens xml files and exports html files.
    I'm using this code to test the behavior:import java.io.ByteArrayInputStream;
    import java.io.File;
    import javax.jnlp.FileContents;
    import javax.jnlp.FileSaveService;
    import javax.jnlp.ServiceManager;
    import javax.jnlp.UnavailableServiceException;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    public class ChooseFile
        static final String[] EXTENSIONS = { "xml" };
        static final String DESCRIPTION = "XML files";
        public static void main(String[] args)
         try {
             ServiceManager.lookup("javax.jnlp.FileOpenService");
             // we're running with JAWS
             System.out.println("JAWS filechooser:");
             System.out.println(choose_JAWS());
         catch (UnavailableServiceException x)
             // we're NOT running with JAWS
             System.out.println("normal filechooser:");
             System.out.println(choose_normal());
        static String choose_normal()
         JFileChooser fc = new JFileChooser();
         fc.setFileFilter(new CustomFileFilter(EXTENSIONS, DESCRIPTION));
         if (JFileChooser.APPROVE_OPTION == fc.showSaveDialog(null))
             return "selected " + fc.getSelectedFile().getName();
         else
             return "cancelled";
        static String choose_JAWS()
         try {
             FileSaveService fos = (FileSaveService)ServiceManager.lookup(
                         "javax.jnlp.FileSaveService");
             ByteArrayInputStream stream = new ByteArrayInputStream(new byte[] {});
             FileContents fc = fos.saveFileDialog(null, EXTENSIONS, stream, null);
             if (fc != null)
              return "selected " + fc.getName();
             else
              return "cancelled";
         } catch (Exception x)
             x.printStackTrace();
            return "";
    class CustomFileFilter extends FileFilter
        String[] extensions;
        String description;
        public CustomFileFilter(String[] extensions, String description)
         this.extensions = extensions;
         this.description = description;
        public boolean accept(File f)
         if (f.isDirectory())
             return true;
         String extension = getExtension(f);
            if (extension == null)
                return false;
         for (int i=extensions.length; i-->0; )
             if (extension.equals(extensions))
              return true;
         return false;
    public String getDescription()
         return description;
    private String getExtension(File f)
    String ext = null;
    String s = f.getName();
    int i = s.lastIndexOf('.');
    if (i > 0 && i < s.length() - 1)
    ext = s.substring(i+1).toLowerCase();
    return ext;
    }Any help is greatly appreciated!
    Tom Jansen

    @tjacobs01
    Hi Tom,
    I have a question regarding your classes
    tjacobs.ui.fc.FileExtensionFilter and
    tjacobs.ui.fc.FileChooser.
    When I look at your code, I see the filename extension is appended in showSaveDialog:     public int showSaveDialog(Component c) {
                        setSelectedFile(new File(f.getAbsolutePath() + "." + ((FileExtensionFilter)filter).getType()));
        }It gets the extension by calling getType on the filter. But getType is implemented as:    public String getType () {
            return mExtensionList.get(0).toString();
        }So this returns the first type in the list. It does not check what filetype is selected by the combobox.
    Am I missing something?
    Also, in getDescription:    public String getDescription() {
            if (mDesc == null) {
                mDesc = "";
                for (int i = 0; i < mExtensionList.size(); i++) {
                    mDesc += (i != 0 ? ", " : "") + "." + mExtensionList.get(0).toString();
                mDesc+= " files";
            return mDesc;
        }you seem to iterate through the list, but only take the first entry every iteration.
    Can you explain mExtensionList.get(0)?
    Do you know how to test what type is selected in the JFileChooser's combobox?

  • Windows Classis Theme - Windows Classic Start Menu / Save Files Dialog

    MS, please keep a way back to the 9x interface!
    Really anoying that the Windows Classis Start menu (Windows 9x etc.) is not available in Win7.
    (and apparently no option "Always Show All Programs" option is available and the subprograms are listed in the same window which makes it a long list)
    People and commpanies want the option to go to the old-familiair Windows Classic (9x) interface!!!!
    We know it, it works and it suits the purpose: why change!
    Furthermore in a company environment all files are saved in a directory structure and not in the 'favorites' folders in the user profile. So please...make a simple classic w7 interface like XP (with a simple Save File Dialog) and not a Christmass Three with bells Interface like W7.
    [i think that's one of the reson that ofiice 2007/vista doesn't sell as it should. I'm affraid it is a marketing strategy of MS. But unfortunately I think it drives more people in to alternatives like openoffice etc.]

    The XP and later interface has always looked like something designed by Fisher-Price to me. Much more annoying, though, is the inability to go the Classic Start Menu. This is sufficient to cause me to stick with XP until it simply can't handle the then-current software. By that time, Linux should be able to run all Windows progams; it is getting closer to that now. Are you listening, MSFT? I'm an MCP with other certs, and, unless you give the option for the Classic Start Menu and a menu that shows all programs (not just a "personalized menu), XP may be my final Windows version.
    I really do not understand Microsoft's lack of logic here. They changed the interface in Office 2007 with the ribbon; millions upon millions of users were proficient with the interface prior to that, and MSFT says they have to learn a new one (I agree with Frank1977 here that it's driving people to OpenOffice). That sounds like a New Coke decision to me. Maybe they have an Apple or Linux mole in there, seeking to give bad advice purposely (for any Biblically literate readers, think "Hushai the Archite", and the advice he gave Absalom).
    I have defended Microsoft to many Microsoft-bashers at work, but this is becoming more and more difficult to do. And I'm losing my incentive to do so. PLEASE, Microsoft, add power and abilities, as you are doing, but don't arrogantly insist on forcing professional users to learn a new (and less capable) interface.
    Well said , Tewald , have considered other options lately as far as "other operating systems go" , you listening Micro soft ?
    MB

  • Open Save File Dialog with Default Path

    Hi All,
    I want to open a "Save File Dialog " with some default path.
    Like when user run that script I want to open  a "Save As" dialog box with default path "/Volumes/<shared name>/<folder name>/.. ."
    I am using
    File.SaveDialog(prompt, filter);
    but it doesn't open to the location by default that I want to open.
    Thanks
    Harsh

    look at this thread to see if it helps
    http://forums.adobe.com/thread/1077267?tstart=0

  • Help!  Save File Dialog CRASHES Every Program

    Suddenly, I cannot save a file in any program in Mac OS X. As soon as I select "Save..." or hit Ctrl+S, the program crashes. This happens in every program, all of them!
    The problem persists across multiple reboots, and even after repairing permissions, verifying the disk, and booting into single-user mode and running fsck (and the disk passed).
    Please email me directly at jonmills at email dot unc dot edu if you have any ideas how to fix this. It has rendered my computer unusable, and I may have to completely re-install.

    to make things clearer a screenshot of the dialog I'm talking about. this happens everywhere such a generic save file dialog appears.

  • Problem in opening Save file Dialog..

    Hi all,
    I have a table, i want to save the table data in in csv format.So my problem starts here that when i click on button to save table data a Save dialog should be displayed where i can select path and save file.
    So please make it possible ASAP.

    Is this a Java Studio Creator JSF table component related question? If you are you talking about saving the data from the table at design time or when you run the application and you want to save the table data from the table displayed in the browser?
    Please clarify.
    thanks,
    Sandip

  • Save File Dialog with PDF servlet

    I've looked through messages posted relavent to this topic but I'm having trouble finding a solution to my particular problem.
    I'm running a servlet that is used to dynamically generate completed business documents using given a customer number. The servlet loads the customer information, generates a collection of forms as a single pdf document and sends it back to the browser.
    The problem is, the servlet doesn't work in one of the scenarios that is required: we email a link to an adminstrator that clicks on the link to view the documents, e.g.:
    http://myhost/myservlet.srv?custno=1234
    When you click on the link in the email (using Outlook), you always get the "save/open file" dialog box. If you click cancel AND LEAVE THE BROWSER OPEN and click on the link again in the email, everything works fine--the pdf document opens up in Adobe. It's just when the OS has to launch a new browser window that it doesn't work and you get the dialog.
    I've tried using the content disposition header (both inline and attachment). I've tried setting the content length. I've tried adding no cache headers. Nothing seems to work for this particular use case.
    Anybody seen this before? I could really use a hint.

    There are two thing that u can do.
    First try setting the contenttype as text/html and see
    if it works. The reason its opening a download box is
    that the stream is coming as a .pdf header and browser
    is not getting a plug in for the same.
    another way is a bit patchy.
    you have to set some kind of parameter with your url
    that u send in e-mail.
    then depending on this parameter. first send a
    javascript to reload the page.
    something like.
    if (request.getParameter("isMail))
    //send
    javascript:document.location().substring(0,indexOf('&is
    ail');
    else
    //your normal processing
    this way browser will actually resubmit the request
    from browser itself and will resume your normal
    processing.
    Regards
    KuldeepThis is kind of what we finally did. We decided that rather than have the url point directly at the servlet, we had the link point at a jsp that simply digests the parameters and constructs a new url to the servlet and then sends a redirect to the browser to the new url.

  • Open/Save File Dialog Box comes up, then does not respond for a long time or not at all

    I will click a link for a download and the box will pop up saying
    "You have chosen to open "blahblah.blah.blah
    Which is a: blah file
    From: www.randomsite.com
    What should Firefox do with this file?
    Open with
    Save File"
    At this point other than being able to see the box, it is as though it doesn't exist. I can't click okay or cancel or choose what to do. Sometimes after a few minutes it will suddenly work, other times it will just remain until Firefox closes.

    You can also try to clean install the new version after deleting the [http://kb.mozillazine.org/Profile_folder Profile Folder] as well as the [http://kb.mozillazine.org/Installation_directory Installation Folder.] Please see [https://support.mozilla.org/en-US/kb/Backing%20up%20your%20information?s=backup&r=1&e=sph&as=s this] for backing up important info. The '''places.sqlite''' file stores the bookmarks and history, the '''key3.db''' + '''siqnons.sqlite''' files are needed to successfully restore the saved passwords etc.
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Files]
    [https://www.mozilla.org/en-US/firefox/new/ Firefox Latest]

Maybe you are looking for