Select list in JSP (Options from database)

I am developing a web application on struts.
I am having problem with my JSP.
I have a form from where users input the keywords for search
and when they click on a database query is performed and
result is shown on the screen.
Where i am stuck is that in the display screen, i wanna have one
set of result in the drop down list (same as select in html).
If the result from the database search is 1 i want the first option of
select to be Yes and if its 0 then i want the first option of select to be
No.
what i have in JSP is following
<select name="attt" size="2"><option value="<bean:write name="sList" property="att"/>">Yes
<option value="<bean:write name="sList" property="att"/>">No
Where I am stuck is that I dont know where to perform whether the
result from database is 1 or not. Can someboday help me on how
to solve this or get this done? Am i right so far?
thanx in advance

The best I could come up with was to use the second layout I mention and then add some Javascript on the page to do something like
<style type="text/css">
label.l {position:absolute;top:100px;left:210px;}
input.i {position:absolute;top:100px;left:200px;}
</style>
<script type="text/javascript">
var f=$x('P1_RADIO');
var l=f.getElementsByTagName('label')[1];
var i=f.getElementsByTagName('input')[1];
l.className += "l";
i.className += "i";
</script>Basically, it takes that "Radiogroup Option 2" and the form input field and uses absolute CSS positioning to place it to the right of the Select list.
Works great in FF (as usual), but the usual IE inconsistencies with CSS box model rear their ugly head. Looks terrible in IE, totally mis-aligned.
Any other ideas?
Thanks

