Populating Database values into a combo box in STRUTS Framework

Hi Guys,
I am currently working on a STRUTS Framework project and I can't get much resources related to the problems that I'm facing.
Currently I need to populate a JSP file's Combo box with database values. What I don't know here is the syntax used to in STRUTS framework to populate the Combo box with database values. Anyone with experience related to this topic, please kindly help me out.

Struts doesn't define anything about the datab layer. You're free to implement how you will.
Struts instead guides you into following an MVC pattern.
You populate a combo box with values from a bean.
So you need to set up a bean for this page to talk to.
That bean can be populated from the database - but at that point you're in java/jdbc code - and away from the struts layer.
My suggestions
1 - Define a bean to represent the information from the database.
2 - write a method that queries the database, and copies the data into a List of those beans. This will be your Data access layer.
3 - in your action, call that method, and then set the list of beans as a request attribute. Or maybe as a property on a form.
4 - use that list of beans to populate your dropdown box.

Similar Messages

  • How to populate values from database into a Combo Box?

    Hi,
    How to display all the values of a field of a database table in a combo box inside a grid in B1 user defined form?
    Regards,
    Sudeshna.

    Hi,
    If you are trying to do this on a system form (I gues this is your case, reading the other question), for example Sales Orders, and you want to show the values from a User Defined Table (UDT), you just need to add a User Defined Field on Marketing Documents Line level, and say it is linked to the UDT.
    SBO will automatically show the combo with the values on the Code field of the UDT.
    Regards,
    Ibai Peña
    Sorry, I didn´t read the post well.
    What you could do is each time the form is loaded, read the values from the table, and asign them as Valid Values for the combobox column. You can do this programatically, or using XML (which is recommended becouse of better performance).
    Message was edited by: Ibai Peña

  • How to fetch records from the database into a combo box?

    Hi:
    I´m really new with ABLBPM and I´m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I´m using a dynamic method with this code:
    <em>for each row in SELECT campo1, campo2 from TABLE</em>
    <em>do</em>
    <em>solicitudes[] = [row.campo1, row.campo2]</em>
    <em>end</em>
    <em>return solicitudes
    </em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
    Do you know another way to do it?
    P.D. Sorry for my terrible english
    Greetings

    Hi Steve,
    Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
    fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
    Motivo: 'java.lang.NullPointerException'.
         at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
         at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
         at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
         at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
         at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
         at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    Any ideas??
    Thanks and greetings

  • How can i display the value fetched from my database back onto my combo box

    i have saved a selected value from my combo box in my database.
    i want to display the same value on my combo box to the user on a jsp page.
    Can someone help me?

    <%
    String valueInYourDatabase="2";
    String[] valuesToDisplay={"1","2","3"};
    %>
    <SELECT name="square_root_of_for">
    <% for(int i=0;i<valuesToDisplay.lngth;i++){
    String s=valuesToDisplay;
    %>
    <OPTION value="<%=s%>" <%=(s.equals(valueInYourDatabase)?"SELECTED":"")%> ><%=s%></OPTION>
    <%}%>
    </SELECT>
    Something like this...
    didn't compile it so their are surely errors ;)
    regards
    Alban

  • Retriving data from database on selecting particular value in the combo box

    Hi,
    On selecting the particular value from the combo box, the corresponding value of the other segement fields should be retrived from databse and displayed in the text box

    Babel,
    If you don't have a query bdoc and the business query that joins both 2 tables already, then please crate one.
    After that, write this code on the change of the combobox.
    You would have to change the names below for the Query, properties, anchor, parameters, controls.
    ===================================
    Private Sub ctrlBankNameCombo_onValueChanged2(ByRef boundAttributeChanged As Boolean)
    On Error Resume Next
    Dim objBankQuery As BusinessQuery
    Dim ObjBankCol As BusinessCollection
    Dim strID As String
    If Not boundAttributeChanged Then Exit Sub
    strID = ""
    strID = myanchor.bo.getAttribute("BankNameComboProperty") ' Bank ID
    If strID <> "" Then
        Set objBankQuery = gServices.factory.newBusinessQuery("MyNewQuery")
        objBankQuery.Mandt = "000"
        objBankQuery.BANKID = strID
        Set ObjBankCol = objBankQuery.query 
           If Not ObjBankCol Is Nothing Then  
               ctrlBankAddress.Value = ObjBankCol.getAttribute(1, "BankAddress")
               ctrlBankPhone.Value = ObjBankCol.getAttribute(1, "BankPhone")
           End If
    End If
    ===================================
    Regards,
    Vadim.

  • How to get the current selected value of a combo box or a option button?

    Hello All,
    I want to catch the current selected value of a combo box and also of a option button and want save it into different variables in my code. These option button and combo box are in a SAP business one form which I have created through VB dot.net coding.
    But I don't know how to do that, can any one send any example code for this.
    Regards,
    Sudeshna.

    Hi Sudesha,
    If you want to get the selected values you can do it as follows: The Combo Box value you can get from the combo box. If you want to get it on the change event, you must make sure that you check when BeforeAction = False. If you want to get an Option Button value you should check the value in the data source attached to the option button.
            Dim oForm As SAPbouiCOM.Form
            Dim oCombo As SAPbouiCOM.ComboBox
            Dim oData As SAPbouiCOM.UserDataSource
            oForm = oApplication.Forms.Item("MyForm")
            oCombo = oForm.Items.Item("myComboUID")
            oApplication.MessageBox(oCombo.Selected.Value)
            oData = oForm.DataSources.UserDataSources.Item("MyDataSourceName")
            oApplication.MessageBox(oData.ValueEx)
    Hope it helps,
    Adele

  • Problem in Showing multiple values into one text box.

    Hi all,
    How can show i multiple row values into one text box. here text box is multi line type.
    i have one table it has content column, it has number of rows. i need to show those data into one text box in form. how can i solve it?
    my sample code here,
    egin
    --:block3.txt_to := :parameter.p_current_user||''||':'||:block3.txt_From;
    -- go_item('txt_from');
    insert into chat(fromid,toid,content)values(:block3.fromid,:block3.toid,:block3.txt_From);
    :block3.txt_From:= null;
    commit;
    :block3.txt_to := :parameter.p_current_user||''||':'||:block3.txt_From;
    go_item('txt_from');
    declare
    cursor c4 is select content from chat where toid = :block3.fromid;
    rec1 c4%rowtype;
    begin
    open c4;
    loop
    fetch c4 into rec1;
    exit when c4%notfound;
    null;
    end loop;
    end;
    --select content into :block3.txt_to from chat where toid= :block3.fromid;
    end;
    please give me some tips to solve it.
    thanks
    gurus

    Hi,
    Try giving CHR(10) for line feed.
    DECLARE
         CURSOR C4 IS SELECT CONTENT FROM CHAT WHERE TOID = :BLOCK3.FROMID;
         Str_Temp VARCHAR2(20);
    BEGIN
         :BLOCK3.TXT_TO := '';
         OPEN C4;
         LOOP
              FETCH C4 INTO Str_Temp;
              EXIT WHEN C4%NOTFOUND;
              :BLOCK3.TXT_TO := :BLOCK3.TXT_TO || CHR(10) || Str_Temp;
         END LOOP;
         CLOSE C4;
    END;Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • Please help with: A date split into 3 Combo Boxes ....

    Can someone help me with this Please?
    I have a date for a Date of Birth i.e. dd/MM/yyyy
    I need to split it up an place it into 3 combo boxes i.e. Day Combo, Month Combo and Year Combo.
    This is the code I have to set the combo boxes, now I need to bring it back into the combo boxes.
    can someone help me with the code as I need to have this finish on friday and I am running out of time. I just dont know what to do PLEASE SOMEONE HELP...
    Thanks
    Craig
    // List days
      private void DayOfTheMonth(int highNumber,JComboBox comboBox){
        comboBox.addItem(" ");
        for (int index = 1; index < highNumber; index++) {
          comboBox.addItem(String.valueOf(index));
      private void DaySpecificComboBox()
        DayOfTheMonth( 32, DayjComboBox);
    // List Months
      private void Month(){
        MonthjComboBox.addItem("");
        MonthjComboBox.addItem("January");
        MonthjComboBox.addItem("February");
        MonthjComboBox.addItem("March");
        MonthjComboBox.addItem("April");
        MonthjComboBox.addItem("May");
        MonthjComboBox.addItem("June");
        MonthjComboBox.addItem("July");
        MonthjComboBox.addItem("August");
        MonthjComboBox.addItem("September");
        MonthjComboBox.addItem("October");
        MonthjComboBox.addItem("November");
        MonthjComboBox.addItem("December");
    //List Years
      private void Year(int highNumber,JComboBox comboBox){
        comboBox.addItem(" ");
        for (int index = 2002; index > highNumber; index--) {
          comboBox.addItem(String.valueOf(index));
      private void YearSpecificComboBox()
        Year( 1900, YearjComboBox);
    private String StringFromDateFields(){
        int month =1;
        if (MonthjComboBox.getSelectedItem().equals(JANUARY))
          month = 1;
        else
          if (MonthjComboBox.getSelectedItem().equals(FEBRUARY))
            month = 2;
          else
            if (MonthjComboBox.getSelectedItem().equals(MARCH))
              month = 3;
            else
              if (MonthjComboBox.getSelectedItem().equals(APRIL))
                month = 4;
              else
                if (MonthjComboBox.getSelectedItem().equals(MAY))
                  month = 5;
                else
                  if (MonthjComboBox.getSelectedItem().equals(JUNE))
                    month = 6;
                  else
                    if (MonthjComboBox.getSelectedItem().equals(JULY))
                      month = 7;
                    else
                      if (MonthjComboBox.getSelectedItem().equals(AUGUST))
                        month = 8;
                      else
                        if (MonthjComboBox.getSelectedItem().equals(SEPTEMBER))
                          month = 9;
                        else
                          if (MonthjComboBox.getSelectedItem().equals(OCTOBER))
                            month = 10;
                          else
                            if (MonthjComboBox.getSelectedItem().equals(NOVEMBER))
                              month = 11;
                            else
                              if (MonthjComboBox.getSelectedItem().equals(DECEMBER))
                                month = 12;
                              String
                              DOB = DayjComboBox.getSelectedItem()+"/"+String.valueOf(month)+"/"+YearjComboBox.getSelectedItem();
                              return DOB;

    Thanks for your time.
    I could not get that to work ??
    I have come up with this code whitch seams to work. Thought you may like to see it
         String dobxml = xmlDoc.getValueOf(clientInfo, "DOB");
          String dob = dobxml.replace('/', ' ');
          System.out.println(dob);
          StringTokenizer tokenizer = new StringTokenizer(dob);
          String day = tokenizer.nextToken();
          String month = tokenizer.nextToken();
          String year = tokenizer.nextToken();
          System.out.println(dob);
          DayjComboBox.setSelectedItem(day);
          MonthjComboBox.setSelectedIndex(Integer.parseInt(month));
          YearjComboBox.setSelectedItem(year);ps thankyou
    Craig

  • Value of two combo box is not persistent on change of a third combo box

    Hi All:
    I have flex page in which i have 3 combo boxes. I would be
    selecting first 2 combo box and when i select the third combo box ,
    i would get the value of previous two combo selection and display
    data accordingly.
    My problme here is when i do a change in 3rd combo box the
    values of other combo boxed are defaulted to "Select..." without
    maintaining my previous selection.
    I am stuck in this for a while. I would really appreciate if
    you can help me out in this.
    Thanks
    Kan

    there's a typo.  fix it or remove it:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
    trace(a);
       compareF();
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    compareF()
    cbSecond.addEventListener(Event.CHANGE, Second);
    function compareF(){
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);

  • When i change the value of a combo box using a property node it displays the value not the item label

    I am using a combo box as a select list for text serial commands.  I have items like "engineering", "GUI", and "Scan" for the commands "MDE", "MDN", and MDS respectively which i have input as the corresponding value in the combo box.  so for example the label "engineering" has the value "MDE" in the combo box items list.  when the Vi starts it needs to read the current value MDE, MDN, or MDS and then i want it to display on the front panel the item text corresponding to that command value.
    To do this i have tried to read the serial command, ie MDS and then wire that to a "value" property of a property node of the combo-box, but instead of displaying the corresponding item label, "Scan", it displays the value "MDS" on the front panel instead.  i want the front panel to use the label text when choosing and displaying but the block diagram to use the serial commands.  Can this be done with a combo box?  I'm trying to use a combo box so i can keep it all text and avoid having to build a case statement to convert enums or rings from a numerical value to the text command.
    The correct text value is wired to the value property and it does exist in the combo-box.  I have unchecked "values match items" and selected to not allow undefined values.

    Don't use the value property node.  Use the Text.Text property node.  When creating the property node, select Text, then in the next pop-up box, select Text.
    - tbob
    Inventor of the WORM Global

  • How to get values in the combo box in a XML form?

    Hi All,
        1. I have created a property which has "Default value" as "Clothings" and  "Allowed Values(csv)" as Real Estate - Sales , Clothings etc" by navigating to KM > CM > Global Services > Property Metadata > Properties.
       2. In the XML form builder when I drag this property I get a combo box for this property.
       3. But when I preview this by going to Content Management > Folder > New > FORMS > and select my XML form project I get a preview but it is not showing me the default values in the combo boxes which I created using the property in XML form builder.
    Please Suggest me as to how to get those values (which I mentioned in property) in the combo box ?
    Thanks in Advance,
    Jasmine.

    Hi All,
      I ll make the above Query Simple.
    1.In Xml Form Builder when you drag a property which has some 3-4 assigned values so you are  recomended to use a combo box.
    2.But the problem after using COMBOBOX is I am not getting these values in the preview of the combo box.
    3.Help Required please its urgent.
    Thanks in advance,
    Jasmine.

  • How to get value of html combo box (i.e select) in jsp?

    Hello,
    I was just wondering how to get value of html combo box in jsp page. My code for combo box is:
    <select name="combo" size="1">
    <%
    List<Project> projects = mgr.getProjects();
    for(Project project : projects){
    %>
    <option value="<%= project.getId()%>"><%= project.getName()%></option>
    <%
    %>
    </select>
    I thought combo.value might give me the value, but it throws exception.
    Any help is appreciated.
    Thanks.

    The combo does not exists in Java, but only in HTML. You have to submit the form containing the combo and then use request.getParameter("combo") to get it's value ;-)

  • Form development - Getting a value from a combo box

    Hey,
    I have recently started form development in IDM. I seem to have stumbled at the first hurdle. I have created a combo box with some hard coded values. I want a variable to hold the value of what is currently selected in the combo box. The reason is what is selected in the combo box will affect what appears further down on the form.
    Can anyone help me achieve this?
    Thanks for your time

    There may be many good answers to this problem. One may be the fact that the value of the combo box is accessible futher down in the form simply by referencing the name of the combo box.
    For example, if the name of the combo is cmbVal and assuming the base context is variables, you can later reference that field (in a Disable, Derivation, Expansion...) with <ref>cmbVal</ref>.
    If the base context was variables.user, the same would hold true, let's say, for waveset.capabilities, where the reference would be <ref>waveset.capabilities</ref>.
    A more creative alternative might include setting a Process, Activity, or Action level variable in the expansion of the combo and then referencing that value later on. This requires that the combo has action and isn't as good of a solution as the first.
    Hope that helps.

  • How to show default value selected in combo box...

    Hi,
    I need an help...
    I have a combo box and i want to show the default value(coming from DB) selected on combo box on Page Render.
    Thanks,
    Neha

    Hi,
    Will this help?
    database default value in selectOneChoice
    Set default selected value in a SelectOneChoice
    Regards
    Vishal

  • Importing a list into a combo box.

    I need to import several large lists into combo boxes in a form I am creating in AcrobatPro XI. I found the comboPopulateTest.pdf in another discussion; however, this only populates the items in the list. I need to import the Export Values associated with each item as well. Can the Java Script be modified to include two items on each line? I have tried but cannot get it to work -- I don't know if I have the correct name for the Export Values field, or if I'm doing something else incorrectly.

    It can be done with a script. Have a look at the setItems method of the Field object.

Maybe you are looking for

  • How to install Windows 7 on a hard disk sdd from a macbook pro 13 " i7?, How to install Windows 7 on a hard disk sdd from a macbook pro 13 " i7?

    I have a macbook pro 13 " and I shall like settling on an external hard disk ( SSD) Windows 7 not to split up the main disk.

  • IPhone Battery????

    Hi. My IPhone is a 3G (I think) Model MB702LL. It was updated to version 4.2.1. Two days ago started to sign low battery but it seems it doesn't hold a charge.Though my battery level it's totally red I can still make/receive calls. I went to an Apple

  • Writing on top of writing?

    There are certain websites where the titles or headers have writing on top of writing. Is this my Mac Air or is it the web site? Thank you.

  • Cisco Works LMS 4.0 - Fault Monitor Issue

    Hi!,      I have a little problem with the LMS application. when I try to access to the screen of: Monitor --> Monitoring Tools --> Fault Monitor, the application shows an error message that only said: "Sorry an error occurred" and thats all. Any ide

  • Why won't my G3 run 10.3.9?

    This is a third (backup/music) Mac. It's been running 10.3.5 for several months. I thought I would update it along with iTunes this weekend. I'm sure Apple is wondering why I've registered my OS over a dozen times in the last three days. It has never