1 Reply Latest reply on Feb 25, 2008 9:53 AM by Stan Silvert

    Disable/Enable of buttons

    steve alex Newbie


      how to test the disable and enable of buttons. using jsfunit


        • 1. Re: Disable/Enable of buttons
          Stan Silvert Master

          You have several ways to test this. Assume you have a command button defined like this:

          <h:commandButton value="Hello" action="/index.jsp" id="submit_button" disabled="#{mybean.enabled}"/>

          You can test this from the server side using the JSFServerSession like this:
          JSFServerSession server = new JSFServerSession(client);
          HtmlCommandButton submitButton = (HtmlCommandButton)server.findComponent("submit_button");

          From the client side you have several ways to find the component but the simplest in this case is to use the HttpUnit API:
          WebResponse response = client.getWebResponse();
          String clientID = client.getClientIDs().findClientID("submit_button");
          Button submitButton = (Button)response.getElementWithID(clientID);

          I prefer testing this sort of thing from the server side, which is a bit more powerful.