Create dynamic table

Hi
I am new to Javascript. Anyone has a standard program to create a dynamic table after getting the input from the user. The number of columns would be 2 and the number of rows depend upon the user input. And the number of rows should not exceed 4. I tried some codes from web but does not seem to work for me. Thanks.

Sorry, new to JSP. I tried as follows. My basic idea is get the input from the user and generate table according to that.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD>
    <TITLE>A Colorful and Dynamic Table</TITLE></HEAD>
    <BODY>
        <CENTER>
            <H1>Colorful and Dynamic Table</H1>
            <FORM METHOD=POST>
                <INPUT TYPE=TEXT NAME=WIDTH  VALUE=15 SIZE=2>               
                <INPUT TYPE=SUBMIT VALUE="Do it !">
            </FORM>
            <%  String w = request.getParameter("WIDTH"); %>
            <% out.print(w); %>
            <TABLE>
                <% for(int row=1; row <= w; row++) { %>
                <TR>
                    <%      for(int col=1; col<=2; col++) { %>
                    <TD> (<%=col%>, <%=row%>)
                    </TD>
                    <% } %>
                </TR>
                <% } %>
            </TABLE>         
            <HR>
        </CENTER>
    </BODY>
</HTML>But something wrong. It is giving me some errors. I need to get the info from the user and then generate the table. Is it possible to do it with JSp or I have to use javascript. Thanks.

Similar Messages

  • Error while creating dynamic Table

    Hi All,
    I have a node 'SEG' with 3 attributes, ATTR1.2.3, I am tring to crate dynamic table using this context node. Initialy i am displaying view with button, when click on this button i want to create table dynamically.. if click again one more table i have to create.. its giving dump... here is the code... How to do this???
    data: wd_node_info type ref to if_wd_context_node_info,
            wd_node type ref to if_wd_context_node,
            lr_container type ref to cl_wd_uielement_container,
            lv_tablename type string,
            lt_db_data type ref to data,
            lr_table type ref to cl_wd_table.
      field-symbols: <lt_data> type any table.
      wd_node_info = wd_context->get_node_info( ).
      wd_node = wd_context->get_child_node( name = 'SEG' ).
    lr_container ?= view->get_root_element( ).
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
    " Creating internal table with the same structure as our dynamic
      context node
      CALL METHOD CL_WD_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE
        EXPORTING
          UI_PARENT = lr_container
          TABLE_ID  = 'MY_TABLE'
          NODE      = wd_node
        RECEIVING
          TABLE     = lr_table.
      cl_wd_matrix_data=>new_matrix_data( element = lr_table ).
      lr_table->bind_data_source( path = 'SEG' ).
    Thanks'
    Madhan.

    Hi Sarbjeet,
    The code is working fine, when i use in wddomodify view method without button click on first time.( I checked this by creating another component). But I am creating dynamic table when click on button(view contains one button initially), for this i created two attributes FLAG OF TYPE wdy_boolean and count of type int1. and in button action i write this code :
      DATA lo_el_context TYPE REF TO if_wd_context_element.
        DATA ls_context TYPE wd_this->element_context.
        DATA lv_flag LIKE ls_context-flag.
      get element via lead selection
        lo_el_context = wd_context->get_element( ).
      get single attribute
        lo_el_context->set_attribute(
            name =  `FLAG`
            value = abap_true ).
      DATA lv_count LIKE ls_context-count.
    get element via lead selection
      lo_el_context = wd_context->get_element(  ).
    get single attribute
      lo_el_context->get_attribute(
        EXPORTING
          name =  `COUNT`
        IMPORTING
          value = lv_count ).
    lv_count = lv_count + 1.
    lo_el_context->set_attribute(
        EXPORTING
          name =  `COUNT`
          value = lv_count ).
    and in wddomodify view method following code..
    Method WDDOMODIFYVIEW
    DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_flag LIKE ls_context-flag.
      get element via lead selection
        lo_el_context = wd_context->get_element(  ).
      get single attribute
        lo_el_context->get_attribute(
          EXPORTING
            name =  `FLAG`
          IMPORTING
            value = lv_flag ).
      DATA lv_count LIKE ls_context-count.
    get element via lead selection
      lo_el_context = wd_context->get_element(  ).
    get single attribute
      lo_el_context->get_attribute(
        EXPORTING
          name =  `COUNT`
        IMPORTING
          value = lv_count ).
    if lv_flag = abap_true. ......
    Remaining code same post previously************8
    get element via lead selection
      lo_el_context = wd_context->get_element(  ).
    get single attribute
      lo_el_context->set_attribute(
        EXPORTING
          name =  `FLAG`
          value = abap_false ).
    endif.
    endmethod...
    I created like this i am not getting other UI elements(input, ddbykey,button).
    And if i click view button again it going to dump..
    Thanks,
    Madhan.

  • Create dynamic table using pojo data control

    What are the options we can in order to create dynamic table columns based on pojo data control?
    We have a class A and there are some attributes say A.x, A.y, A.z
    Within class A, we have a collection of class B and has attribute say B.k
    Within class A, we have a collection of class C and has attribute say C.j
    Every instance of class A has same number of instances of class B
    Every instance of class A has same number of instances of class C
    We would like to display a table like this
    A.x, A.y, A.z, [B.k, B.k, ...], [C.j, C.j, ...]
    How should we do that?
    Thanks

    What are the options we can in order to create dynamic table columns based on pojo data control?
    We have a class A and there are some attributes say A.x, A.y, A.z
    Within class A, we have a collection of class B and has attribute say B.k
    Within class A, we have a collection of class C and has attribute say C.j
    Every instance of class A has same number of instances of class B
    Every instance of class A has same number of instances of class C
    We would like to display a table like this
    A.x, A.y, A.z, [B.k, B.k, ...], [C.j, C.j, ...]
    How should we do that?
    Thanks

  • Problem with editable combo box and creating dynamic table values using js

    Hai
    I have used jquery.jec.js to make my dropdown list as editable... I need to create dynamic table values on the onChange event of dropdown using javascript.
    Now am facing the problem in it...
    I am getting duplicate rows in the table... think(assumption) this jquery.jec.js is calling the dropdown again creating duplicate values...
    Please help me out.... Any help is appreciable... Thanks in advance

    Thanks elOpalo, for your valuable response....
    I have found the correct way of doing.
    Before i had my code like this,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('#list').jec();
    function giveAlert(){
         alert('hello');
    </script>
    </head>
    <body>
    <form>
    Combo Box:
    <select id="list" name="list" onChange="giveAlert();">
    <option value="1">one</option>
    <option value="2">two</option>
    </select>
    </form>
    </body>
    </html>
    Now i have changed as the following,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('select.combo').jec();
    $('select.combo')
    .change(function() {
    alert($(this).val());
    }).change();
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td>Combo Box:</td>
    <td><select class="combo"><option value="b">banana</option><option value="a">apple</option></select></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    The problem is with the function i have called on the onChange Event.. Now i have defined it inside the jquery function of dropdown to make it as editable...

  • How to create Dynamic Table Control

    Hi
    How to create Dynamic Table control , The field names and values to be displayed in table control are to be fetched from Add-on Tables.
    Regards
    Prasath

    Hi Jonathan,
    Actually the columns to be displayed are not constant . It will be increased based on the database values, Anyhow it will not exceed 100.
    Please confirm my understanding.
    1. In this case I have to create 100 custom columns and make it visible / invisible based on my requirement and I can set the title at runtime.
    2. How can i assosicate / reassociate the datadictionary reference for the columns that i use. Because I need to show the search help values for the
    dynamic columns.
    Your opinion on this will be helpful.
    Regards
    Prasath

  • CREATE DYNAMIC TABLE ERROR (CACHE PROBLEM ?)

    Hi,
    i have to create dynamic table. The Report is running. But i get Problem by next Programstart. It's showing the Message : This Table is ready exist! Can anyone help me?
    Thanks!
    CLEAR gt_fieldcatalog.
    CLEAR gz_tab.
      lv_index = 1.
      gs_fieldcatalog-tabname = 'test'.
      gs_fieldcatalog-fieldname = 'field_0'.
      gs_fieldcatalog-reptext = 'field_0'.
      gs_fieldcatalog-col_pos = lv_index.
      gs_fieldcatalog-outputlen = 10.
      APPEND gs_fieldcatalog TO gt_fieldcatalog.
      lv_index = 2.
      gs_fieldcatalog-tabname = 'test'.
      gs_fieldcatalog-fieldname = 'TEXT'.
      gs_fieldcatalog-reptext = 'TEXT'.
      gs_fieldcatalog-col_pos = lv_index.
      gs_fieldcatalog-outputlen = 50.
      APPEND gs_fieldcatalog TO gt_fieldcatalog.
      Do 10 times.
        lv_index = lv_index + 1.
         CONCATENATE field '_' lv_index INTO lv_fieldname.
        gs_fieldcatalog-tabname = 'TEST'.
        gs_fieldcatalog-fieldname = lv_fieldname.
        gs_fieldcatalog-reptext = lv_fieldname.
        gs_fieldcatalog-col_pos = lv_index.
        gs_fieldcatalog-outputlen = 10.
        APPEND gs_fieldcatalog TO gt_fieldcatalog.
        CLEAR lv_fieldname.
      ENDDO.
    "Converting the Fieldcatalog for  ALV Grid showing
    LOOP AT gt_fieldcatalog INTO gs_fieldcatalog.
        ls_fcat-col_pos = gs_fieldcatalog-col_pos.
        ls_fcat-fieldname = gs_fieldcatalog-fieldname.
        ls_fcat-seltext_l = gs_fieldcatalog-reptext.
        ls_fcat-tabname = gs_fieldcatalog-tabname.
        ls_fcat-datatype = gs_fieldcatalog-datatype.
        ls_fcat-outputlen = gs_fieldcatalog-outputlen.
        APPEND ls_fcat TO lt_fcat.
      ENDLOOP.
      " Creating internal Table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = gt_fieldcatalog
        IMPORTING
          ep_table                  = gz_tab
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      ASSIGN gz_tab->* TO <ft_tab>.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = ls_variant-report
          it_fieldcat        = lt_fcat
          i_grid_title       = 'Test'
          is_layout          = alv_layout
          i_save             = 'A'
          is_variant         = gx_variant
        TABLES
          t_outtab           = <ft_tab>
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
    CLEAR <ft_tab>.
    UNASSIGN <ft_tab>.
    CLEAR lt_fcat.
    Edited by: Hoang Lam Vu on Aug 25, 2008 11:18 AM

    Hi Maroz,
    I know this is not best practise to post my question in some others,  but i have posted it separately earlier
    Dynamic ITAB from Excel
    I have created a dynamic ITAB from 1 Row of Excel Sheet
    LOOP AT ist_excel INTO w_excel WHERE row = 2. " Contains the Values provided in 2nd row of Excel
        APPEND w_excel TO row1.
      ENDLOOP.
      LOOP AT ist_excel INTO w_excel WHERE row = 3. " Contains the Values provided in 3rd row of Excel
        APPEND w_excel TO row2.
      ENDLOOP.
      LOOP AT ist_excel INTO w_excel WHERE row = 4." Contains the Values provided in 4th row of Excel Etc
        APPEND w_excel TO row3.
      ENDLOOP.
      LOOP AT row1 INTO w_excel.
        CLEAR wa_it_fldcat.
        wa_it_fldcat-fieldname = w_excel-value .
        wa_it_fldcat-datatype = 'C'.
        wa_it_fldcat-inttype = wa_details-type_kind.
        wa_it_fldcat-intlen = 40.
    *  wa_it_fldcat-decimals = wa_details-decimals.
        APPEND wa_it_fldcat TO it_fldcat .
      ENDLOOP.
    * Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = new_table.
      ASSIGN new_table->* TO <dyn_table>.
    * Create dynamic work area and assign to FS
      CREATE DATA new_line LIKE LINE OF <dyn_table>.
      ASSIGN new_line->* TO <dyn_wa>.
    I followed the Link provided by to create a Dynamic ITAB
    Please guide me how to pass these Value from excel to Dynamic Internal Table
    Warm Regards
    Ramchander

  • Create dynamic table in web dynpro abap

    Hi Friends,
    I want to create several tables in a web dynpro. For this reason I have created a View, a group1 and a context node.
    Now I want create a table for each characteristic group from cabn in the ui group1.
    For this reason I want to use create_table_from_node and I have to craete dynamicly attributes in the node.
    Is it the propper way  or is there a different approach.
    So in this case
    1. I read the node
    2. craete attribute for each characteristic group in this node
    3. create a UI Table with create_table_from_node for each attribute
    4. bind the data to the UI Table
    Can I do the same without to craete attributes?
    Thank in advance.
    RG. Jimbob

    Hi Jimbob,
    Have you looked at using the row-repeater UI element? You could then have as many tables as per your characteristic groups.
    Although this would be more difficult if the attributes of each table were to also be only known at run-time. (I'm not sure that this is the case though from your description of the issue.)
    so have a context of the form:
    Context Root
    --->node_characteristic_group (0..n)
    >node_char_group_details(0...n) (non-singleton child node)
    then bind your row repeater to node "node_characteristic_group " and bind the table inside the row repeater to node "node_char_group_details".
    Each time you had a new element in the node_characteristic_group you would get a new table...
    Much easier to support that anything dynamically created.
    Cheers,
    Chris

  • Create Dynamic table name in the select statement.

    I use oracle reports 6i to make myrep.rdf , this report created using certain select query Q1, I created a formula column in this report,
    in the formula column  I write pl/sql block statements to select the data from certain table depends on the output of a column in Q1,
    I want to make the pl/sql block dynamically enough to change the user which I select the data from depends on the connected user
    Ex: if I connected with user = 'KAM14'
    the pl/sql block will be
    select x into v_value from kam13.bil_file where .....;
    and if  I connected with user = 'KAM13'
    the pl/sql block will be
    select x into v_value from kam12.bil_file where .....;
    and so on
    how can I do this in the pl/sql block ...
    Thanks in Advance.

    I am not sure I understood properly, but I think you should create bil_file table under a different user and create synonyms  under KAM1x users.
    Regards

  • How to create dynamic table using POJO based DataControl

    Hi,
    I'm using JDeveloper 11.1.1.5.0. I'm not using ADF BC.
    I've a requirement to display the Dynamic table in my search page.
    In our product we are using POJO based Data controls.
    I created a task-flow and page fragment. I tried to create the dynamic table by drag-drop of searchResults from my Data control, I see the option for Read-Only Dynamic Table, but when I select this option, I don't see anything happening.
    Does the Dynamic Table work with POJO data controls?
    Any inputs would be helpful.
    Thanks
    Ravi

    First U have to crate Extended View Object to your actual View obj.
    Now take Page with Panel  Splitter ,on First facet drag View obj as table and on second Facet Drag Extended View Obj as table.On page loading U have delete all rows from Extended View object.And then u have write bean code on button click to get current select rows from above view objct,and for Filter rows from Second View obj according to selection of rows from first view obj...

  • Creating Dynamic table

    Hi,
    I am uploading one file into my program with structure_name,field_name,field_value and records. Now I want to create a dynamic internal table with the above fields and want to fill the records too.Can anyone tell how to do it?

    Hi,
    Have a look at this sample program to create dynamic internal and passing data to that internal table.
    <pre>
    REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS:
          slis.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
      DO 20 TIMES.
        DO p_colms TIMES.
          l_index = sy-index.
          CONCATENATE 'FIELD' l_index INTO l_fieldname.
          ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
          <l_field> = sy-index.
        ENDDO.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDDO.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
      CLEAR: l_fieldname,
             l_tabname,
             l_fieldtext,
             l_index.
      DO  p_colms TIMES.
        CLEAR l_index.
        l_index = sy-index.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'Field' l_index INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1 </pre>Thanks
    Venkat.O

  • NEED HELP... Creating dynamic table from data file...

    Hi
    I'm writing an application for data visualization. The user can press the "open file" button and a FileChooser window will come up where the user can select any data file. I would like to take that data file and display it as a table with rows and columns. The user needs to be able to select the coliumns to create a graph. I have tried many ways to create a table, but nothing seems to work! Can anyone help me?! I just want to read from the data file and create a spreadsheet type table... I won't know how many rows and columns I'll need in advance, so the table needs to be dynamic!
    If you have ANY tips, I'd REALLY appreciated.....

    Thank you for your help. I tried to use some of the code in the examples... I'm really new at this, so I'm not sure how to set it up. I added the code, but when I open a file, nothing happens. Here's the code I have so far...
    package awt;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.text.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    * @author
    public class Main {
    public static void main(String[] args) {
    JFrame frame = new ScatterPlotApp();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.show();
    class ScatterPlotApp extends JFrame implements ActionListener{
    private JButton openButton, exitButton, scatButton, refreshButton;
    private JMenuBar menuBar;
    private JMenuItem openItem, exitItem;
    private JFileChooser chooser;
    private JMenu fileMenu;
    private JTextPane pane;
    private JTable table;
    private DefaultTableModel model;
    private JScrollPane scrollPane;
    private Container contentPane;
    /** Creates a new instance of ScatterPlotApp */
    public ScatterPlotApp() {
    setTitle("Data Visualizer");
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension d = tk.getScreenSize();
    int width = 867;
    int height = 800;
    setBounds((d.width - width)/2, (d.height - height)/2, width, height);
    contentPane = getContentPane();
    JPanel panel = new JPanel();
    //pane = new JTextPane();
    panel.setLayout(new FlowLayout(FlowLayout.CENTER));
    contentPane.add(panel, BorderLayout.SOUTH);
    //contentPane.add(pane, BorderLayout.NORTH);
    scatButton = new JButton("Create ScatterPlot");
    scatButton.addActionListener(this);
    openButton= new JButton ("Open File");
    openButton.addActionListener(this);
    exitButton = new JButton ("Exit");
    exitButton.addActionListener(this);
    refreshButton = new JButton ("Reload Data");
    refreshButton.addActionListener(this);
    panel.add(openButton);
    panel.add(scatButton);
    panel.add(refreshButton);
    panel.add(exitButton);
    fileMenu = new JMenu("File");
    openItem = fileMenu.add(new JMenuItem ("Open", 'O'));
    openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));
    openItem.addActionListener(this);
    exitItem = fileMenu.add(new JMenuItem ("Exit", 'X'));
    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    exitItem.addActionListener(this);
    JMenuBar menuBar = new JMenuBar();
    fileMenu.setMnemonic('F');
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);
    public void actionPerformed(ActionEvent e){
    Vector columnNames = new Vector();
         Vector data = new Vector();
    try{
    Object source = e.getSource();
    if (source == openButton || e.getActionCommand().equals("Open")){
    chooser = new JFileChooser(".");
    int status =chooser.showOpenDialog(this);
    if (status ==JFileChooser.APPROVE_OPTION)
    File file = chooser.getSelectedFile();
    FileInputStream fin = new FileInputStream(file);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));
    String line;
    //StringBuffer bf = new StringBuffer();
    StringTokenizer st1 = new StringTokenizer(br.readLine(), ";");
                   while( st1.hasMoreTokens() )
                        columnNames.addElement(st1.nextToken());
                   // extract data
                   while ((line = br.readLine()) != null)
                        StringTokenizer st2 = new StringTokenizer(line, ";");
                        Vector row = new Vector();
                        while(st2.hasMoreTokens())
                             row.addElement(st2.nextToken());
                        data.addElement( row );
                   br.close();
    model = new DefaultTableModel(data, columnNames);
              table = new JTable(model);
    scrollPane = new JScrollPane( table );
    getContentPane().add( scrollPane, BorderLayout.NORTH );
    while((line=br.readLine())!=null)
    bf.append(line+"\n");
    pane.setText(bf.toString());
    //pane.setText(bf.toString());
    else if (source == scatButton){
    else if (source == exitButton || e.getActionCommand().equals("Exit")){
    System.exit(0);
    else if (source == refreshButton){
    catch (Exception ex){
    ex.printStackTrace();
    }

  • Procedure for creating dynamic table

    Hi! I'm having a problem with creating a table with the help of procedure. The thing is, I want to pass an (possibly an array of) unknown amount of values - column names, types - to the procedure, that I defined, and then be able to create a (temporary) table with the received data. Possible? Maybe you could give me some hints - any help appreciated.

    899749 wrote:
    Yes, not literally there are million fields, of course :) What I was trying to say -> there are too much fields to create a hidden field array each time, and honestly I don't like this because of content availability through source code.Statement does not make sense.
    If there are too many "fields" (databases have tables and rows and columns - not fields), then how does introducing a new database table reduce these? It is far simpler to only select the rows required, the columns needed for display, and building a "field array" using that - assuming that your definition of such an array matches mine...
    Besides the saneness and logic of using dynamic tables, there are performance considerations. The slowest and most expensive database operation is I/O.
    So what is your justification to spend a lot of I/O on duplicating existing data in the database? Why read data from tables to create so-called dynamic tables? Is that the best spend of database resources?
    Don't know what forms you were talking about - the idea is to possibly use some programming (like php) + html to create a dynamic form. That's why I need a dynamic temporary table to pass the content around (no sessions, please).Forms are typically not dynamic. You do not point code at some arbitrary table structure and say "+form instantiate thyself+". This code will not understand the business rules and validation rules for properly displaying a data entry form for that entity, and applying the rules and logic for processing entered data and storing that in the table.
    Forms are usually (almost always) coded as static - the entry fields are known at design time. The validation rules are known. The business logic to apply is known.
    That begs the question as to not only what you are trying to do (it does not make sense!), but also why? What are the business requirements that need to be met?

  • How to create dynamic tables in jsp page

    Hi,
    Iwant to create a table with 8 rows.each row will have two select boxes and one text box.besides i have add button.intially the screen shows only one row.if user clicks on add button then another row is added.like this upto 8 rows.
    how can solve this problem..
    regards,

    Hi I am not a big programmer but i can suggest a method to u
    try something like this..
    this could be quite adjusted in html page itself.....
    <html>
    <head>
    <script language="javascript">
    var count=1
    fucntion addRow(){
    if(count<8){
    count=count+1
    row.innerHTML=row.innerHTML+"<tr><td><input type='text' name="+count+"></td><td><input type='button' onclick=addRow() value='Add' name='add'></td></tr>"
    else if(count==8){
    row.innerHTML=row.innerHTML+"<tr><td><input type='text' name="+count+"></td><td></td></tr>"
    </script >
    </head>
    <body>
    <form action='Myservlet" method='post'>
    <table>
    <div name='row' name='row'><tr><td><input type='text' name=1></td><td><input type='button' onclick=addRow() value='Add' name='add'></td></tr></div>
    </table>
    </form>
    </body>
    </html>
    I believe it could be quite adjusted @ client side itself.... as per your description...

  • Create dynamic table at runtime and bind it with ViewObject

    Hi everyone.
    I have the following task.
    I need to create a multiple ViewObjects at runtime (using different constructed sql queries) and then bind ViewObjects with created (also in runtime) tables.
    Tables are to be created on PanelTabbed component. Each tab contains one table.
    So the problem - is there a way to perform this task?
    A portion of code:
    ApplicationModule am = ADFUtils.getApplicationModule("AppModule");
    ViewObjectImpl vo = null;
    if (am.findViewObject("SQLVo") != null)
    am.findViewObject("SQLVo").remove();
    System.out.println("object removed!");
    vo = am.createViewObjectFromQueryStmt("vo", "select ...");
    RichTable newTable = new RichTable();
    newTable.setVar("row");
    newTable.setVarStatus("rowStat");
    RichShowDetailItem newDetItem = new RichShowDetailItem();
    newDetItem.setText("New Detail");
    newTable.setInlineStyle("width:100%;height:180px");
    newTable.setRowSelection("single");
    DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    String iterBindingName = vo.getName() + "Iterator";
    JUIteratorBinding iterBinding =
    (JUIteratorBinding)dcBindings.findIteratorBinding(iterBindingName);
    if (iterBinding != null) {
    dcBindings.removeIteratorBinding(iterBindingName);
    BindingContext bcc = (BindingContext)JSFUtils.resolveExpression("#{data}");
    iterBinding =
    new JUIteratorBinding(bcc.findDataControl("AppModuleDataControl"), vo);
    String ctrlBindingName = vo.getName() + "Binding";
    FacesCtrlHierBinding clonedHierBinding =
    (FacesCtrlHierBinding)dcBindings.findCtrlBinding(ctrlBindingName);
    if (clonedHierBinding != null) {
    dcBindings.removeControlBinding(ctrlBindingName);
    =======================================
    Please, look here!
    What's the best practices to create a new FacesCtrlHierBinding?
    What a parameter _nodeBindings (type JUCtrlHierTypeBinding[]) should be?
    =======================================
    clonedHierBinding =
    new FacesCtrlHierBinding(null,
    iterBinding,
    new String[]{
    "BUILDING_ID"
    // "BUILD_NAME",
    // "FUNCTIONALITY_NAME",
    // "CITY_NAME",
    // "STREET_NAME",
    // "FLOORS"
    _nodeBindings
    dcBindings.addControlBinding(ctrlBindingName, clonedHierBinding);
    newTable.setValue(clonedHierBinding.getCollectionModel());
    for (int g=0; g < vo.getAttributeCount(); g++){
    RichColumn col = new RichColumn();
    col.setId("c" + Integer.toString(g));
    col.setHeaderText(vo.getAttributeDef(g).getProperty(AttributeHints.ATTRIBUTE_LABEL).toString());
    ValueExpression valExp =
    facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(),
    "#{row." + vo.getAttributeDef(g).getName() + "}",String.class);
    RichOutputText text = new RichOutputText();
    text.setId(vo.getAttributeDef(g).getName() + "txt");
    text.setValueExpression("value", valExp);
    col.getChildren().add(text);
    newTable.getChildren().add(col);
    newDetItem.getChildren().add(newTable);
    myBean.panelTabbed.getChildren().add(newDetItem);
    ...

    Shay, good day!
    You answer is good, but - it use only one dynamic view (and one table, iterator and FacesModel).
    I have task like topic started have - i need to create some unknows numbers of ViewObject (created by demad) and i must have a FacesModel for each created ViewObject.
    How can we do it?

  • Creating dynamic table in livecycle pdf through coldfusion cfpdf.

    Hi,
    I have a pdf created in Livecycle, i am able to populate data in it with coldfusions cfpdf. but fields in pdf are static, means i will have to pass every field vale and coldfusion will populate it.
    But I have a Table in PDF i want it to be dynamic, so I i pass 5 rows it will populate table with 5 rows. right now every thing in pdf is fixed on place, but i want it dynamic.
    Hope i am able to explain it correctly, Please help and let me know if this is confusion. I will try to explain my problem correctly.
    Thanks

    Have you tried creating the data connection via LCD
    and not CF? You can write the same queries in LCD and connect to your tables. If you want dynamic pdfs in CF, I would use the <cfdocument> tag.

Maybe you are looking for