2 Replies Latest reply on Dec 17, 2007 6:51 AM by pmuir

    Navigate to anchor?

    whafrog

      I have a series of h:dataTables, each of which can have rows added to or removed from them. To add or remove the rows I use an h:commandButton to call a method on the action class, which adds or removes the entity from the underlying list. As the page is rather long, when the page returns, I'd like to navigate to the dataTable where the row was added or removed. Example:

      <ui:define name="content">
       <h:form>
       <a name="DataTable1"/>
       <h:dataTable value="#{entityTypeLists.getEntityType('EntityType1')}" var="entity">
       <h:column>
       <h:inputText value="#{entity.name}"/>
       <f:facet name="footer"> </f:facet>
       </h:column>
       <h:column>
       <h:commandButton type="submit" value="-" action="#{entityManager.remove('EntityType1', entity)}"/>
       <f:facet name="footer">
       <h:commandButton type="submit" value="+" action="#{entityManager.add('EntityType1')}"/>
       </f:facet>
       </h:column>
       </h:dataTable>
       <a name="DataTable2"/>
       <h:dataTable value="#{entityTypeLists.getEntityType('EntityType2')}" var="entity">
       <h:column>
       <h:inputText value="#{entity.name}"/>
       <f:facet name="footer"> </f:facet>
       </h:column>
       <h:column>
       <h:commandButton type="submit" value="-" action="#{entityManager.remove('EntityType2', entity)}"/>
       <f:facet name="footer">
       <h:commandButton type="submit" value="+" action="#{entityManager.add('EntityType2')}"/>
       </f:facet>
       </h:column>
       </h:dataTable>
       <!-- and on and on -->
       </h:form>
      </ui:define>
      


      The action class code:
      public String add(String entityTypeName) {
       // ... add to list
       return "entityEditPage";
      }
      public String remove(String entityTypeName, Entity entity) {
       // ... remove from list
       return "entityEditPage";
      }
      


      Now, how can I navigate back to the anchor for, say, "DataTable2"?


        • 1. Re: Navigate to anchor?
          whafrog

          I've tried adding specific entries to my navigation.xml file based on output from the action class, but that doesn't seem to work either, eg, assuming entityTypeName.equals("EntityType2"):

          public String add(String entityTypeName) {
           // ... add to list
           return "entityEditPage." + entityTypeName;
          }
          


          <navigation-case>
           <from-outcome>entityEditPage.EntityType2</from-outcome>
           <to-view-id>/lenderbenefits-verify.xhtml#DataTable2</to-view-id>
           <redirect />
          </navigation-case>
          


          Do anchor tags not work at all with facelets?


          • 2. Re: Navigate to anchor?
            pmuir

            I don't believe JSF supports this, no.

            Feature request for JSF 2?