You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by pipothebit <pi...@yahoo.es> on 2006/10/20 16:39:35 UTC
@PropertySelection inside a @For
Hi,
I have a problem with this convination. When I use a simple
PropertySelection getter / setter it's work fine but when I use a @Form
component to render many options to select it not works.
My Java code:
public abstract UserPage extends BasePage implements
PageBeginRenderListener {
...
@Persist
public abstract User getUser();
public abstract void setUser(User user);
...
public RolSelectionModel getRolSelectionModel() throws Exception {
InitialContext initialContext = new InitialContext();
IRoleServiceRemote iRoleServiceRemote = (IRoleServiceRemote)
initialContext.lookup("app/RoleService/remote");
return new RoleSelectionModel(iRoleServiceRemote.findAll());
}
public void addRolAction() throws Exception {
getUser().getRoles().add(new Role());
}
...
public void submitAction() throws Exception {
// after add one role the user property have 1 role
// but data are not initialized
for (Rol role : getUser().getRoles()) {
System.out.println("id: " + rol.getId());
System.out.println("name: " + rol.getName());
}
...
public class RolSelectionModel implements IPropertySelectionModel,
Serializable {
private List<Rol> roles;
public RolSelectionModel(List<Rol> roles) {
this.roles = roles;
}
public int getOptionCount() {
return roles.size();
}
public Object getOption(int index) {
return roles.get(index);
}
public String getLabel(int index) {
return roles.get(index).getCodigo();
}
public String getValue(int index) {
return String.valueOf(roles.get(index).getId());
}
public Object translateValue(String value) {
for (Rol rol : roles) {
if (rol.getId() == Integer.valueOf(value)) {
return rol;
}
}
return null;
}
}
HTML template code:
...
<tr jwcid="@For" source="ognl:user.roles" value="ognl:rol" element="tr"
index="ognl:index">
<td colspan="2">
<nobr>
<select jwcid="@PropertySelection" model="ognl:rolSelectionModel"
value="ognl:rol">
</select>
<a href="#" jwcid="@LinkSubmit" listener="listener:delRolAction"
parameters="ognl:{index}">del</a>
</nobr>
</td>
</tr>
...
UserPage.page code:
...
<page-specification>
<property name="rol" />
<property name="index" initial-value="0" />
</page-specification>
I don't have idea why this dont't work, can someone help me?
Very than you.
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto.
http://es.voice.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org