5 Replies Latest reply on Aug 20, 2007 2:39 PM by Tim

    how to use s:button to execute action first before jump to v

    Tim Newbie

      Is there a way to for action on s:button first before it jumps to the view page with params?
      This is JSF code:

      <rich:dataTable values="#{locations}" var="location"...>
      ...
      <a:commandLink value="Remove" action="#{applicationHome.deleteLocation}"/>
      ...
      </rich:dataTable>
       <s:button value="Add New Location"
       action="#{applicationHome.addLocation}"
       view="/LocationEdit.xhtml"
       propagation="join"
       >
       <f:param name="locationId" value="#{applicationHome.location.id}"/>
       </s:button>
      

      I need new location added to current application before edit it in LocationEdit.xhtml
      Application.addLocation() is defined as followed
       @DataModelSelection("locations")
       private Location location;
       public Location getLocation() { return location; }
      
       public void deleteLocation()
       {
       getInstance().getLocations().remove(location);
       getEntityManager().remove(location);
       location = null;
       }
      
       public void addLocation()
       {
       location = new Location();
       getInstance().getLocations().add(location);
       getEntityManager().persist(location);
       }
      


      location is DataModelSelection to be used within dataTable but also be used when added new. If I use the edit panel in the same page, that will be no problem, but I have to jump to new page to do it, that same code won't work because addLocation() didn't get called before #{applicationHome.location.id} assignment.