1 Reply Latest reply on Jan 24, 2008 8:13 AM by Stan Silvert

    JSFUnit supports javascript non ajax?

    yang pa Newbie

      Certainly, HttpUnit supports javascript, but JSFUnit doesn't any action onclick event of CommandButton.

      Anybody knows official support for javascript?


      My problem code.
      <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>




      <!--
      function openPopup()
      {
      var url = "popUp.faces";
      var obj = window.open(url,"popup","height=200,width = 200,resizable=yes");
      }
      function testScript()
      {
      document.getElementById("form00:inputText00").value = "200";
      return true;
      }
      -->



      <f:view>
      <h:form id="form00" style="height: 300px; width: 300px">
      <h:panelGrid columns="1">
      <h:panelGroup>
      <h:outputText value="AA"></h:outputText>
      </h:panelGroup>
      <h:panelGroup style="height: 20px; width: 800px">
      <h:inputText id="inputText00" value="#{testPageBean.inputText00}" size="10"></h:inputText>
      <h:outputText value="*"></h:outputText>
      <h:inputText id="inputText01" value="#{testPageBean.inputText01}" size="10"></h:inputText>
      <h:commandButton id="commandButton00" value="calculation" actionListener="#{testPageBean.processChangeAction}" ></h:commandButton>
      <h:commandButton id="commandButton01" value="popUp" onclick="openPopup();" ></h:commandButton>
      <h:commandButton id="commandButton02" value="Next Page" action="newPage"></h:commandButton>
      <h:commandButton id="commandButton03" value="Script test" onclick="document.getElementById('form00:inputText00').value = '200'"></h:commandButton>
      <h:outputText id="outputText00" value="#{testPageBean.outputText00}"></h:outputText>
      </h:panelGroup>
      </h:panelGrid>
      </h:form>
      </f:view>







      public class JSFUnitTest extends ServletTestCase{
      public static Test suit(){
      return new TestSuite(JSFUnitTest.class);
      }

      public void testInitialPage() throws IOException, SAXException{
      JSFClientSession client = new JSFClientSession("/test/testPage.faces");
      JSFServerSession server = new JSFServerSession(client);

      assertEquals("/test/testPage.jsp",server.getCurrentViewID());
      System.out.println("Begin:" + server.getCurrentViewID());
      client.submit("commandButton03");

      server = new JSFServerSession(client);

      HtmlInputText inputText00 = (HtmlInputText)server.findComponent("inputText00");
      System.out.println(inputText00.getValue());

      }}