1 2 Previous Next 19 Replies Latest reply on Nov 16, 2008 8:31 PM by kragoth Go to original post
      • 15. Re: Error when using rich:scrollableDataTable
        ssilvert

        I finally got HtmlUnit 2.4-SNAPSHOT to build.

        I added a test for RichScrollableDataTable and it worked. If you want to see it you can do a svn update on the JSFUnit svn repo. To run the test you will need to uncomment the code in RichScrollableDataTableTest and uncomment the versions in the dependency management section of the main JSFUnit pom. The three dependencies that need version updates are htmlunit, xalan, and commons-collections.

        So unfortunately, I couldn't recreate your problem. Perhaps if you look at the JSFUnit test for this you can compare it to yours.

        Stan

        • 16. Re: Error when using rich:scrollableDataTable
          kragoth

          Ok, I'm really confused and a tad frustrated now :P
          I'm going to post my code cause no matter what I do I cannot get any of my tests to work where there is a scrollable data table on the page.
          I have created a simple test to try and eliminate any other issues. But I just can't get it to work.

          Anyways here is my xhtml. Basically a straight copy from your test but now dynamic data. Just the table with headers.

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html
           xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich">
          
          <ui:composition>
          
           <style>
           .scrolls {
           width: 300px;
           height: 200px;
           overflow: auto;
           }
           </style>
           <h:form id="form1">
           <rich:spacer height="30" />
           <rich:scrollableDataTable
           rowKeyVar="rkv"
           frozenColCount="1"
           height="400px"
           width="700px"
           id="carList"
           rows="40"
           columnClasses="col"
           value=""
           var="category"
           sortMode="single">
          
           <rich:column id="make">
           <f:facet name="header">
           <h:outputText
           id="makeText"
           styleClass="headerText"
           value="Make" />
           </f:facet>
          
           </rich:column>
           <rich:column id="model">
           <f:facet name="header">
           <h:outputText
           id="modelText"
           styleClass="headerText"
           value="Model" />
           </f:facet>
          
           </rich:column>
           <rich:column id="price">
           <f:facet name="header">
           <h:outputText
           id="priceText"
           styleClass="headerText"
           value="Price" />
           </f:facet>
          
           </rich:column>
           <rich:column id="mileage">
           <f:facet name="header">
           <h:outputText
           id="mileageText"
           styleClass="headerText"
           value="Mileage" />
           </f:facet>
           </rich:column>
           <rich:column
           width="200px"
           id="vin">
           <f:facet name="header">
           <h:outputText
           id="vinText"
           styleClass="headerText"
           value="VIN" />
           </f:facet>
           </rich:column>
           <rich:column id="stock">
           <f:facet name="header">
           <h:outputText
           id="stockText"
           styleClass="headerText"
           value="Stock" />
           </f:facet>
           </rich:column>
           </rich:scrollableDataTable>
           <rich:spacer height="20px" />
           </h:form>
          </ui:composition>
          </html>
          


          And now my test.
          package gekko.web.jsfunit.scratch;
          
          import java.io.IOException;
          
          import gekko.web.jsfunit.pages.AbstractGekkoWebTest;
          
          public class RichScrollableDataTableTest extends AbstractGekkoWebTest {
          
           public void testGotoPage() {
           try {
           getContext().getClient().click("scrollTestLink");
           } catch (IOException e) {
           throw new IllegalStateException(e);
           }
           assertTrue(getContext().getServer().getCurrentViewID().equals("/scratch/tje/richScrollableDataTableTest.xhtml"));
           assertTrue(getContext().getClient().getElement("carList")!=null);
           }
          }
          


          This line always fails
          assertTrue(getContext().getClient().getElement("carList")!=null);
          


          Here is the superclass to understand what's going on
          package gekko.web.jsfunit.pages;
          
          import org.apache.cactus.ServletTestCase;
          import org.apache.log4j.LogManager;
          import org.apache.log4j.Logger;
          import org.jboss.jsfunit.framework.WebClientSpec;
          import org.jboss.jsfunit.jsfsession.JSFSession;
          import org.springframework.web.context.WebApplicationContext;
          import org.springframework.web.context.support.WebApplicationContextUtils;
          
          import com.gargoylesoftware.htmlunit.BrowserVersion;
          
          import gekko.util.ReflectionUtils;
          import gekko.util.SpringUtils;
          import gekko.web.jsfunit.pages.root.HomePageDriver;
          
          
          public class AbstractGekkoWebTest extends ServletTestCase {
           private GekkoJSFTestContext testContext = new GekkoJSFTestContext();
           private static final Logger log = LogManager.getLogger(AbstractGekkoWebTest.class);
          
           @Override
           protected final void setUp() throws Exception {
           super.setUp();
          
           WebApplicationContext ctx = WebApplicationContextUtils
           .getWebApplicationContext(session.getServletContext());
          
           SpringUtils.injectBeanProperties(
           ctx.getAutowireCapableBeanFactory(), this);
          
           this.afterSetUp();
           }
          
           public void afterSetUp() throws Exception {
           log.debug("GekkoWebTest.afterSetUp(): Request page: " + HomePageDriver.PAGE);
          
           // Send an HTTP request for the initial page
           // There is currently a bug with running as IE 6 so, leave it on Firefox for now
           WebClientSpec wcSpec = new WebClientSpec(HomePageDriver.PAGE, BrowserVersion.FIREFOX_2);
           testContext.setSession(new JSFSession(wcSpec));
          
           //Logging in should probably be done differently but...this will do for now
           log.debug("GekkoWebTest.afterSetUp(): Logging in");
           HomePageDriver homePageDriver = getPageDriver(HomePageDriver.class);
           homePageDriver.setUsername("submitter");
           assertTrue(homePageDriver.isDisplayed());
           homePageDriver.clickSubmit();
           log.debug("After login the page is:" + testContext.getServer().getCurrentViewID());
           }
          
           public void beforeTearDown() throws Exception {
          
           }
          
           @Override
           protected final void tearDown() throws Exception {
           this.beforeTearDown();
           super.tearDown();
           }
          
           public GekkoJSFTestContext getContext() {
           return testContext;
           }
          
           public void setContext(GekkoJSFTestContext context) {
           this.testContext = context;
           }
          
           public <T extends GekkoPageDriver> T getPageDriver(Class<T> clazz) {
           T driver = ReflectionUtils.instantiate(clazz);
           driver.setTestContext(testContext);
           return driver;
           }
          
          }
          


          Here is the main menu that gets clicked to go to my test page. The last item is the one I'm clicking on.
          <?xml version="1.0" encoding="UTF-8"?>
          
          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:gekko="http://gekkoTagLibs.com"
           >
          
          <!--<link
           href="#{facesContext.externalContext.requestContextPath}/css/primary_nav.css"
           rel="stylesheet"
           type="text/css" />-->
          
          <script type="text/javascript">
          
           function findMenuStateInput() {
          // var el = document.getElementById("GekkoPageMenu").getElementsByTagName("input")[0];
          // alert(el.value);
           var el = document.getElementById("MasterPageForm:menuGroupSelectedState");
          // alert(el);
           return el;
           }
          
           function activateTopLevelMenu(menuGroupId, initState) {
          
           // FUTURE: Set this via EL to stop group toggle
           var disabled = #{NavigationManager.globalNavigationLocked};
          
           // Sorry for nested if but parser was giving me grief
           if (! initState) {
           if (disabled) {
           return;
           }
           }
          
           if (initState == null) {
           initState = false;
           }
          
           // Close down old menu choice
           if (! initState) {
           var oldMenuGroupId = findMenuStateInput().value;
           if (oldMenuGroupId != menuGroupId) {
           if (oldMenuGroupId) {
           var oldMenuGroup = document.getElementById(oldMenuGroupId);
           if (oldMenuGroup) {
           oldMenuGroup.style.display = 'none';
           }
           }
           }
           }
          
           // Open new menu choice
           findMenuStateInput().value=menuGroupId;
          
           var menuGroup = document.getElementById(menuGroupId);
           if (menuGroup) {
           menuGroup.style.display = (menuGroup.style.display == 'none') ? 'block' : 'none';
           }
           }
          
          </script>
          
           <div class='navigator_container' id="GekkoPageMenu">
           <h:inputHidden value="#{MainMenuController.menuGroupSelected}" id="menuGroupSelectedState"/>
           <dl id="menu">
           <dt onclick="activateTopLevelMenu('searchMenuGroup');">
           <span class="searchMenuGroupStyle">Search</span>
           <gekko:graphicImage url="search_icon.gif" id="searchIcon" />
           </dt>
           <dd id="searchMenuGroup" style="display:none">
           <ul>
           <li>
           <h:commandLink id="gotoCertificateSearch"
           value="Certificate"
           action="#{MainMenuController.certificateSearchClicked()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink id="gotoCustomerSearch"
           value="Customer"
           action="#{MainMenuController.searchCustomer()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink id="gotoProposalSearch"
           value="Proposal"
           action="#{MainMenuController.searchProposal}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink id="gotoTenureSearch"
           value="Tenure"
           action="#{MainMenuController.searchTenure}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink id="gotoUserSearch"
           value="User"
           action="#{MainMenuController.searchUser()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           </ul>
           </dd>
           <dt onclick="activateTopLevelMenu('scratchMenuGroup');">
           <span class="scratchMenuGroupStyle">Scratch</span>
           <gekko:graphicImage url="error_icon.gif" id="scratchIcon" />
           </dt>
           <dd id="scratchMenuGroup" style="display:none">
           <ul>
           <li>
           <h:commandLink
           id="gotoDraftUserSearch"
           value="Draft Example User"
           action="#{MainMenuController.searchDraftEgUser()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoBatchAdmin"
           value="Batch Administration"
           action="#{MainMenuController.batchAdministration()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoTenureMutation"
           value="Tenure Mutation"
           action="#{MainMenuController.tenureMutation()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoBatchTenureCreationProcess"
           value="Batch Tenure Creation Process"
           action="#{MainMenuController.batchTenureCreationProcess()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoPerformLeaseholdCalculations"
           value="Perform Leasehold Calculations"
           action="#{MainMenuController.performLeaseholdCalcs()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoPerformCalculations"
           value="Perform Calculations"
           action="#{MainMenuController.performCalculations()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoASearch"
           value="A Search"
           action="#{MainMenuController.aSearch()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="gotoGekkoTagReference"
           value="Gekko Tag Reference"
           action="#{MainMenuController.viewGekkoTagReference()}"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           <li>
           <h:commandLink
           id="scrollTestLink"
           value="ScrollTestLink"
           action="/scratch/tje/richScrollableDataTableTest.jsf"
           disabled="#{NavigationManager.globalNavigationLocked}"/>
           </li>
           </ul>
           </dd>
          
           </dl>
           <rich:spacer width="100%" height="100px" />
          
           <div style="height:100%;width:100%;text-align:center">
           <gekko:graphicImage id="gekkoImg" url="gekko.gif" />
           </div>
          
           </div>
          
          <script type="text/javascript">
           // This is designed to sync the initial menu state on a page with server
           // state. Normally would add this to list of onLoad events.
           activateTopLevelMenu(findMenuStateInput().value, true);
          </script>
          
          </ui:composition>
          



          My client always has this as its getPageAsText() value after clicking on the menu option.
          <?xml version="1.0" encoding="ISO-8859-1"?>
          <html>
           <body/>
          </html>
          


          I might try to make my test even more simple by not logging in but that requires a bit of messing with the rules. But, I'm stuck now... I have no way of moving forward with JSFUnit at the moment.

          Yes I've tried updating my collections library but that made no difference.

          How can i make your tests run on Tomcat? Could that be an issue?

          • 17. Re: Error when using rich:scrollableDataTable
            kragoth

            that should read "NO dynamic data" sorry.

            • 18. Re: Error when using rich:scrollableDataTable
              kragoth

              Ok.... I stopped being silly and made a basic single page test.... and the stupid thing worked! LOL

              So.... it seems there is something happening on transition from one page to another page with a scrollableDataTable.
              I'm gona go do some more digging around and see if I can find out a little bit more so that you can reproduce the error.
              At least we know that the component itself is not the problem. Hopefully I'll have some info for you soon

              • 19. Re: Error when using rich:scrollableDataTable
                kragoth

                After getting myself very confused I finally think I have found the problem.

                The problem is a combination of couple of things. So here are the steps to reproduce the problem

                First you need 2 pages.
                page1: just needs a button or link that goes to page2.
                page2: needs a rich:scrollableDataTable

                Second your test must be run in FireFox2 mode.

                WebClientSpec wcSpec = new WebClientSpec("page1.jsf", BrowserVersion.FIREFOX_2);
                


                Now, make your test go from page 1 to page 2. Check that the scrollableDataTable is there. This should fail.

                Some interesting things about this problem.
                1. If I make my test go directly to the page with the rich:scrollableDataTable it works. The failure only happens on page transition.

                2. If I change the mode to default (which I think is IE 7) then the test will work.

                1 2 Previous Next