2 Replies Latest reply on Aug 7, 2008 3:22 AM by dcc66

    Trouble getting started with page navigation

    dcc66

      Greetings,
      I've spent the last few days getting started with JSFUnit and so far all looks good - but now I've run into problems with page navigation. If I'm not wrong it should simp[ly be a case of doing something like the following:

      ClientIDs ids = client.getClientIDs();
      String id = ids.findClientID("_id1");
      client.clickLink(id);
      server = new JSFServerSession(client);
      assertNotNull(server.getCurrentViewID());
      

      Now, in my JSF page I have a series of tabs, the source code of which is as follows:
      <map name="tab0-map">
      <area id="_id35:tabIdx_0" onclick="submitForm('_id2',0,
      {source:'_id35:tabIdx_0'});return false;" accesskey="D" href="#"
      alt="Details: Select to go to this tab" title="Details: Select to go to this
      tab" coords="0,19,10,0,57,0,65,8,65,19" shape="poly"/>
      ...........
      ...........
      ...........
      </map>
      

      When the tab I want to navigate to is<area id="_id35:tabIdx_0"..... etc

      But when I do:
      client.clickLink("_id35:tabIdx_0");
      

      I get an error:

      No component ID was found for _id35:tabIdx_0

      Investigating further, I try:
      ClientIDs ids = client.getClientIDs();
      String id = ids.findClientID("_id35:tabIdx_0");
      String id2 = ids.findClientID("_id2");
      ...... etc
      


      the id Strings are null. Indeed, if I run my test through the debugger and look at the ClientIDs object, no "_id35:tabIdx_0" id exists.

      I then tried pasting the id numbers from the debugger into the "findClientID"Indeed, none of the expected ids exist. How can this be if I can see it in the HTML sourcecode for my page?

      Is there something I have so far misunderstood?

      How can I get a simple map of all the components in my page? Perhaps from that, I can then find the one I need to navigate to.




        • 1. Re: Trouble getting started with page navigation
          ssilvert

          See http://wiki.jboss.org/wiki/JSFClientSessionAPI

          client.clickLink() is used to click a link that was created using the JSF <h:outputLink> tag.

          The reason no component ID was found for _id35:tabIdx_0 is because the markup was not generated with JSF. ClientIDs looks at the server side to find all of JSF client IDs.

          The Beta 3 version of JSFUnit will be out soon. This version takes a very different approach to emulating the browser. Instead of HttpUnit, we use HtmlUnit which bills itself as a "headless browser". We still put a JSFClientSession class on top of HtmlUnit for manipulating JSF components. HtmlUnit includes a much more natural API for when you need to deal with the rest of your page and especially your AJAX/javascript stuff.

          For what you are wanting to do, I think you will need the new version. You can build it from SVN and try it out. Or you can wait a few weeks for Beta 3. This will be done before the end of August.

          See some of the posts at the beginning of this forum to get started with the new JSFUnit.

          Stan

          • 2. Re: Trouble getting started with page navigation
            dcc66

            Many thanks for that Stan,

            Yes indeed, we are using Oracle's ADF Faces which is why the output from the jsp pages looks as it does.

            The new JSFUnit sounds excellent and I look forward to trying it out.