Beginner |
|
Joined: Mon Jun 25, 2007 11:57 pm Posts: 28
|
Hi,
Does anybody know what is the "best practice" way of initializing elements in a Set.
Scenario is that class contains a set which is to be used to display (just the first record) to the screen. However it is possible that this set may be empty and therefore when i go to access the first element using : setelements[0] the page does not display correctly.
Workaround i have used is that when parent object is initialised, i check to see if the set contains an element. If it doesn't i create one and insert it into the set.
Is there a more elegant way of doing this? Such as an attribute of the <set> element that tells us to create an object by default? Or has anyone got any better suggestions?
Thanks a lot.
John
|
|