Skip to content

Commit

Permalink
Streamline the Games page use of Ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
hlship committed Sep 7, 2011
1 parent ded1941 commit a4fd6e2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
18 changes: 9 additions & 9 deletions src/main/java/t5presentations/introapp/pages/Games.java
@@ -1,8 +1,7 @@
package t5presentations.introapp.pages;

import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
import t5presentations.introapp.entities.BoardGame;
Expand All @@ -14,19 +13,20 @@ public class Games {
private Session session;

@Property
private BoardGame game, selectedGame;
private BoardGame game;

@InjectComponent
private Zone gameDetail;

@SuppressWarnings("rawtypes")
@Inject
private Block gameDetailContent;

public List getGames() {
return session.createCriteria(BoardGame.class).list();
}

Object onActionFromSelectGame(BoardGame game) {
selectedGame = game;
Object onActionFromSelectGame(BoardGame selectedGame) {
game = selectedGame;

return gameDetail.getBody();
return gameDetailContent;
}

}
40 changes: 23 additions & 17 deletions src/main/webapp/Games.tml
@@ -1,26 +1,32 @@
<html t:type="layout" title="Game List" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
xmlns:p="tapestry:parameter">

<div class="left-column">
<div class="left-column">
<t:grid source="games" include="title,creator" row="game">
<p:titleCell>
<t:actionLink t:id="selectGame" context="game" zone="gameDetail">
${game.title}
</t:actionLink>
</p:titleCell>
<p:titleCell>
<t:actionlink t:id="selectGame" zone="gameDetail" context="game">
${game.title}</t:actionlink>
</p:titleCell>

</t:grid>
</div>

<div class="right-column">
</div>

<div class="right-column">
<t:zone id="gameDetail" t:id="gameDetail">
<t:if test="selectedGame">
<strong>${selectedGame.title}</strong>
by
<strong>${selectedGame.creator}</strong>
<br />
For ${selectedGame.minPlayers} - ${selectedGame.maxPlayers} players.
</t:if>

</t:zone>
</div>
</div>


<t:block id="gameDetailContent">
<strong>${game.title}</strong>
by
<strong>${game.creator}</strong>
<br/>
For ${game.minPlayers} - ${game.maxPlayers} players.

</t:block>


</html>

0 comments on commit a4fd6e2

Please sign in to comment.