Similar Messages

  • Select list in radiogroup options

    Is there any way to achieve the following layout
    o Radiogroup Option 1 [Select List] o Radiogroup Option 2Yes, I can easily do
    o Radiogroup Option 1 [Select List]
    o Radiogroup Option 2which is close enough, but just wondering if the other one was possible.
    Thanks

    The best I could come up with was to use the second layout I mention and then add some Javascript on the page to do something like
    <style type="text/css">
    label.l {position:absolute;top:100px;left:210px;}
    input.i {position:absolute;top:100px;left:200px;}
    </style>
    <script type="text/javascript">
    var f=$x('P1_RADIO');
    var l=f.getElementsByTagName('label')[1];
    var i=f.getElementsByTagName('input')[1];
    l.className += "l";
    i.className += "i";
    </script>Basically, it takes that "Radiogroup Option 2" and the form input field and uses absolute CSS positioning to place it to the right of the Select list.
    Works great in FF (as usual), but the usual IE inconsistencies with CSS box model rear their ugly head. Looks terrible in IE, totally mis-aligned.
    Any other ideas?
    Thanks

  • To get list of suspended responses from database

    Hi All,
    we have O2A PIP installed with below versions:
    Oracle AIA     11.1.1.5
    Oracle WebLogic    10.3.5
    SOA Suite    11.1.1.5
    O2C PIP        11.1.1.1
    In Production some of the orders are failing because of Siebel internal error and hence those responses are also erroring out in AIA.
    Now as per the resequencing logic all subsequent responses for that account is going into suspended state so that only when the faulted response was recovered successfully, the subsequent response will flow.
    The issue we have here is, whenever any new order is coming bearing same Account no. for which the response of some order has failed, the responses of new orders are also going into suspended state. now all suspended responses we can only see that in mediator_instance table, one row is getting added with same group_id of that account. leaving us with no option to identify if this response is for new order or same order which has faulted.
    we can identify all the responses which has faulted by combining mediator_instance and composite_instance table as instance of updateSalesOrderSiebelComsProvABCSImpl gets created for the response which has failed.
    but we need the list of all new orders and its group_id which is going into suspended state because of some other order's faulted response.
    Please let us know if there is any way to get this list from database.
    Thanks & Regards,
    Vivek

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JSP - ImageLoader from Database (BalusC code)

    ImageServlet
    Firstly @ BalusC amazing code thanx
    I have been playing with the ImageServlet and Wow.
    It works perfectly
    Here is my problem:
    I want to load the image from my SQL Server 2000 database
    but when I load the image it doesn't display and no errors occur
    public class SQLImage{
      Connection conn = null;
      public SQLImage(){
        //init();
      public byte[] getImage(String name){
        try{
          PreparedStatement prepStat = conn.prepareStatement("SELECT [DATA] FROM [IMAGE_TABLE] WHERE [NAME] = '" + name + "'");
          ResultSet rs = prepStat.executeQuery();
          byte[] bytes = null;
          if(rs.hasNext())
            bytes = rs.getBytes(1);
          return bytes;
        }catch(Exception ex){
          ex.printStackTrace();
          return null;
      } The only thing I have changed on the ImageServlet is:
    FROM
    BufferedInputStream input = null;
    BufferedOutputStream output = null;
            try {
                // Open image file.
                input = new BufferedInputStream(new FileInputStream(imageFile)); TO
    BufferedInputStream input = null;
    BufferedOutputStream output = null;
    SQLImage sqlImage = new SQLImage();
            try {
                // Open image file.
                byte[] data = sqlImage.getImage(imageFileName);
                if(data == null){
                  JOptionPane.showMessageDialog(null,"Null Value");
                  return;
                input = new BufferedInputStream(new ByteArrayInputStream(data)); The Dialog is never displayed so that means that data contains a value
    I take it the image data in the DB is the same as the image file
    can anyone tell me what has changed and why it doesn't work?

    DM_Is_SM
    You know me to well,
    I found the problem as suggested
            if (!imageFile.exists()) {
                // Do your thing if the file appears to be non-existing.
                // Throw an exception, or show default/warning image, or just ignore it.
                return;
            } as the file was located on the DB it will always return;.
    I removed all the unnecessary code from ImageServlet
    And this is the working code I am left with for ImageServlet
    package mypackage;
    import DataBase.SQL.SQLImage;
    import java.io.ByteArrayInputStream;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.Closeable;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.URLConnection;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * The Image servlet for retrieving image from Database
    * @author BalusC - original
    * @author gtRpr - Edited
    * @link Orig - http://balusc.blogspot.com/2007/04/imageservlet.html
    * @link Edit - http://forum.java.sun.com/thread.jspa?messageID=10340335
    public class ImageServlet extends HttpServlet {
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
        String imageFileName = request.getParameter("file");
        Validate:
          imageFileName = imageFileName.replaceAll("'","<Apos">);
    //    replace all ' chars with <Apos> when image is added to DB
    //    and when retrieved from DB
    //    Helps prevent SQL injection
    //    EG:
    //    "image?id=';TRUNCATE TABLE Image--"
    //    Becomes
    //    "image?id=<Apos>;TRUNCATE TABLE Image--"
        // Prepare streams.
        SQLImage sqlImage = new SQLImage();
        BufferedInputStream input = null;
        BufferedOutputStream output = null;
        try {
          // Open image file.
          input = new BufferedInputStream(new ByteArrayInputStream(sqlImage.ReadImage(imageFileName)));
          int contentLength = input.available();
          // Init servlet response.
          response.reset();
          response.setContentLength(contentLength);
          response.setHeader("Content-disposition", "inline; filename=\"" + imageFileName + "\"");
          output = new BufferedOutputStream(response.getOutputStream());
          // Write file contents to response.
          int data;
          while ((data = input.read()) != -1) {
            output.write(data);
          // Finalize task.
          output.flush();
        } catch (IOException e) {
          // Something went wrong?
          response.sendredirect("Error.jsp";);
        } finally {
          // Gently close streams.
          output.close();
          input.close();
    }

  • Populate List of AutoSuggest Item from Database

    Hi,
    I am working in JDeveloper 11.1.2.1.0 IDE and developing an ADF Application.I just want to know how to populate the list of AutoSuggest Item from a database.
    Please reply.
    Thanks.

    hi user,
    nothing to do with you thread.
    why are you cross posting here also.
    duplicate:
    Populate List of AutoSuggest Item from Database

  • List/menu options from database

    Hello
    I need help trying to populate 2 list/menu with some database information.
    Let's suppose that this is my table:
    Id
    Brand
    Model
    1
    ford
    f1
    2
    citroen
    c1
    3
    citroen
    c2
    4
    citroen
    c3
    5
    toyota
    t1
    6
    toyota
    t2
    7
    volvo
    v1
    I have 2 list/menu. One is  the brand menu, which extracts the values  in the brand column of the database (using the DISTINCT statement in MySql). So when you click the menu, these options appear:
    ford
    citroen
    toyota
    volvo
    The  code for that menu is something like  this:
    <select name="menu_marque" id="menu_marque">
    <option value="null">select</option>
    <?php do {  ?>
    <?php
    print '<option  value="'.$row_marque_recordset['marque'].'">'.$row_marque_recordset['marque'].'</option>' ;
    ?>
    <?php } while ($row_marque_recordset =  mysql_fetch_assoc($marque_recordset)); ?>
    </select>
    Now,  I want to do the same for the model menu.  The problem is that I don't know how to write in the Sql, that it  should take the selected value of the brand menu.  I have something like this:
    SELECT modele FROM test WHERE marque  = 'colname' ORDER BY modele ASC
    (where colname is:  $_POST['menu_marque']..... Obviously I am not getting the value by a  POST method, but I tried changing it to something like:
    menu_marque.selectedIndex
    but  it doesn't work...... Any tips on how can I solve this

    Hi DanielAtwood,
    Thanks for your reply...
    Actually when i send the variable in 'WHERE Clause' in Db Adapter query it will retrieve more than one record as the output.
    I want to put that values to a 'SelectOneChoice' component and list down all the values..
    First I tried with data control. But i couldn't find the way to pass the value to the variable(in WHERE clause) to the query in data control view.
    Thanks,
    Nir

  • Selecting all user's (scheme) from Database

    Hi,
    I'm trying show all user from my database using this command:
    select username from dba_users;
    It work.. but I'd like see just my user's and not system user like Sys.. System etc.
    Could anyone help me ?
    Yours
    Fernando.

    hum..
    I mean... user like thoses...
    In my Select apear also
    OUTLN
    DBSNMP
    TRACESVR
    PERFSTAT
    To me.. theses are "strange" users. I'd like see just the users that I create...
    do u understand me ?
    I belive exist one field in.. some table to filtre them..
    anyways..
    Thank you by your help.
    Yours
    Fernando.

  • Sample JSP code needed with jdbc select lists

    Hello java experts!
    I need to create a series a jsp pages that connects to an ms access "books" database. This first page should connect to the books.mdb and populate select lists with the values from the database. The solution would be similar to the the books shopping cart in the CoreServlets book, EXCEPT I must do everything in JSP only.
    All I have done to this point is Java servlets. (I've done shopping cart stud in ASP.net, but not JSP).
    I know everyone hates to post code samples, but seeing the code will help me understand. I've read the API, the tutorials, 3 textbooks, and any other doc I could find. I understand Java beans and jsp, but I need to see the JSP for this to finally crystalize.
    Thanks in advance.
    -JavaGirl

    what school is teaching db access from jsp?

  • Select List Defaults -- w/ Database Column

    I've checked the forums, but I'm still stuck on this.
    So I have a form that keeps track of meetings and contains a select list item of persons who could have organized the meeting. This select list is linked to a database column. I would like this to default to the logged-in-user when a new meeting is created.
    Unfortunately, whatever I try (defaults, computations, etc.), I cannot seem to be able to change the selected name. If source is set to database column and always use source, will it override and prior attempts to change the value of the select list?

    Wahhhh.....okay, it took me two days to come up with a solution to this. Marc, that was exactly the way I thought it should be. I had as the default attribute a PL/SQL function body that looked like:
    select person_id into :P27_LEAD_ID from person where username = :APP_USER;
    But that never worked. I still have no idea why. Anyway, I ended up using in SQL query to fill a hidden box and then referenced the box in the default using:
    &P27_LEAD_DEFAULT.
    Even leaving it as a PL/SQL expression and referencing it as :P27_LEAD_DEFAULT didn't work. =/
    Thanks for your help,
    Jonathan

  • Select option in select list and navigate to different page

    Hello,
    I have a tabular form.One of the item is a select list with 2 options. Selecting option one should take the user to page10(just an example) and display all the values of that particular row. Similarly selecting option 2 should take the user to page 20 and display all the values of that row.
    Can some one guide me how to do above mentioned job.
    Thanks in advance.
    Pravish

    @Avinash
      if f_cat-seltext_m = 'Select'.
        f_cat-col_pos = 1.
        f_cat-seltext_l = 'EDIT'.
        f_cat-Checkbox = 'X'.
        f_cat-EDIT = 'X'.
      endif.
    I am already passing f_cat-checkbox = 'X'.
    Thanks
    Kumar.

  • Select list defaulting to first value

    APEX Version: 4.1.1.00.23
    Oracle Database: 11g
    Issue: The application is updating the selected value from the Select list (Y/N) to the database but in front end, the select list is defaulted to display only the first value in the list. What I find is the datatype of the field in the table that this select list is tied to is CHAR(2). And upon changing it to VARCHAR2(2), it worked fine. Now whichever option I choose from the select list is updated and displayed at front as well.
    I do not understand why is this messing up with CHAR(2). Anyone please explain, I would really appreciate that.
    Thanks,
    Samip

    never use CHAR() in your tables.
    CHAR will always pad your strings to the exact same length.
    In your case, you are comparing the table value of 'Y ' to the List value of 'Y'.
    declare
      a  char(2) := 'Y';
      b varchar2(2) := 'Y';
    begin
      dbms_output.put_line('variable A has length of ' || length( a ) ); -- this will ALWAYS have a length of 2
      dbms_output.put_line('variable A has length of ' || length( b ) );
    end;

  • Dynamic Action based on Interactive Report Select List Value

    I'd like to perform a Dynamic Action when a user selects one of 3 options from a Select List within an Interactive Report:
    select APEX_ITEM.SELECT_LIST(
    p_idx => 3,
    --p_value         =>   deptno,
    p_list_values => 'Copy;Copy,Delete;Delete,Export to PDF;Export to PDF',
    --p_attributes    =>   'style="color:red;"',
    p_show_null => 'YES',
    p_null_value => NULL,
    p_null_text => '--Select--',
    --p_item_id       =>   'f03_#ROWNUM#',
    p_item_id => 'P6_IR_SELECT_LIST',
    p_item_label => 'Label for f03_#ROWNUM#',
    p_show_extra => 'YES') "Actions"
    from dual;
    When building the Dynamic Action, I chose the following values from the Advanced wizard
    Event: Select
    Selection Type: DOM Object
    DOM Object: P6_IR_SELECT_LIST
    Condition: Equal to
    Value: "Delete"
    True Action: Execute Javascript Code: Alert('Here');
    Doesn't seem to be firing...can anyone help?
    Thanks in advance,
    John

    Hi,
    I am not sure if the "equal to" condition applies to a DOM object... after all, a DOM object can be anything (any HTML element) not only a field.
    Try using a javascript expression instead, like this:
    $v('P6_IR_SELECT_LIST')=='Delete'UPDATE: Sorry, I just tested and "equal to" condition works for DOM objects... should have tested before posting!
    Luis
    Edited by: Luis Cabral on Feb 29, 2012 4:45 PM

  • How to display data from Database individually??? Anyone can help ?

    HI,
    i i had select a row of data from database using ,
    /* Query * From Table RESOURCEORDER where po = selected no and project = selected project */
         public ResultSet getAllData() throws SQLException
         getConnection();
         Statement stmt = conn.createStatement();
         ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
         return rs;
    After that , how do i display the data individually ?
    Eg select data is ('projectA','7891203-1', '10-4-2005','lcd',2000,'121-45217-8','electrical','pending','donwong')
    i want to display them individually, like this in a page
    Projectname: /* should display the Project A*/
    P.O no:
    Date:
    Order:
    Cost:
    Acc no:
    Type:
    status:
    Orderedby:
    Can anyone help ? cos i'm new to JSP ......Thanks alot!!!!!
    Regards,
    khim

    I assume PO being a unique key, will always return 1 row from db.
    public String[] getAllData() throws Exception
    getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
    String [] returnValue = new String[9];
    while(rs.next())
    returnValue[1] = rs.getString("colname");
    returnValue[2] = rs.getString("colname");
    ///and so on
    return returnValue;
    }Once you get that you could individually view it by setting a loop to run through the returned array.
    Hope it helps

  • Dynamic select list as APEX plug-in custom attribute?

    I'm developing a region plug-in in APEX 4.0.1. I wanted to make one of the custom attributes a select list where the options offered were the current application list templates (queried from the <tt>apex_application_temp_list</tt> view: the rendered plug-in region should be styled using a standard list template from the current theme). However, the Select List plug-in custom attribute type only appears to support static lists. Can anyone confirm that I've not missed anything and that this is indeed the case?
    If so, it seems that the plug-in will have to rely on developers typing a list template name into a text box, which is far from ideal. (Unless anyone can suggest a workaround?)
    Component specific templates can be applied to several built-in component types&mdash;lists, calendars, reports&mdash;so it would make sense for there to be a similar capability for plug-ins where these are congruent with an existing template type, e.g. by providing a Template Picker plug-in custom attribute type.

    Hi,
    you have not missed anything. Plug-in attributes of type "Select List" just support static values. And I'm not sure if a query based Select List would really help, because what happens if the template is deleted. Or in the reports where it shows if the template is in use.
    So I think your second approach to extend plug-in attributes to link to certain shared components (Lists, Templates) is the better way forward, because that will also allow us to know what you are actually referencing and we can use that information in reports, delete operations, ...
    Will add it to possible enhancements for 4.1
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Select list pagination not working for big tables

    Hi,
    i am trying to view a table with large amount of data using tabular form. the pagination using select list is not working in this page. i have selected select list kind of pagination but it is showing "row range 1-15 16-30(with set pagination)' type of pagination. when i lowered the amount of data in the table the pagination type will automatically change to select list pagination. could you please tell me why this happens and any possible work around if any.
    Thanks,
    Jo

    Hi Jo,
    I don't know what you call a large amount of records, but the effect you describe might be intentional by apex.
    The select list pagination would generate a selection tag with (number of records in table/15) options in your page HTML.
    Although there isn't a hard limit to the number of options a select list can have there certainly is a limit to what your browser/pc can render.
    Think about it
    Let's say you table contains a million rows. this would result to a select list with 66666 options. Which your browser won't handle :)
    I very possible the apex team resolved this by simply reverting to row range pagination when the number of select options would grow to large.
    Geert

Maybe you are looking for

  • Yet another Nano 6th Gen with power button failure

    When is apple going to put its hand up and admit there is a problem with the 6th Gen Nano. My daughters 13 month old 16gig  ipod has a power button failure the same as so many others. At £120 odd its already an expensive bit of kit without having to

  • Export to Clip Notes

    Hi When I try to export to clip notes After Effects freezes and trying to select anything gives me the 'ping' noise.  The only way out of this is then to close the program down from the windows task list. Anything????? thanks

  • HTTP Send

    I'm trying to send a SOAP message from XI via HTTP adapter to an external web services client URL and I get an 'HTTP_TIMEOUT' message. The trace says 'HTTP-Client: exception during receive: HTTP_COMMUNICATION_FAILURE'. I can take the message and send

  • Why do I have two degree marks in Notification Center?

    When I open Notification Center I always see two degree marks and it is like: Temperature: 8°°C, maximum: 7°°C. Where is the problem and what should I do?

  • Shuts down almost inmediately after login in

    My MBP shuts down almost inmediately after entering my password, while it is loading. How can I enter in safe mode?