Creating dynamic select list - Weblogic

This is a discussion on Creating dynamic select list - Weblogic ; I have a dynamic select list populated by site names and URLs from a map; when a user clicks on an entry the site name and URL will fill two text boxes. There are also buttons to add, update, and ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Creating dynamic select list

  1. Creating dynamic select list

    I have a dynamic select list populated by site names and URLs from a map; when a user clicks on an entry the site name and URL will fill two text boxes. There are also buttons to add, update, and delete entries. These buttons lead to actions within my JPF file.

    When I select an entry to delete, the script runs a delete SQL statement again my Ora db instance, then the page content is repopulated. I want to know how come when I do that I always get the sequence ID of the just deleted entry at the end of my select list.

    Here is a snippet of what I've got:

    JSP:

    [pre]
    dataSource="{actionForm.siteList[0]}"
    optionsDataSource="{actionForm.itemOptions}"
    size="4"
    tagId="siteList">
    ...
    dataSource="{actionForm.title}"
    size="30" maxlength="200" tagId="title"/>
    dataSource="{actionForm.url}"
    size="30" maxlength="200" tagId="url"/>
    tagId="key"/>
    ...

    [/pre]

    JPF:

    [pre]
    Connection conn = null;
    query = "delete from stlnt_other_ref_sites " +

    "where stlnt_ors_site_id = " + form.getKey();
    try {
    pstmt = conn.prepareStatement( query );
    pstmt.executeUpdate();
    } catch (SQLException ex) {
    ...
    }

    try {
    Map map = new LinkedHashMap();
    while ( rs.next() )
    {
    map.put(new Integer(rs.getInt(1)), rs.getString(2));
    jsArray += "siteArray[" + rs.getInt(1)
    + "]=new Array(\"" + rs.getString(2)
    + "\",\"" + rs.getString(3) + "\");";
    hasResults = true;
    }
    options = map;
    getSession().setAttribute("jsArray",jsArray);
    getSession().setAttribute("hasResults",
    String.valueOf(hasResults));
    } catch (SQLException ex) {
    ...
    }
    [/pre]

  2. Re: Creating dynamic select list

    OK I got it working... Mostly... I don't know if it was a combination of changes that made the difference, but I'll put down what I did. First, I switched my select object in the form bean into just a string type from a string array (it was allowing the selection of one entry anyways). Second, rather than just blanking out the options map, I also blanked out the select object [eg form.setSelect("")].

    Now when I select an entry and click delete, the resulting select list is short one visible element. However, you can still select the blank spot where that last entry used to be. However, this is not a huge issue for me now; I will investigate this at a later time.

+ Reply to Thread