I want to use a fileupload that inserts zipfiles and their names in a simple table. For some reason -probably caused behind my keyboard- I don't get it to work.

<fileUpload name="FileUploader" domain="DefaultCLOB" column="CONTENT" dataSource="HC_ZIP_FILE1">

I don't see the data arriving in the table. Most probably I am missing steps in the interaction between the GUI and the database. What are the exact steps that I should take to end with my precious zipfiles in a table, along with their names. The examples don't cover this, or I don't recognize that they do it.

So, essentially I am looking for an example of a CRUD for a simple table that accepts the filename and the filecontents from the upload GUI where the Create is the upload action, the Read the download action. It would also be very nice to be able to filter only certain filesuffixes (in thie case .zip) in the upload GUI element.

asked 18 Feb '13, 11:53

ik_zelf's gravatar image

accept rate: 16%

edited 18 Feb '13, 13:44

Hi Ronald,

Considering the HC_ZIP_FILE table as follows;

create table HC_ZIP_FILE
  id number,
  name varchar2(4000),
  content blob,
  constraint file_pk primary key (id)

And a sequence generating its primary key:

create sequence file_seq
increment by 1
start with 1
minvalue 1
maxvalue 999999999999999999999999999
cache 20

You can define your panel XML as:

      <cell hAlign="Center" childWidth="200">
        <fileUpload name="FileUploader" column="CONTENT" dataSource="HC_ZIP_FILE1">
            <valueChanged action="selectedFileChanged"/>
        <button label="Upload" uploadOnEvent="buttonPress" uploadFrom="mainPanel.FileUploader">
            <buttonPress action="uploadFile"/>

Note that the upload is triggered when the button component labeled "Upload" is pressed (uploadOnEvent="buttonPress" uploadFrom="mainPanel.FileUploader").

When the user changes the selected file from the fileUpload component, it's valueChanged event triggers. In this valueChanged event, you have to create(prepare) a new row in your datasource if it's not created yet. To achieve this, the "selectedFileChanged" action calls the following procedure:

procedure selectedFileChanged is
  v_rowStatus_cd varchar2(255);
  v_row_id       number;
  -- check the status of the current row. 
    v_rowStatus_cd := api_datasource.getRowStatus('HC_ZIP_FILE1');
    when api_exception.e_noCurrentRow then -- there is no current row in the datasource 
      v_rowStatus_cd := null;
  -- if the current row is not a new row, create a new row and set it as current
  if v_rowStatus_cd <> api_datasource.ROW_STATUS_TEMP or v_rowStatus_cd is null then
    v_row_id := api_datasource.createRow('HC_ZIP_FILE1');
    api_datasource.setCurrentRow('HC_ZIP_FILE1', v_row_id);
  end if;

When the user presses "Upload" button the uploaded file, Formspider automatically writes the uploaded file to the CONTENT column of your HC_ZIP_FILE1 datasource. You can use api_component.getUploadedFileName API to retrieve the name of the uploaded file. After setting necessary datasource columns, you can use api_datasource.doCommit API to save your file to the HC_ZIP_FILE table.

procedure uploadFile is
  v_fileName_tx varchar2(4000);
  v_file_id     number;
  -- get the name of the uploaded file
  v_fileName_tx := api_component.getUploadedFileName('mainPanel.FileUploader');
  -- check whether a file is selected or not
  if v_fileName_tx is not null then
    -- if pk column is not set yet, set it
    if api_datasource.getColumnValueNR('HC_ZIP_FILE1.ID') is null then
      select file_seq.nextval into v_file_id from dual;
      api_datasource.setColumnValue('HC_ZIP_FILE1.ID', v_file_id);
    end if; 
    -- set the file name
    api_datasource.setColumnValue('HC_ZIP_FILE1.NAME', v_fileName_tx);
    -- save the uploaded to the table
    api_application.showpopupmessage('Please select a file to upload.');
  end if;

Currently, it's not possible to filter file suffixes in GUI, you can only check it in your action code (on the valueChanged event of the fileUpload component for example).

The download action is not available in version 1.2.1 but it's already implemented in our development environment, it will be available for the next version.

I also created an application named "fileUploadDemo" in your formspideronline account.

Hope this helps,


answered 19 Feb '13, 06:42

Ibrahim%20Sandalli's gravatar image

Ibrahim Sand... ♦♦
accept rate: 25%

yes, this helps a lot. Thanks! :-D

(19 Feb '13, 06:54) ik_zelf
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 18 Feb '13, 11:53

Seen: 1,453 times

Last updated: 19 Feb '13, 06:54

© Copyright Gerger 2017