Sub-components woes
Sub-components woes
- Subject: Sub-components woes
- From: Pascal Robert <email@hidden>
- Date: Wed, 14 Nov 2012 20:51:12 -0500
I think I still have to understand a couple of things about components. So I have a component that display a table where each row is coming from a WORepetition. Inside each row, I have a column that calls a stateless sub-component:
<td class="manifest_column">
<wo:BuildManifest selectedProject="$selectedProject" spec="$childSpec.spec" transactions="$~transactionsForSpec(childSpec.spec)" employee="$~employee" rootTransaction="$rootTransaction" />
</td>
In BuildManifest, I have the following code:
<wo:loop list="$spec.parts" item="$partItem">
<wo:if condition="$spec.isLotInventory">
<wo:str value="$partItem.serialNumber" />
</wo:if>
<wo:textfield value="$qtyForSynthManifestTransaction" size="4" numberformat="#" style="padding: 0px; margin: 0px;" />
<wo:if condition="$spec.isLotInventory">
<wo:AjaxSubmitButton updateContainerID="$spec.inventoryNumber" value="SM" action="$~createSyntheticTransactionFromPart(partItem)" /> <br />
</wo:if>
<wo:else>
<wo:AjaxSubmitButton updateContainerID="$spec.inventoryNumber" value="SM" action="$~createSyntheticTransactionFromSpec()" /> </wo:else>
</wo:loop>
qtyForSynthManifestTransaction is a Integer, with a setter and a getter in BuildManifest.java. Now, if I submit the form, setQtyForSynthManifestTransaction is called with the value that I submitted, that's fine, but the setter is called a second time, and it sets the value to null, so when createSyntheticTransactionFromSpec or createSyntheticTransactionFromPart are finally called, the quantity is set to null!
I have put a breakpoint on the awake method in BuildManifest, and awake() is called as many time as I have rows in my table. So for example, if I had 10 rows, BuildManifest is called 10 times. After the first awake, setQtyForSynthManifestTransaction is called to the correct value, after than awake() is called a couple of times and boum! setQtyForSynthManifestTransaction is called with a null value!
So what's the trick?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden