Hey what I do is the following:

1. You have to initialize the collection somewhere. Yes, pageBeginRender is
ok ( well, sorry for the tapestry gurus, but I have also done it that way ).
And dont have to initialize it in the rewind phase.
2. What I do is to "hide" the collection in the form. Oh, what I did
sometime was to persist the collection property ( tap 3) but now I prefer to
do this.  Items in the collection should implement serializable interface.
In your code I would do:

<form jwcid="[EMAIL PROTECTED]" listener="listener:saveFormHistory">
<span jwcid="@Hidden" value="ognl:items"/>
...
<tr jwcid="@For" source="ognl:items" value="ognl:item" element="tr">
<td><span jwcid="@Insert" value="ognl:item.question.text">Question
Text</span></td>
<td><input jwcid="@TextField" value="ognl:item.answerText"/></td>
</tr>

3. I dont pass parameters to the submit method, I think you dont need it.
4. With this, in the submit or in the form listener you should have access
to the updated collection.

Tell me if this works for you.

Gabriel H. Lozano M.


On 11/14/06, Srinivas Yermal <[EMAIL PROTECTED]> wrote:

Thanks so much for the response. I will try out the
DefaultPrimaryKeyConverter and InvokeListener options.
My comments inline -


> Anyway.. about your code: obviously, I can't tell you which is best.
> But I think you don't have to pass your items as a parameter to the
> listener method. Instead, the form fields (in this case, the
> collection) will be bound to an instance variable in your page object.
> Maybe you should drop that parameters attribute in the @Submit.
> But you have to make sure the list is not null during rewind, and has
> the right length, so you have to refill it before the rewind, and the
> values will be overwritten during rewind.


I tried not passing them as parameter initially, but that didnt work.
Setting the parameter was something that I guessed might work, but it
doesnot. I have also made sure that the items object is not null during
rewind phase by removing the if condition in pageBeginRender, but all it
does is gives me the same items without change to any values. On a side
note, actually it might turn out be a overhead in large pages if I have to
run the query again just for the rewind phase. Moreover, the collection is
serialised and is available from the form, isnt it? Shouldnt it be
deserialized?

I have another observation to add. I have a method that returns the
PropertySelectionModel for each item depending on the item. This is
required
for the dropdowns for each item. The dropdown values depend on the item.
During the rewind phase this method gets called and I get proper objects
with proper values. But when the submit listener gets called I still get a
null collection or the old collection. Is there any other method like say
renderComponent of the page that I have to implement?

The listener method that is called will be the one referenced in the
> @Submit component. In your case, the one referenced in the @Form is
> never called, I think. So you might want to lose on of those two, to
> avoid confusion.


Actually, both the listeners get called. The form listener gets invoked
last. I have both the listeners just as an experiment to see if I get a
non-null proper collection in any listener at all.
Thank you very much for the advice. Will continue trying and see where
this
goes. Its just that I am running out of time.
Regards,
Srini.


Reply via email to