9 Replies Latest reply on Jan 20, 2011 1:51 PM by ilya40umov

    comboBox is not fetching data from my table

    olasamuel

      Hi all,

       

      I have a rich combobox. like this

       

      <rich:comboBox value="#{user.subscriberName}" defaultLabel="Select Subscriber" style=" width : 129px;">

       

       

                        </rich:comboBox>

       

      which is according to this link http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_comboBox.html.

       

      I want the combobox to fetch the data from my enityTable but the comboBox display nothing. When I tried to use it like this:

       

      <rich:comboBox value="#{subscriber.subscriberName}" defaultLabel="Select Subscriber" style=" width : 129px;">

                             <f:selectItems value="#{subscriber.subscriberName}"/>

       

                        </rich:comboBox>

       

      I get the following error:

       

      Value of tag <selectItems> attribute is incorrect.

       

      Can someone tell me how to do this if I am not doing it correctly?

       

      Thank you

        • 1. Re: comboBox is not fetching data from my table
          ilya40umov

          Accordingly to this link:

          http://download.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/f/selectItems.html

          valuefalsefalsejavax.el.ValueExpression
          (must evaluate to java.lang.Object)
          Value binding expression pointing at a List or array of SelectItem instances containing the information for these options.

           

          So you should create a list of SelectItem elements in your bean.

          Look at the link for the details:

          http://www.roseindia.net/jsf/selectItems.shtml

          • 2. Re: comboBox is not fetching data from my table
            olasamuel

            So does that mean that there is no way that I can make my comboBox to fetch the data from my table? What I want to do is for comboBox to fetch the data of a row from my table and that is why I linked it with that particular role in my bean which is an enity. Any help on populating rich:comboBox from the database table based on the data that is present in the table without any need to create a list of selectItem manually?

            • 3. Re: comboBox is not fetching data from my table
              ilya40umov

              I'm afraid that there is no standard ways to do it. You can only try some "magic" with JavaScript and DOM on the client side. But I don't think that this is a good way.

              • 4. Re: comboBox is not fetching data from my table
                olasamuel

                I found it strange that one cannot dynamically load or populate comboBox with the value of data in a table inside a database. Now lets say for example my value changes does that mean I will have to go back to my code and modify it every time the value changes?

                • 5. comboBox is not fetching data from my table
                  ilya40umov

                  I looks like we are talking about two different components. =)

                  1) Please, provide your code and describe what do you think rich:comboBox should do.

                  2) rich:comboBox shows to a user the list of options and the user can pick on of this option. Then this value will be submited immitiatly or when form is submited. The list of options can be static(f:selectItem) or dinamically obtained (f:selectItems with a list of SelectItem elements). The list of SelectItem elements can always depend on some value in your bean. So I don't understand where's your problem.

                  • 6. comboBox is not fetching data from my table
                    olasamuel

                    This is my simple code

                     

                    <s:decorate id="selectUserDecoration" template="layout/edit.xhtml">

                                      <ui:define name="label">Select User:</ui:define>

                                      <rich:comboBox id="selectOneCb" value="" >

                                          <f:selectItem itemLabel="Select subscriber" var="subscriber" itemValue="#{user.userName}"/>

                                          

                                        

                                      </rich:comboBox>

                                    </s:decorate>

                     

                    userName is a property in my table entity bean. What I want the comboBox to do is to fetch the data that are store in this table and populate it and from there a user can select the vlaue from the list that the combo box presents.

                     

                    if I used <f:selectItems var="subscriber" itemValue="#{selectSub.options}"/>, I get Value of tag <selectItems> attribute is incorrect error

                    • 7. comboBox is not fetching data from my table
                      ilya40umov

                      Hm. I think the only problem that I haven't ever used Seam. That's why I wasn't able to answer you correctly immediately.

                      So definetly you should try some Seam tags which can help you to solve this task.

                      Look at the following link:

                      http://docs.jboss.org/seam/1.2.0.PATCH1/reference/en/html/controls.html

                      http://seamframework.org/Community/ComboboxSettingValue

                      http://www.coderanch.com/t/447746/JSF/java/Configuring-seam-convertEntity

                      If it won't help I think you should better wait for a answer from seam-guys =)

                      • 8. comboBox is not fetching data from my table
                        olasamuel

                        Thanks for the answer but they are not helping in any way. One is therefore confused where to post question when you have problem because no one seems to answer even in the seamframework community. I have tried the exact implementation of all the examples provided even in the richfaces page exadellive demo. Anyone with this experience should please help me

                        • 9. Re: comboBox is not fetching data from my table
                          ilya40umov

                          IMHO You should try with simpler examples and then add some additional functions. For example you can try to find and implement some simple page with h:selectOneMenu and s:selectItems. Then add some more complecated things and so on. I will help you to anderstand all the components better and you will not need to wait for any help.