workshop update

This commit is contained in:
robin 2012-05-24 13:19:11 +08:00
parent 499839d0e6
commit 78503ebd87
7 changed files with 62 additions and 27 deletions

View File

@ -1,18 +0,0 @@
package com.pmease.commons.product;
public class Counter {
private int value;
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public void increase() {
value++;
}
}

View File

@ -0,0 +1,18 @@
package com.pmease.commons.product.components;
public class LoginForm {
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
void onActionFromLogin() {
}
}

View File

@ -0,0 +1,3 @@
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns:p="tapestry:parameter">
<t:actionlink t:id="login">login as ${userName}</t:actionlink>
</t:container>

View File

@ -5,9 +5,8 @@ import java.util.List;
import javax.inject.Inject;
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.services.ComponentSource;
import com.pmease.commons.product.model.Repository;
@ -24,8 +23,11 @@ public class Index {
@Inject
private ComponentSource componentSource;
@InjectComponent
private Zone myZone;
@Inject
private Block emailBlock;
@Inject
private Block loginBlock;
public List<User> getUsers() {
List<User> users = new ArrayList<User>();
@ -73,6 +75,13 @@ public class Index {
user = new User();
user.setName(userName);
user.setEmail(userName + "@pmease.com");
return myZone;
return emailBlock;
}
Object onActionFromLoginLink(String userName) {
user = new User();
user.setName(userName);
user.setEmail(userName + "@pmease.com");
return loginBlock;
}
}

View File

@ -11,20 +11,30 @@
</p:else>
</t:if>
<p:else>
<t:grid source="users" row="user">
<t:grid source="users" row="user" add="action">
<p:nameCell>
<t:pagelink page="index" context="user.name">${user.name}</t:pagelink>
</p:nameCell>
<p:emailCell>
<t:jquery.dialogajaxlink t:id="emailLink" t:dialog="myDialog" t:zone="myZone" context="user.name">open</t:jquery.dialogajaxlink>
</p:emailCell>
<p:actionCell>
<t:jquery.dialogajaxlink t:id="loginLink" t:dialog="myDialog" t:zone="myZone" context="user.name">login</t:jquery.dialogajaxlink>
</p:actionCell>
</t:grid>
</p:else>
</t:if>
<t:jquery.dialog t:clientId="myDialog">
<t:zone t:id="myZone" id="myZone">
${user.email}
</t:zone>
<t:zone id="myZone"></t:zone>
</t:jquery.dialog>
<t:block t:id="emailBlock">
${user.email}
</t:block>
<t:block t:id="loginBlock">
<t:loginForm></t:loginForm>
</t:block>
</body>
</html>

View File

@ -0,0 +1,6 @@
package com.pmease.commons.product.pages;
public class Preference {
}

View File

@ -0,0 +1,7 @@
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns:p="tapestry:parameter">
<head>
<title>Preferences</title>
</head>
<body>
</body>
</html>