Setting file name for a downloaded file

I've set up a file download using code I've gleaned from jsf forums. However, the file name is not being set correctly. When the user downloads File.doc, it shows up as downloadPage.jsf. Am I setting the header correctly?
public class VendorInfoBean extends AbstractViewController {
    public VendorInfoBean() {
    public String downloadVendorApp() {
        ExternalContext context = getExternalContext();
        String path = context.getInitParameter("externalFiles");
        String filename = "Vendor_Application_e_Form.doc";
        String fullFileName = path + filename;
        File file = new File(fullFileName);
        HttpServletResponse response = (HttpServletResponse) context.getResponse();
        response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
        response.setContentLength((int) file.length());
        response.setContentType("application/msword");
        try {
            FileInputStream in = new FileInputStream(file);
            OutputStream out = response.getOutputStream();
            // Copy the contents of the file to the output stream
            byte[] buf = new byte[1024];
            int count;
            while ((count = in.read(buf)) >= 0) {
                out.write(buf, 0, count);
            in.close();
            //out.write(bytes);
            out.flush();
            out.close();
            FacesContext.getCurrentInstance().responseComplete();
        } catch (IOException ex) {
            ex.printStackTrace();
        return null;
}

StringBuffer sbFilename = new StringBuffer();
     sbFilename.append("adeem");
     sbFilename.append(".doc");
StringBuffer sbContentDispValue = new StringBuffer();
     sbContentDispValue.append("attachment");
     sbContentDispValue.append("; filename=");
     sbContentDispValue.append(sbFilename);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setHeader("Content-Disposition", sbContentDispValue.toString());
i think this will work .. if not let me know i will give some code that will work for u then ...

Similar Messages

  • Is there a setting that allows for simultaneous downloading and watching of a rental movie on ATV?

    Is there a setting that allows for simultaneous downloading and watching of a rental movie on ATV?

    Apple TV has no storage, it is caching the movie and needs to load a portion before playback starts. The time it takes is dependent on your network.
    What is your current connection via speedtest.net?
    Make sure DNS is set to auto (settings - general - network)
    If on wifi try ethernet

  • Setting Display Name for sent emails

    Hi All,
    I want to set a display name for sent emails. For example: when I send emails using [email protected] and after receivign this amil in my inbox it says from [email protected] Is there any way that I can show display name for this like Kartik <[email protected]>.
    is there any API by which I can set this display name? Or this has to be done on mail server?
    Any help would be appreciated!!
    Thanks, Kartik

    it asks for a attribute messageFrom and passes it to SMTPTransport. I have tried setting different values for messageFrom like
    messageFrom=Test Email
    messageFrom="Test Email"
    but it didn't work for me. it expects a domain name there (even if its dummy) like
    messageFrom=[email protected]
    Can you tell me at which place InternetAddress is been called by SMTPTransport so that I can write my own impl for it.

  • ExprHow to set default name for Express VI

    I have created an express and when I drag drop the express in block diagram, I am getting a name "A1". What should I do to set a default name (for example "B") for my express VI? I tried updating the Window title properties of the source VI.
    Thanks in advance.
    Regards,
    Satish

    Hello diademi!
    Select the menu 'Einstellungen' / 'Optionen' / 'Allgemeines...'. You get the dialog 'Allgemeine Einstellungen'. Click on the button 'Kompatibilität...'. In the dialog 'Kompatibilität' you have the flag 'Sprachunabhängige Ergebniskanalnamen in ANALYSIS' where you can set the behaviour. If you press Ctrl+A and paste in a text editor you can see that it is variable CompResChnNaming.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • Setting network name for shared music...

    How do I set the name of my shared music so it doesn't say somenting stupid like "Joe Blow's Music"?

    iTunes Preferences > General > look for Shared Name at the bottom of the page. Name it whatever you like.

  • How to set the name for an 'unknown' file extension?

    Specifics:
    I have various file extensions that are recognized by my mac. I would like to know how to create a list of applications that can open it so I do not get a 'There is no Default Application to open this file' error. I would also like to be able to give these file extensions names recognized by the mac.
    Just like .txt is a "Textedit Document" and .html is a "HTML Document," I'd like to be able to change the name and assosication of a file and give it its own .icns if possible.
    As for the default applications, I know how to set a default application. However, if a mac does not recognize a file extension, adding a new default application to run the file wil actually erase the old one, which is a big pain, especially when your file can be opened with ANY text editor.
    I understand that this may involve hacking into the operating system's databases, but if anyone can help, it would be greatly appreciated.

    Hi Timo,
    My jdev version is 10.1.3.3.0, this is for R12. By PR i mean to say process request and PFR process form request in the controller.
    In the Process request of the controller, i am finding the checkbox bean and assigning the firepartialaction for it.
    Later in the process form request for the fired event, i am trying to handle the rendered property of the messagetextinput. Is this a right approach?
    my code below
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
    OAMessageCheckBoxBean oamessagecheckboxbean = (OAMessageCheckBoxBean)oawebbean.findChildRecursive("X_FLAG");
    if(oamessagecheckboxbean != null)
    oapagecontext.writeDiagnostics(this, "Message check box Bean found:", 1);
    FirePartialAction firepartialaction = new FirePartialAction("change");
    oamessagecheckboxbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firepartialaction);
    oamessagecheckboxbean.setFireActionForSubmit("change", null, null, true);
    oapagecontext.writeDiagnostics(this, "setting fire event", 1);
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processFormRequest(oapagecontext, oawebbean);
    oapagecontext.writeDiagnostics(this, "Inside Process Form Request", 1);
    if("change".equals(oapagecontext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAMessageTextInputBean bean = (OAMessageTextInputBean)oawebbean.findChildRecursive("X_NUMBER");
    if(bean!=null){
    bean.setRendered(Boolean.TRUE);}
    Thanks,
    Malar

  • Dynamically setting manager name for trap

    As per the SEA documentation, trap destinations are specified through master agent configuration file and need to be set before starting master agent.
    We want add more managers dynamically i.e. after master and subagent are started and communicating with one manager.
    Does snmpdx provide any MIB variable to "set" the manager name? Is there any other alternative such as command line parameter or API to set the manager name?
    Thanks
    Dhananjay

    Hi,
    This feature is not supported in SEA. All the configuration should be done before starting master agent.
    To register the subagent, you can use any of the following two methods.
    * Static method : The master agent reads agent resource files. This resource
    file contains an entry for each subagent.
    * Dynamic method : The master agent receives the information from the subagents. The subagent sends a SET request containing the MIB objects needed to register with the Master Agent, through the use of the registration API.
    Using SEA, there is no way you can add the managers dynamically for traps.
    I suggest you may have look on new product from SUN i.e SunMC( Sun Management Center) which has lot of new features.
    HTH.
    Thanks,
    Santosh

  • How can I set a name for a unknown place without moving it?

    I imported some photos with GPS information into iPhoto. I can see these photos on the map with one pin per photo, but every pin is tagged with "unknown place". All the photographs were taken on the same island, so I want to add the name of this Island to all pins.
    When I enter the name of the place, iPhoto doesn't know it (it seems like the built-in database is very small), so I have to go to the Google view. There I find the Island and can create a new place, but when I confirm it all photos will move to one pin which was defined in google - the original location is lost (and there is no undo function!!!).
    Questions:
    1. How can I assign a name to a pin without moving the pin?
    2. How can I restore the original place stored in the exif-information of the file?
    Thanks a lot,
    Jürgen

    Thanks for your answer, after playing around another while I understand that using GPS-data or Places are two things which cannot be used together in a reasonable way.
    Either I use the GPS pins, then they are at the right place, but then I just have the pins on the map without any names or grouping information.
    Or I create places - I can create one place per photo, but then I would have to manage around 10.000 places in a simple list view. So if I go on a city trip and take 100 photographs with GPS, then I either have to create 100 places, just to see the name of the city above the pin, or i have to group them to one single pin in the middle of the city. I think both doesn't make sense.
    Let's hope there are some improvements in upcoming versions.
    BTW: To go back to the original GPS-location is very easy. Just remove the assigned place by clicking on the 'x', then the GPS-location is used again immediately.
    Jürgen

  • Cannot set DNS name for ORA APPS

    While installing oracle applications 11.0.2 on windows2000 advance server at the begining of the installation i m prompted with the error :
    ONE HOUR INSTALL REQUIRES THAT THE TCPIP DOMAIN NAME IS SET, THIS CAN BE SET ON THE DNS PAGE OF THE TCP ID PROPERTIES BOX.
    kindly advice as to what is to be done to se DOMAIN name
    Thanks and regards.

    Hi Krishna and everyone in the forum,
    I had the same problem and as mine is a stand alone machine, I followed your suggestion - and everything went fine. The installation was done with cd#19 (the last cd) also. And in the rapid install wizard post install checks, I got a bunch of errors saying portal check, http check etc etc. With the help of the discussions in this forum I realized that http://host:8002 was working and not http://host.domain:8002 was not.
    My mistake was that I added the wrong IP address in hosts file. So, edited that with the right IP address. As many of the tasks in rapid install were incomplete because of this, I restarted the installation (documentation says - if installation stops in the middle, restarting will work and more rapidly to the point of previous stop).
    Now the problem is that I get the error "error code received running external process........" while using DISK#1 of 19 itself. :(
    Any ideas on what can be done? Now I can go to personal home page etc using both host and host.domain.
    Please help!!!
    regards,
    Vasu

  • How to set Alias name for URL or change  URL..

    Hi:
    I am using Apache Tomcat as web server, it contains multiple web applications.
    Url for one of this application is, e.g. http://localhost:8080/myapplication. This particular url work fine.
    But i want to use only mypage word instead of all the above url.
    So how to set or map this?
    Thank You,
    Anup Desai.

    Thank you.
    I tried to set the displayname (using setPersonal function)
    Still its not working.
    I feel it is because during authentication we give the login name (which is taken as the display name).
    Is there any way to change without touching configuration level properties in exchange server 2007.
    thanks in advance

  • Setting host name for non-Apache webserver

    http://www.appdal.com is a website in my Snow Leopard Server. And I have non-Apache webserver running http://appdal.com:8080/ . I want to give host name 'pier' chaing the web host name settings of this
    But it is not working. What did I do something wrong?

    i want to setup a hostname 'pier', so i can use url 'pier.appdal.com' instead of 'appdal.com:8080'.
    Although the latter url works fine, but i don't want to foce my users to enter the :8080 .

  • How to specify file names for the generated code in wscompile

    Hi,
    We want to follow a certain file naming conventions for the artifacts generated by wscompile.
    How is it possible to set the name for the service interface file, service implementation file etc....
    This is possible in AXIS ant task Wsdl2Java. How do we do it for wscompile.
    thanx

    Thanks Chris and c. Under Description I'm presented with three Names for the profile: ASCII, UniCode and Mac Script. ASCII and Mac Script are the same name for the profile, with nothing being in the UniCode Name box. Which do I change -- both?
    Am I going to screw things up in Photoshop if I change these names to something I can comprehend? Looks like I may just have to make a sticky-note list of the cryptic profile names with my own descriptive name as a reference. Thanks.

  • Set the name of cell or cells' range for a report and when export it to excel the names will be defined.

    Hello,
    I have an C# application that exports report from Reporting Services to Excel files.
    I would like to know if there is a possibility to set the name of the cell or range of cells in the report (via Report Builder or somewhere else) and when open the Excel the names are set. Similar functinality when you open the Excel and go Formulas/Define
    Name and set the name for a unique cell or range.
    Regards,

    Hi there,
    I don't believe this is possible in Reporting Services.  One workaround, if you don't know the exact range at runtime, might be to put hidden characters (white?) in your sheet at start and end of range, then do some postprocessing on the file using
    VSTO or perhaps a 3rd-party tool like this one.  
    http://www.aspose.com/reporting-services/excel-component.aspx
    If you do know the range it should be much easier.
    cheers,
    Andrew
    Andrew Sears, T4G Limited, http://www.performancepointing.com

  • How do I set proxy settings for a Java app behind a corporate server?

    I have the source code of a Download Manager program written in Java. It has to be run within my college network in which we use the "Corporate Client" server to access the internet. The HTTP proxy is 172.16.68.6 and Port number is 3128. How do I define these parameters in my java program so that it can download files from the internet?
    The source code for the program is:
    There are four classes:
    1. DownloadManager.java
    2. Download.java
    3. DownloadTable.java
    4. ProgressRenderer.java
    /*__DownloadManager.java__*/
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    // The Download Manager.
    public class DownloadManager extends JFrame
            implements Observer {
        // Add download text field.
        private JTextField addTextField;
        // Download table's data model.
        private DownloadsTableModel tableModel;
        // Table listing downloads.
        private JTable table;
        // These are the buttons for managing the selected download.
        private JButton pauseButton, resumeButton;
        private JButton cancelButton, clearButton;
        // Currently selected download.
        private Download selectedDownload;
        // Flag for whether or not table selection is being cleared.
        private boolean clearing;
        // Constructor for Download Manager.
        public DownloadManager() {
            // Set application title.
            setTitle("Download Manager");
            // Set window size.
            setSize(640, 480);
            // Handle window closing events.
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    actionExit();
            // Set up file menu.
            JMenuBar menuBar = new JMenuBar();
            JMenu fileMenu = new JMenu("File");
            fileMenu.setMnemonic(KeyEvent.VK_F);
            JMenuItem fileExitMenuItem = new JMenuItem("Exit",
                    KeyEvent.VK_X);
            fileExitMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionExit();
            fileMenu.add(fileExitMenuItem);
            menuBar.add(fileMenu);
            setJMenuBar(menuBar);
            // Set up add panel.
            JPanel addPanel = new JPanel();
            addTextField = new JTextField(30);
            addPanel.add(addTextField);
            JButton addButton = new JButton("Add Download");
            addButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionAdd();
            addPanel.add(addButton);
            // Set up Downloads table.
            tableModel = new DownloadsTableModel();
            table = new JTable(tableModel);
            table.getSelectionModel().addListSelectionListener(new
                    ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    tableSelectionChanged();
            // Allow only one row at a time to be selected.
            table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            // Set up ProgressBar as renderer for progress column.
            ProgressRenderer renderer = new ProgressRenderer(0, 100);
            renderer.setStringPainted(true); // show progress text
            table.setDefaultRenderer(JProgressBar.class, renderer);
            // Set table's row height large enough to fit JProgressBar.
            table.setRowHeight(
                    (int) renderer.getPreferredSize().getHeight());
            // Set up downloads panel.
            JPanel downloadsPanel = new JPanel();
            downloadsPanel.setBorder(
                    BorderFactory.createTitledBorder("Downloads"));
            downloadsPanel.setLayout(new BorderLayout());
            downloadsPanel.add(new JScrollPane(table),
                    BorderLayout.CENTER);
            // Set up buttons panel.
            JPanel buttonsPanel = new JPanel();
            pauseButton = new JButton("Pause");
            pauseButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionPause();
            pauseButton.setEnabled(false);
            buttonsPanel.add(pauseButton);
            resumeButton = new JButton("Resume");
            resumeButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionResume();
            resumeButton.setEnabled(false);
            buttonsPanel.add(resumeButton);
            cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionCancel();
            cancelButton.setEnabled(false);
            buttonsPanel.add(cancelButton);
            clearButton = new JButton("Clear");
            clearButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionClear();
            clearButton.setEnabled(false);
            buttonsPanel.add(clearButton);
            // Add panels to display.
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(addPanel, BorderLayout.NORTH);
            getContentPane().add(downloadsPanel, BorderLayout.CENTER);
            getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
        // Exit this program.
        private void actionExit() {
            System.exit(0);
        // Add a new download.
        private void actionAdd() {
            URL verifiedUrl = verifyUrl(addTextField.getText());
            if (verifiedUrl != null) {
                tableModel.addDownload(new Download(verifiedUrl));
                addTextField.setText(""); // reset add text field
            } else {
                JOptionPane.showMessageDialog(this,
                        "Invalid Download URL", "Error",
                        JOptionPane.ERROR_MESSAGE);
        // Verify download URL.
        private URL verifyUrl(String url) {
            // Only allow HTTP URLs.
            if (!url.toLowerCase().startsWith("http://"))
                return null;
            // Verify format of URL.
            URL verifiedUrl = null;
            try {
                verifiedUrl = new URL(url);
            } catch (Exception e) {
                return null;
            // Make sure URL specifies a file.
            if (verifiedUrl.getFile().length() < 2)
                return null;
            return verifiedUrl;
        // Called when table row selection changes.
        private void tableSelectionChanged() {
        /* Unregister from receiving notifications
           from the last selected download. */
            if (selectedDownload != null)
                selectedDownload.deleteObserver(DownloadManager.this);
        /* If not in the middle of clearing a download,
           set the selected download and register to
           receive notifications from it. */
            if (!clearing) {
                selectedDownload =
                        tableModel.getDownload(table.getSelectedRow());
                selectedDownload.addObserver(DownloadManager.this);
                updateButtons();
        // Pause the selected download.
        private void actionPause() {
            selectedDownload.pause();
            updateButtons();
        // Resume the selected download.
        private void actionResume() {
            selectedDownload.resume();
            updateButtons();
        // Cancel the selected download.
        private void actionCancel() {
            selectedDownload.cancel();
            updateButtons();
        // Clear the selected download.
        private void actionClear() {
            clearing = true;
            tableModel.clearDownload(table.getSelectedRow());
            clearing = false;
            selectedDownload = null;
            updateButtons();
      /* Update each button's state based off of the
         currently selected download's status. */
        private void updateButtons() {
            if (selectedDownload != null) {
                int status = selectedDownload.getStatus();
                switch (status) {
                    case Download.DOWNLOADING:
                        pauseButton.setEnabled(true);
                        resumeButton.setEnabled(false);
                        cancelButton.setEnabled(true);
                        clearButton.setEnabled(false);
                        break;
                    case Download.PAUSED:
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(true);
                        cancelButton.setEnabled(true);
                        clearButton.setEnabled(false);
                        break;
                    case Download.ERROR:
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(true);
                        cancelButton.setEnabled(false);
                        clearButton.setEnabled(true);
                        break;
                    default: // COMPLETE or CANCELLED
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(false);
                        cancelButton.setEnabled(false);
                        clearButton.setEnabled(true);
            } else {
                // No download is selected in table.
                pauseButton.setEnabled(false);
                resumeButton.setEnabled(false);
                cancelButton.setEnabled(false);
                clearButton.setEnabled(false);
      /* Update is called when a Download notifies its
         observers of any changes. */
        public void update(Observable o, Object arg) {
            // Update buttons if the selected download has changed.
            if (selectedDownload != null && selectedDownload.equals(o))
                updateButtons();
        // Run the Download Manager.
        public static void main(String[] args) {
            DownloadManager manager = new DownloadManager();
            manager.show();
    This example shows how to create a simple download manager in Java. It contains four classes in foru Java source files:
    Download.java: Contains Download class which downloads a file from a URL.
    DownloadManager.java: Contains the main class for download manager application.
    DownloadsTableModel.java: Contains the class which manages the download table's data.
    ProgressRenderer.java: Contains the class which is responsible to render a JProgressBar in a table cell.
    The contents of the listed files are written below.
    /*__Download.java__*/
    import java.io.*;
    import java.net.*;
    import java.util.*;
    // This class downloads a file from a URL.
    class Download extends Observable implements Runnable {
        // Max size of download buffer.
        private static final int MAX_BUFFER_SIZE = 1024;
        // These are the status names.
        public static final String STATUSES[] = {"Downloading",
        "Paused", "Complete", "Cancelled", "Error"};
        // These are the status codes.
        public static final int DOWNLOADING = 0;
        public static final int PAUSED = 1;
        public static final int COMPLETE = 2;
        public static final int CANCELLED = 3;
        public static final int ERROR = 4;
        private URL url; // download URL
        private int size; // size of download in bytes
        private int downloaded; // number of bytes downloaded
        private int status; // current status of download
        // Constructor for Download.
        public Download(URL url) {
            this.url = url;
            size = -1;
            downloaded = 0;
            status = DOWNLOADING;
            // Begin the download.
            download();
        // Get this download's URL.
        public String getUrl() {
            return url.toString();
        // Get this download's size.
        public int getSize() {
            return size;
        // Get this download's progress.
        public float getProgress() {
            return ((float) downloaded / size) * 100;
        // Get this download's status.
        public int getStatus() {
            return status;
        // Pause this download.
        public void pause() {
            status = PAUSED;
            stateChanged();
        // Resume this download.
        public void resume() {
            status = DOWNLOADING;
            stateChanged();
            download();
        // Cancel this download.
        public void cancel() {
            status = CANCELLED;
            stateChanged();
        // Mark this download as having an error.
        private void error() {
            status = ERROR;
            stateChanged();
        // Start or resume downloading.
        private void download() {
            Thread thread = new Thread(this);
            thread.start();
        // Get file name portion of URL.
        private String getFileName(URL url) {
            String fileName = url.getFile();
            return fileName.substring(fileName.lastIndexOf('/') + 1);
        // Download file.
        public void run() {
            RandomAccessFile file = null;
            InputStream stream = null;
            try {
                // Open connection to URL.
                HttpURLConnection connection =
                        (HttpURLConnection) url.openConnection();
                // Specify what portion of file to download.
                connection.setRequestProperty("Range",
                        "bytes=" + downloaded + "-");
                // Connect to server.
                connection.connect();
                // Make sure response code is in the 200 range.
                if (connection.getResponseCode() / 100 != 2) {
                    error();
                // Check for valid content length.
                int contentLength = connection.getContentLength();
                if (contentLength < 1) {
                    error();
          /* Set the size for this download if it
             hasn't been already set. */
                if (size == -1) {
                    size = contentLength;
                    stateChanged();
                // Open file and seek to the end of it.
                file = new RandomAccessFile(getFileName(url), "rw");
                file.seek(downloaded);
                stream = connection.getInputStream();
                while (status == DOWNLOADING) {
            /* Size buffer according to how much of the
               file is left to download. */
                    byte buffer[];
                    if (size - downloaded > MAX_BUFFER_SIZE) {
                        buffer = new byte[MAX_BUFFER_SIZE];
                    } else {
                        buffer = new byte[size - downloaded];
                    // Read from server into buffer.
                    int read = stream.read(buffer);
                    if (read == -1)
                        break;
                    // Write buffer to file.
                    file.write(buffer, 0, read);
                    downloaded += read;
                    stateChanged();
          /* Change status to complete if this point was
             reached because downloading has finished. */
                if (status == DOWNLOADING) {
                    status = COMPLETE;
                    stateChanged();
            } catch (Exception e) {
                error();
            } finally {
                // Close file.
                if (file != null) {
                    try {
                        file.close();
                    } catch (Exception e) {}
                // Close connection to server.
                if (stream != null) {
                    try {
                        stream.close();
                    } catch (Exception e) {}
        // Notify observers that this download's status has changed.
        private void stateChanged() {
            setChanged();
            notifyObservers();
    /*__DownloadTableModel.java__*/
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    // This class manages the download table's data.
    class DownloadsTableModel extends AbstractTableModel
            implements Observer {
        // These are the names for the table's columns.
        private static final String[] columnNames = {"URL", "Size",
        "Progress", "Status"};
        // These are the classes for each column's values.
        private static final Class[] columnClasses = {String.class,
        String.class, JProgressBar.class, String.class};
        // The table's list of downloads.
        private ArrayList downloadList = new ArrayList();
        // Add a new download to the table.
        public void addDownload(Download download) {
            // Register to be notified when the download changes.
            download.addObserver(this);
            downloadList.add(download);
            // Fire table row insertion notification to table.
            fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
        // Get a download for the specified row.
        public Download getDownload(int row) {
            return (Download) downloadList.get(row);
        // Remove a download from the list.
        public void clearDownload(int row) {
            downloadList.remove(row);
            // Fire table row deletion notification to table.
            fireTableRowsDeleted(row, row);
        // Get table's column count.
        public int getColumnCount() {
            return columnNames.length;
        // Get a column's name.
        public String getColumnName(int col) {
            return columnNames[col];
        // Get a column's class.
        public Class getColumnClass(int col) {
            return columnClasses[col];
        // Get table's row count.
        public int getRowCount() {
            return downloadList.size();
        // Get value for a specific row and column combination.
        public Object getValueAt(int row, int col) {
            Download download = (Download) downloadList.get(row);
            switch (col) {
                case 0: // URL
                    return download.getUrl();
                case 1: // Size
                    int size = download.getSize();
                    return (size == -1) ? "" : Integer.toString(size);
                case 2: // Progress
                    return new Float(download.getProgress());
                case 3: // Status
                    return Download.STATUSES[download.getStatus()];
            return "";
      /* Update is called when a Download notifies its
         observers of any changes */
        public void update(Observable o, Object arg) {
            int index = downloadList.indexOf(o);
            // Fire table row update notification to table.
            fireTableRowsUpdated(index, index);
    /*__ProgressRenderer.java__*/
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    // This class renders a JProgressBar in a table cell.
    class ProgressRenderer extends JProgressBar
            implements TableCellRenderer {
        // Constructor for ProgressRenderer.
        public ProgressRenderer(int min, int max) {
            super(min, max);
      /* Returns this JProgressBar as the renderer
         for the given table cell. */
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            // Set JProgressBar's percent complete value.
            setValue((int) ((Float) value).floatValue());
            return this;
    }

    Thank you for the quick reply! But the solution provided by you, it seems, has still not been able to address my issue. I ran the program at command prompt with your said parameters, but the download still gave an error in the App window.
    Also, is there some way of defining these parameters in the source code? I am keen in using NetBeans to run the program.
    Cheers!

  • Set Document Name

    Hi guys
    I'm using VS + C# for my Add-on
    I create my new document by this code:
    Document myDocument = myVisioApplication.Documents.Add("MyTemplateFile.vst");
    and it create new document for me but the default name of this document is Drawing1.vsdx , Drawing2.vsdx , ....
    How can I set another name for that without saving?
    Regards
    Danesh

    You can't, the document name is a read-only attribute, it is set by saving the file.
    Paul Herber, Sandrila Ltd. Engineering and software shapes for Visio
    Sandrila Ltd

Maybe you are looking for

  • Need help with installing Adobe Flash Player

    I saw a message that my Flash player was out of date. I tried to install it, but whenever I opened the downloaded installer, it crashed. I have uninstalled Flash, made sure there was no Flash plug-in in my Library for Internet plug-ins, re-started my

  • What cable to connect ibook 2005 to tv

    I  have a ibook circa 2005 i just want to connect it to a lcd samsung tv, struggling to get lead, the recommended one for post may 2010 ibooks is too small, (Thunderbolt i think) simillar fitting but too narrow.  The recommended one for pre 2009 is c

  • Advise and help pls

    hello illustrators. im trying to achieve the blue symbol going around propotionally around the eclipse with out it having it distort dramaticly,how can i do this?i also would like it so seem mapped on it with the bending as its going around.

  • Query on Bounce Management and tracking the return Mails

    Hi Group, I have a requirement to track the mails ( for Bounced Back mails, Soft bounce, Hard Bounce, and Emails read by the receipient ). I got a table( SOOD ) to get all the Incoming mails from the mail reciepients but, not able to proceed further

  • Connection/Network encryption in Oracle Standard Edition 11gR2

    Does the Oracle 11gR2 Standard Edition support any network encryption for SQL*Plus or JDBC thin clients? I don't have "Oracle Advanced Security" installed, is this required to support any encryption of data send across a network?