webtier@glassfish.java.net

<f:ajax> with h:commmandButton

From: <webtier_at_javadesktop.org>
Date: Mon, 19 Oct 2009 20:14:46 PDT

Hello.
I'm trying to create a dynamic table (similar with FlexTable from GWT): have a table grid, and under the table grid a text box and an add button. When the user enters a text and hits add the text has to be added to the table. My code is partially working (first time a text is added it does not appear in the table, the when the second text is added the first one appears in the table, and so on). Here is my code that does this:
     <h:panelGrid id ="teamsGrid" columns = '2' border='1' >
        <f:facet name="header">
          <h:outputText value="Team"/>
          <h:outputText value="Actions"/>
        </f:facet>
        <c:choose>
                <c:when test="#{leagueCreator.numberOfTeams == 0}" >
                  <h:outputText value ="You currently do not have any team for this league"/>
                </c:when>
                <c:otherwise>
                  <c:forEach items="#{leagueCreator.teams}" var="team" begin="0">
                    <h:outputText value="#{team.name}"/>
                  </c:forEach>
                </c:otherwise>
        </c:choose>
      </h:panelGrid>
      
      <h:inputText id="teamToAdd" value="#{leagueCreator.teamToAdd}">
         <f:ajax event="blur" listener="#{leagueCreator.saveNewTeamToModel}"/>
      </h:inputText>
      
      <h:commandButton id ="addTeamToLeague" value="add" actionListener="#{leagueCreator.addTeam}">
        <f:ajax event="action" render="teamsGrid teamToAdd"/>
      </h:commandButton>

The problem is that the panelGrid is refreshed for the blur event of inputText, but I only add the team to the panel on click, and then the panel does not refresh. I am new to JSF 2.0 so maybe I am missing something.

Thanks,
George
[Message sent by forum member 'capitanu' (goprean_at_yahoo.com)]

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