2 Replies Latest reply on Sep 27, 2008 12:37 AM by Jim R

    RichFaces combobox and datatable

    Jim R Newbie


      I wonder if jsfunit has special handling for combobox and datatable control of richfaces? I tried to use client.setValue on combobox, but it didn't work:

      This method can not be used on components of type com.gargoylesoftware.htmlunit.html.HtmlDivision

      Also I'm not sure what's the best way to find a row with particular value in a column in datatable, any ideas?


        • 1. Re: RichFaces combobox and datatable
          Stan Silvert Master

          Right now, the RichFacesClient doesn't have special methods for combobox. It does have methods for datatable scroller and data filter slider, but that's probably not what you are looking for.

          The RichFacesClient needs to be beefed up to add more convenience methods for those components that need it. The combobox is a great example where it appears to be pretty easy to set the value, but you have to do some digging.

          For example, take a look at the RichFaces demo here: http://livedemo.exadel.com/richfaces-demo/richfaces/comboBox.jsf?c=comboBox.
          The markup looks like this:

          <rich:comboBox defaultLabel="Enter some value">
           <f:selectItem itemValue="suggestion 1"/>
           <f:selectItem itemValue="suggestion 2"/>
           <f:selectItem itemValue="suggestion 3"/>
           <f:selectItem itemValue="suggestion 4"/>
           <f:selectItem itemValue="suggestion 5"/>

          The combobox is rendered like this:
          <div id="j_id258">
          <div id="j_id258combobox" class="rich-combobox-font rich-combobox" style="width: 150px;">
          <div class="rich-combobox-list-cord"/>
          <div class="rich-combobox-font rich-combobox-shell" style="width: 150px;">
          <div id="j_id258listParent" class="rich-combobox-list-cord" style="position: absolute; z-index: 1000; visibility: visible; display: none;">
          <div class="rich-combobox-shadow">
          <div id="j_id258listPosition" class="rich-combobox-list-position">
          <div id="j_id258listDecoration" class="rich-combobox-list-decoration">
          <div id="j_id258list" class="rich-combobox-list-scroll">
          <span class="rich-combobox-item rich-combobox-item-normal">suggestion 1</span>
          <span class="rich-combobox-item rich-combobox-item-normal">suggestion 2</span>
          <span class="rich-combobox-item rich-combobox-item-normal">suggestion 3</span>
          <span class="rich-combobox-item rich-combobox-item-normal">suggestion 4</span>
          <span class="rich-combobox-item rich-combobox-item-normal">suggestion 5</span>
          <input id="j_id258comboboxValue" type="hidden" name="j_id258"/>

          You can see that the input tag is what needs to have a value set. So the input tag for the combobox has an id="j_id258comboboxValue". If you add a regular id="myComboBoxId" to your markup, you should be able to set the value by saying:

          I've added a jira task so that we will remember to add the convenience method to RichFacesClient. https://jira.jboss.org/jira/browse/JSFUNIT-167

          As for your question about finding a row with a particular value, there are many ways to do that depending on exactly what you are trying to test. Don't forget that it is often easier to navigate through the view using the JSFServerSession, which allows you to find components in the server-side component tree.

          If you give me some more details on what you are trying to verify with your test then I can probably give you some more specific suggestions.


          • 2. Re: RichFaces combobox and datatable
            Jim R Newbie

            Thank you very much for the detailed explanation, the combobox trick works great! I think I know how to deal with table now, I need to drop down to htmlunit level and work with htmltable object there.