You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Marcus Schmidke <Ma...@Schmidke.de> on 2007/09/05 23:20:18 UTC

T5: Troubles editing a list of objects

Hello all,

the following might be an absolute beginner's error, but since I'm an
absolute beginner, I probably am allowed to have this kind of problem
...

I'm trying to edit a list of values:

class Value {
  String name;
  String text;
  boolean used;
  ... getters ...
  ... setters ...
}

class Page {
  private @Persist List<Value> values;
  private Value value; //iterator

  ... getters / setters ...
  ... some code to initialize values list ...
}

And the html code:
    	<t:form>
    	<table border="1">
    	  <t:loop source="values" value="value">
    	  	<tr>
    	  		<td>${value.name}</td>
    	  		<td><input t:type="textfield" size="100" value="value.text" /></td>
    	  		<td><input t:type="checkbox" value="value.used" /></td>
    	  	</tr>
    	  </t:loop>
    	</table>
    	<t:submit />
    	</t:form>

The page is rendered perfectly. On Submit, the new values are passed
into some Value objects.

But: those Value objects are serialized/deserialized instances of the
original Value objects. While the List still holds the original Value
objects, only copies of them get modified. Result is that my program
code (which works on the list) never sees the modified versions, and
on re-rendering, the old values are displayed again.

What am I doing wrong??


Marcus.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Troubles editing a list of objects

Posted by Marcus Schmidke <Ma...@Schmidke.de>.
Nick,

that was really simple ... and works fine, thank you.

But I must admit that I don't understand what I'm doing here (even
reading the documentation about loop.volatile did not help me, sorry).
What is volatile's default for?

I understood so far:

Having volatile=default causes serialization of the displayed objects
during render. To where? I suppose it's that long long long long
invisible field at the beginning of the form?

Ok.

Later, on request processing, the objects get deserialized from the
form, and then, the input values are applied.

But what is the intended way to deal with those deserialized objects?
They are referenced from nowhere in my code. How can I access the
changed values?

Marcus.


2007/9/6, Nick Westgate <ni...@key-planning.co.jp>:
> Use:
> <t:loop source="values" value="value" t:volatile="true">

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Troubles editing a list of objects

Posted by Nick Westgate <ni...@key-planning.co.jp>.
Use:
<t:loop source="values" value="value" t:volatile="true">

Cheers,
Nick.


Marcus Schmidke wrote:
> Hello all,
> 
> the following might be an absolute beginner's error, but since I'm an
> absolute beginner, I probably am allowed to have this kind of problem
> ...
> 
> I'm trying to edit a list of values:
> 
> class Value {
>   String name;
>   String text;
>   boolean used;
>   ... getters ...
>   ... setters ...
> }
> 
> class Page {
>   private @Persist List<Value> values;
>   private Value value; //iterator
> 
>   ... getters / setters ...
>   ... some code to initialize values list ...
> }
> 
> And the html code:
>     	<t:form>
>     	<table border="1">
>     	  <t:loop source="values" value="value">
>     	  	<tr>
>     	  		<td>${value.name}</td>
>     	  		<td><input t:type="textfield" size="100" value="value.text" /></td>
>     	  		<td><input t:type="checkbox" value="value.used" /></td>
>     	  	</tr>
>     	  </t:loop>
>     	</table>
>     	<t:submit />
>     	</t:form>
> 
> The page is rendered perfectly. On Submit, the new values are passed
> into some Value objects.
> 
> But: those Value objects are serialized/deserialized instances of the
> original Value objects. While the List still holds the original Value
> objects, only copies of them get modified. Result is that my program
> code (which works on the list) never sees the modified versions, and
> on re-rendering, the old values are displayed again.
> 
> What am I doing wrong??
> 
> 
> Marcus.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org