Fill combo box  fro database using jsf

dear all,
i am new to JSF and i want to fill a JSF combo box from a database
can anyone help me ??
thanks in advance for help

use this tag inside  <h:selectCombobox>
<f:selectItems value="#{myBean.valueArrayFromDB}"/>

Similar Messages

  • How to fill combo box with list of all SQL server

    Ok, I know how to find all SQL servers that I need, I have code for that task, and I have Array of all servers.
    My problem is ...
    I made setup project and do a huge work, and in the end this task appear!
    I used ORCA tool to change TextBox (A) template in visual studio (2008 by the way), and I transform first TextBox to ComboBox.
    Now, the little part that I'am missing is how to fill this combo box with a result of my function for listin SQL servers?
    Can I somehow send combobox object to myMethod:
    private void FillCombo(ComboBox cmb)
          // do the job
    or
    instanceOfThisCombo.Items.Add(listOfSQLServers);
    please help me to solve this... thanksc#

    Hi Valerij,
    The ComboBox control in an MSI dialog uses the ComboBox table to populate the items in it. To get what you want, you need to update the ComboBox table in the MSI package with your application and run the MSI package. The following KB article describes how to dynamically populate a ListBox control in Windows Installer:
    http://support.microsoft.com/kb/291329
    This method introduced in the above KB article also applies to populating a ComboBox control in Windows Installer.
    I don't think it's possible to run the application as a Custom Action from within the MSI package because the application will modify the content of the MSI package which is currently running. So you need to launch the MSI package from within your application after updating the ComboBox table. In short, when installing, just run your application which updates the ComboBox table and install the MSI package.
    Hope this helps.
    If you have any question, please feel free to let me know.
    Sincerely,
    Linda Liu

  • Question abt. combo box and database

    Hi. I have two combo boxes, A and B. Items in A is obtained from table X, Items in B is obtained from table Y. But, the problem is that whatever appears in combo box B should not contain those in combo box A. How do i go about doing this? Note that values in table X come from values in table Y.Here's an example:
    (this is I currently have)
    Combo X             Combo Y
    Apple            Mango
    Orange           Kiwi Fruit
    Pineapple        Apple
    Kiwi Fruit        
    Mango          (this is I WANT)
    Combo X                  Combo Y
    Orange                  Mango
    Pineapple               Kiwi Fruit
                            ApplePlease help and thanks in advance.

    hi....
    First of all, I've designed the two combo boxes with Add/Delete buttons in the GUI. I'm using JSP to retrieve values from database table into my combo boxes.
    Actually, I have the two combo boxes already. I have already got the items inserted into combo A from table X using JSP. I am thinking of getting all the values in combo box B from the table Y first, then maybe store them in an array or something, b4 comparing those values with that from combo box A, eliminate those existing in combo box A, and the rest will be stored in combo B.
    I do not know exactly how to store values i obtained from table to an array and how to compare arrays.
    hope u understand what i'm trying to say, please help if possible, thanks.

  • **urgent*** -two  combo boxes  -one  database table - ***urgent**

    1. i have one html page - in that two combo boxes are there
    2. first one called--> Bank Name and second one called-->Main Branch
    3. i have a database table like BANK_MASTER(MAIN_BRANCH,BANK_NAME)
    i am giving here some data for the above table:
    (sbi-kurnool, sbi),(sbi-cadapah,sbi),(sbi-chittor,sbi),(ab-rangareddy,ab),(ab-varangal,ab) ..like that every bank has its own main branch in different location.
    MY PROBLEM:
    In HTML page, in the first combo box ie., Bank Name will display all the bank name using the table BANK_MASTER ie.,sbi,ab,cb,sbh ...... (its ok - i too get )
    main Problem: Whenever i select a particular bank name in the first combo box, the second combo box ie.,Main Branch has to display the main branches using the table Bank_Master depending on the Selected bank name from the Bank Name Combo box ( ie., if we select the sbi, it has to display all main branches of sbi's only, but not other bank's main branches)

    Hi friend,
    I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
    U can checkout the below example just for further reference delete
    UserForm.jsp:
    ==========
    <head>
    <script>
    var xmlHttp
    function showState(str)
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    var url="getState.jsp"
    url=url+"?count="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChange
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChange()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("state").innerHTML=xmlHttp.responseText
    </head>
    <body>
    <select name='country' onchange="showState(this.value)">
    <option value='india>india</option>
    </select>
    <br>
    <div id='state'>
    <select name='state' >
    <option value='-1'>pickone</option>
    </select>
    </div>
    </body>       
    getState.jsp
    ============
    <%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
    <%
    String country=request.getParameter("count");
    response.setContentType("text/html");
    response.setHeader("Cache-Control","no-cache");
    try{
    Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
    String buffer="<select name='state'><option value='-1'>Pick One</option>";
    Set s=ht.keySet();
    Object keys[]=s.toArray();
    int size=keys.length;
    for(int i=0; i < size;i++){
    buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
    buffer=buffer+"</select>";
    response.getWriter().println(buffer);
    catch(Exception exp){
    response.getWriter().println(exp);
    %> I think u may go upon replacing country with your Main Branch and vice versa

  • How yo fill combo box by javascript

    hi all,
    i am new to acrobat. working on Acrobat 9.
    i m tryin to add elements to a combo box by javascript....i tried using "setItem()" bt this didnt help

    finally i was able to populate the combo with numbers in a loop....actually wht i m tryin is to populate the combo with name of meshes in a 3D model using 3D tool added on the pdf, on the click of button....bt i cldnt establish connection between the 3d object and the form elements on the pdf

  • Query SQL database using JSF problem!! Using CachedRowSet

    I'm using JSF and want to query data from SQL by using CachedRowSet like this,
    rowset.setCommand("SELECT * FROM dbo.SomeTable WHERE SomeField='"+ xyz +"'");
    then check if the record does exist by using
    *if(rowset.next()) {/ do something with the retrieved data}*
    but i get SQLException telling that execute() never called.
    Anyone can tell me what i'm missing? or is there any better way to check the existence of a record ?
    Thanks in advance :-)

    Hi grzegorz,
    1. If your sap application server is unix/aix
      (and not a microsoft OS),
    2. then this kind of secondary databse connection,
       to MS SQL (which is microsoft system),
       is at present not possible.
      (BCOS the required system files, for such
       cross - platform connection is not delivery by sap)
    regards,
    amit m.

  • How to connect oracle database using jsf

    how to connect oracle database using javaserver faces with connection pooling

    Here is one way...
    http://jakarta.apache.org/commons/dbcp/

  • How to connect database using JSF??

    When I deployed a JSF war file which was connected to MySql on Sun Application Server, then lanuched it, why there was an error message like "HTTP Status 503 - This application is not currently available". Can anyone tell me why? thanks.

    Thanks pringi~~!!
    I still have problems about the database connection. I had tried many examples which were provided by some books. However, once I deployed the application, it still got problems. Can anyone help me and provide a example about the database connection. Thanks a lot.

  • 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.

  • Changing xy graph scale using combo box selection

    Hello,
    I have a xy graph with x scale set to 10k and y scale set to 6 by default.
    I have a combo box which i use to select what the graph will display. For example in combo box i have 3 choices, A, B, C.
    If i select A, xy scale is set to 10k and 6. If i select B, xy scale is set to 2.5k and 8, if i select C, xy scale is set to 4k and 10 respectively. Is there some functions that i can use to do this?
    Thanks.
    Solved!
    Go to Solution.

    Like this (attached)?
    Of course, if the data actually follows these mins and maxes, you could just turn on auto scaling and it would do it automatically
    Tim Elsey
    LabVIEW 2010, 2012
    Certified LabVIEW Architect
    Attachments:
    Untitled 1.vi ‏14 KB

  • Dependent combo boxes using webservice

    Hi All,
    I'm trying to create a depended combo boxes using af:selectOneChoice, using webservice datacontrol. When i try to change the value of the first combo box which has hard coded values (eg. Continent), The depended combo box (eg.Country) is empty. (which is returned via webservice) When i again change the value of the first combo box, I get the corresponding values(Countries) generated. The very first time when a value is selected is not binded to the model. Why is this happening and how to overcome this issue. I tried using the value change listener and assigned the current value to binding but there was no change in the behaviour.

    Thanks for your response Frank. The Sample worked fine. But when i try to implement the same i ran into issues.
    First, I created a combo box for continents and a managed bean.
    <af:selectOneChoice label="Region" id="soc1" autoSubmit="true"
                                  valueChangeListener="#{locateBean.setRegion}">
                <af:selectItem label="Asia" value="Asia" id="si3"/>
                <af:selectItem label="Europe" value="Europe" id="si2"/>
                <af:selectItem label="NA" value="NA" id="si1"/>
              </af:selectOneChoice>Then I created a combo box for countries using the webservice data control.
              <af:selectOneChoice value="#{bindings.Country.inputValue}"
                                  label="Country"
                                  required="#{bindings.Country.hints.mandatory}"
                                  shortDesc="#{bindings.Country.hints.tooltip}"
                                  id="soc2" partialTriggers="soc1">
                <f:selectItems value="#{bindings.Country.items}" id="si4"/>
              </af:selectOneChoice>In the managed bean as
        public void setRegion(ValueChangeEvent event) {
            this.region = (String)event.getNewValue();
        }1. When i run and select an continent, the values are not getting populated in the country combo box. If i refresh the page or select another value for the continent, then its is getting populated.
    2. When i tried to execute the operation manually at pagedef on value change event,
            OperationBinding operBinding = getBindings().getOperationBinding("GetCountryList");
            operBinding.execute();I'm getting an warning as <FacesCtrlListBinding> <getInputValue> ADFv: Could not find selected item matching value Afghanistan of type: java.lang.String in the list-of-values.Why the value binded to the managed bean or model is not getting updated for the first time. Is this the expected behavior.

  • Display data in list and combo box

    hi all....
    how to display data from database in list and combo box? i use MYSQL...
    help me please..... tq...

    1 - Write a query to retrieve the data you want from database
    2 - In a servlet, connect to database, Run the query, scroll through the result set and put the data into a list of Java Objects.
    3 - Set a request/session attribute of that list of objects
    4 - Forward to JSP
    5 - In JSP, create a <select> box, and then use a <c:forEach> loop to generate <option> tags from the list.

  • Multiple lines in a combo box

    Hello,
        I am attempting to create a pdf file for the purposes of filling in information and then printing it out.  I have very limited skill with Acrobat 8, basically what I've learned myself, and I run into an issue with my combo boxes.  Some of the sentences I have put into the boxes are too long and I have not been able to figure out how to wrap the text, or make it use multiple lines.  I need all of my data to show.  Can someone explain, in simple terms if possible, how this can be accomplished, or provide an alternative.  I have read several posts but have not been able to work out where to start with them.  Any help would be appreciated.  Thanks!

    I've been reading through more forums and I think what you suggested was to have shorter options in the combo box that, when selected, generate the full length sentence into a text field.  Is that the basic concept?  Here is one of the sentences that is too large for my combo box:
    5b. Use Mendel's Law to evaluate monohybrid Punnett Squares for complete dominance, incomplete dominance, codominance, sex-linked, and multiple alleles. (DOK 2)
    So I could set up a combo box with 5b in this case.  I could then write script in the combo box properties that would cause the sentence to be generated into a text field located beside the combo box.  If this is the case I would have to write out script for each one of the number/letter combinations correct? 
    Just for some background info, I'm attempting to create a lesson plan template (I'm a teacher) that has all the necessary information listed so that I don't have to type it all out every time I do a lesson plan. 

  • I need a combo box with 4 values to choose from which will populate a text box on the form with text related to each combo box selection

    For example:
    Combo box choices:
    apple
    tomato
    squash
    Pumpkin
    The text box depending on the selection above would state the color:
    Green        (if Apple was chosen from the combo box
    Red           (if Tomato was chosen from the combo box
    Yellow       (if Squash was chosen from the combo box
    Orange      (if Pumpkin was chosen from the combo box
    I am very new at this and have spent hours looking for an answer.  Thank to anyone in advance who can help!

    Place each value as the export value of the options in the combo-box and then use this code as the text field's custom calculation script:
    event.value = this.getField("ComboBox Name").value;

  • Multiple combo boxes cause application freeze

    I have an application that uses 3 combo boxes, they appear if
    the remoting service populates them.
    The actionscript is very simple, I only add items, removeall,
    and sort them by their label.
    If I use old MX combo box, my application works perfectly.
    If I use the Version 2 components, the application works when
    I select one of the combo boxes, but the second I touch the second
    combo box, it locks up the application and I get the message that a
    script is running, should I abort...
    I am using Flash 8 and want to stick with all V2 components,
    but...
    anybody experience this issue? I have a lot of other V2
    components on the application, all work, except this combobox
    issue.
    thanks
    Josh

    You can create a JavaScript array of the items and values to be set into the combo boxes and then use Acrobat's JavaScript's ''setItems()' method to load the fields.
    Get various fields (combo or list) and set items in the list using various techniques. 
    var l = this.getField("ListBox");
    l.setItems(["One", "Two", "Three"]);
    var c = this.getField("StateBox");
    c.setItems([["California", "CA"],["Massachusetts", "MA"],
    ["Arizona", "AZ"]]);
    var c = this.getField("NumberBox");
    c.setItems(["1", 2, 3, ["PI", Math.PI]]);

Maybe you are looking for