4 Replies Latest reply on Apr 11, 2006 6:07 PM by kittyk

    using commandButton to link to a new window (xhtml)

    kittyk

      Hey There,

      I've done some research, aka surfed the web, to see if it's possible to use a commandButton in xhtml to link to a new page. I haven't found any answers and was wondering if anyone out there knows for sure? The idea is that I select a record, and hit update which will move me to a new window where the update is performed.

      Thanks,
      Kitty

        • 1. Re: using commandButton to link to a new window (xhtml)
          max522over

          In code set up the listing behavior with:

          @DataModel
          private List locationList;

          @DataModelSelection
          private Location selectedLocation;


          your jsp code could look like: I'm not sure about xhtml
          <h:dataTable value="#{locationList}" var="location" rendered="#{locationList.rowCount>0}"
          rowClasses="rvgRowOne,rvgRowTwo" headerClass="rvgOrder">
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_id}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="id"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.id}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_street}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="street"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.street}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_city}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="city"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.city}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_state}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="state"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.state}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_zip}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="zip"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.zip}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_opentime}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="opentime"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.opentime}"/>
          </h:column>
          <h:column>
          <f:facet name="header">
          <h:commandLink value="#{msg.Location_closetime}" action="#{locationFinder.reorder}">
          <f:param name="orderBy" value="closetime"/>
          </h:commandLink>
          </f:facet>
          <h:outputText value="#{location.closetime}"/>
          </h:column>
          <h:column>
          <f:facet name="header"><h:outputText value="#{msg.Action}"/></f:facet>
          <h:commandButton action="#{locationSelector.select}" value="#{locationSelector.buttonLabel}"/>
          </h:column>
          </h:dataTable>


          then in your method locationSelector.select:
          public String select() {
          locationEditor.setInstance(locationFinder.getSelection());
          locationEditor.setNew(false);
          return "editLocation";
          }


          the editLocation string return will be used by the page flow to identfy the page to display: Here is an example from the faces-config.xml file

          <!-- navigation rules for com.devx.res.example.Location -->
          <navigation-rule>
          <navigation-case>
          <from-outcome>editLocation</from-outcome>
          <to-view-id>/editLocation.jsp</to-view-id>
          </navigation-case>
          <navigation-case>
          <from-outcome>selectLocation</from-outcome>
          <to-view-id>/findLocation.jsp</to-view-id>
          </navigation-case>
          <navigation-case>
          <from-outcome>findLocation</from-outcome>
          <to-view-id>/findLocation.jsp</to-view-id>
          </navigation-case>
          </navigation-rule>

          • 2. Re: using commandButton to link to a new window (xhtml)
            max522over

             

            @DataModel
            private List<Location> locationList;
            
            @DataModelSelection
            private Location selectedLocation;



            I needed to quote the
            "<location>"
            with code quotes for you to see it.

            • 3. Re: using commandButton to link to a new window (xhtml)

              The booking demo has an example of this.

              Also discussed in this thread.
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=80815

              Good luck!
              Chris....

              • 4. Re: using commandButton to link to a new window (xhtml)
                kittyk

                Thanks heaps!!! :)