2 Replies Latest reply on Aug 11, 2008 10:28 AM by Peter Treitler

    Changing values of HtmlSelect components

    Peter Treitler Newbie

      I need to change the value of a dropdown menu (t:selectOneMenu) in my application.
      I have built JSFUnit from the latest svn version and I am using the classes from the jsfunit package instead of the facade classes.
      When I try to use the setValue method of JSFClientSession I get the following exception:

      java.lang.IllegalArgumentException: This method can not be used on components of type com.gargoylesoftware.htmlunit.html.HtmlSelect
      at org.jboss.jsfunit.jsfsession.JSFClientSession.setValue(JSFClientSession.java:156)

      Is there another way to do this?

        • 1. Re: Changing values of HtmlSelect components
          Brian Gregory Newbie

          One way is to click() the selectitem if they are declared:

           <h:selectOneMenu id="Weekdays">
           <f:selectItem id="selectMonday" itemValue="Monday"/>
           <f:selectItem id="selectTuesday" itemValue="Tuesday"/>
           <f:selectItem id="selectWednesday" itemValue="Wednesday"/>
           <f:selectItem id="selectThursday" itemValue="Thursday"/>
           <f:selectItem id="selectFriday" itemValue="Friday"/>
           <f:selectItem id="selectSaturday" itemValue="Saturday"/>

           JSFSession jsfSession = new JSFSession("/indexWithExtraComponents.faces");
           JSFClientSession client = jsfSession.getJSFClientSession();
           JSFServerSession server = jsfSession.getJSFServerSession();

          Another way if you don't have declared selectItems is to find the selectitem from the select control and click it directly:

           HtmlSelect htmlSelect = (HtmlSelect)client.getElement(controlId);
           HtmlOption htmlOption = htmlSelect.getOptionByValue(value);