When form submission occurs Tapestry5 do not look at binding that was used during render phase. Instead it use ValueEncoder to restore object from String id. If you do not provide an ValueEncoder (I think you don't, do you?) tapestry will use default. Default ValueEncoder use java serialization mechanism for conversion from and to object. So when your form is submitted _new_ objects are deserialized from serialization data. Those object are not the same objects as in actorList (equals will return true, but == will return false).

To solve the problem you need to provide your own ValueEncoder. Something similar to follow.

       <tr t:type="Loop" source="displayActorList" value="actor" 
encoder="encoder">
         <td><t:checkbox t:value="actor.enabled"/></td>
         <td>${actor.name}</td>
       </tr>

public ValueEncoder getEncoder() {
return new ValueEncoder() {
public String toClient(Object value) {
// TODO: indexOf is not very effective operation
return String.valueOf(getDisplayActorList().indexOf(value));
}

public Object toValue(String clientValue) {
return getDisplayActorList().get(Integer.parseInt(clientValue));
}
};
}

With code above you do not ever need to persist actorList, because it is restored from getStoredActorList every request.

Tim Sawyer пишет:
Hi Folks,

I have a list of checkboxes on a page:

        <tr t:type="Loop" source="displayActorList" value="actor">
          <td><t:checkbox t:value="actor.enabled"/></td>
          <td>${actor.name}</td>
        </tr>

The method to return the displayActorList is
  public List<Actor> getDisplayActorList()
  {
    if (this.getActorList() == null)
    {
      this.setActorList(this.getStoredActorList());
    }

    return this.getActorList();
  }

where actor list is persistant.

  @Persist private List<Actor> actorList;

The problem I'm having is that after submitting the page with my checkbox list in, the actor list is not being updated with the new values. Can anyone suggest what I could be doing wrong?

Thanks,

Tim.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to