webtier@glassfish.java.net

Re: <f:ajax> with h:commmandButton

From: <webtier_at_javadesktop.org>
Date: Tue, 20 Oct 2009 19:23:37 PDT

Thanks for the response. The reason why I had that blur event was so that the value entered would be saved to the model, so when I was clicking (originally a h:graphicImage) the value entered would have been already saved to the model. I did not know of the execute option. This code does what I originally wanted to achieve:
   <div id="createTeams" style="display:none">
      <h:panelGrid id ="teamsGrid" columns = '2' border='1' >
        <f:facet name="header">
          <h:outputText value="Team"/>
          <h:outputText value="Actions"/>
        </f:facet>
        
        <ui:fragment rendered="#{leagueCreator.numberOfTeams == 0}">
          <h:outputText value ="You currently do not have any team for this league"/>
        </ui:fragment>
        
        <ui:fragment rendered="#{leagueCreator.numberOfTeams > 0}">
          <ui:repeat value="#{leagueCreator.teams}" var="team">
              <h:outputText value="#{team.name}"/>
              <h:outputText value="delete action and edit action"/>
          </ui:repeat>
        </ui:fragment>
      </h:panelGrid>
      
      <h:inputText id="teamToAdd" value="#{leagueCreator.teamToAdd}" />
               
     <h:commandButton id ="addTeamToLeague" value="add">
        <f:ajax event="click" execute="@this teamToAdd" render="teamsGrid teamErrorMessage teamToAdd" listener="#{leagueCreator.addTeam}"/>
      </h:commandButton>
      
      <h:outputText id="teamErrorMessage" value="#{leagueCreator.teamErrorMessage}" />
    
    </div>
[Message sent by forum member 'capitanu' (goprean_at_yahoo.com)]

http://forums.java.net/jive/thread.jspa?messageID=368722