Hi Steven,<br><br>Good question.<br><br>Assuming ProposalView is a subclass of WAComponent, you don't really want to be using the same instance repeatedly with different data. This will prevent state backtracking from working properly, because the state is saved/restored at the beginning/end of the request processing.<br>
<br>If ProposalView doesn't have state, it likely doesn't need to be a component at all (you could subclass from WAPresenter in Seaside 3.0 or just create your own class) but even then you probably want to use a new instance each time.<br>
<br>The array approach is a good one and it allows you to return the array in your #children method (which you should be doing for all sub-components). But you may run into the problem that the array gets out of date with the current list of proposals.<br>
<br>Probably the best option is to use a Dictionary (or possibly a WeakDictionary) to map Proposals to ProposalViews. You could implement #children like so:<br><br>children<br> ^ Proposal proposals collect: [ :ea | proposalViews at: ea ifAbsentPut: [ ProposalView new proposal: each; yourself ] ]<br>
<br>Then you can iterate over the proposals in your render method but look up the correct view in the dictionary.<br><br>Julian<br><br><div class="gmail_quote">On Sat, May 1, 2010 at 9:50 AM, Steven Baker <span dir="ltr"><<a href="mailto:steven@stevenrbaker.com">steven@stevenrbaker.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Heya folks,<br>
<br>
I have a small style question. At least, I think it's a style question.<br>
<br>
Consider a ProposalListView which has a single instance variable proposalView, which is an instance of ProposalView. ProposalView has a proposal: accessor. I currently have a small number of proposals (less than 5 at a time) so I do the following:<br>
<br>
ProposalListView renderContentOn: html<br>
html heading: 'Proposals'.<br>
Proposal proposals do: [ :each | html render: (proposalView with: each) ].<br>
<br>
This works to display all of my proposals, but I can't help but feel that I should be pre-populating an array of ProposalViews ahead of time for rendering. I have a gut feeling that tells me I should instead have a proposalViews instance variable containing an array of the views, like so:<br>
<br>
PoposalListView initialize<br>
super initialize.<br>
proposalViews := Array new.<br>
Proposal proposals do: [ :each | proposalViews add: ProposalView new proposal: each ]<br>
<br>
(I've written the code above to simplify the idea; please forgive any errors.)<br>
<br>
Is there a technical reason why my code should be written in one way or the other? Perhaps I'm missing the point entirely, and I should be writing this completely differently?<br>
<br>
Thanks,<br>
<br>
-Steven<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote></div><br>