Re: Sub-components woes
Re: Sub-components woes
- Subject: Re: Sub-components woes
- From: Ramsey Gurley <email@hidden>
- Date: Thu, 15 Nov 2012 10:05:54 -0700
On Nov 15, 2012, at 5:12 AM, Pascal Robert wrote:
>
> Le 2012-11-14 à 21:07, Johnny Miller <email@hidden> a écrit :
>
>> I too have trouble with this stuff all the time...
>>
>> if it is a stateless components where does qtyForSynthManifestTransaction get stored?
>
> It's not stored anywhere except in the component, I use this variable in a method in the component and in the text field, and that's it.
That would be the problem. All ivars must be reset in the reset() method because only one instance of the stateless component will be created. The stateless component will be reused in the loop and even across sessions.
https://developer.apple.com/legacy/mac/library/documentation/InternetWeb/Reference/WO542Reference/com/webobjects/appserver/WOComponent.html#isStateless()
The reset method is called at each stage, takeValues, invoke, and append, so you can't get a value in takeValues stage and then use it in the invokeAction stage. If you change the component to a non synchronizing component, it should work. With a non sync you get a component instance per repetition like you would a normal WOComponent.
Non sync is slower than stateless because you create lots of instance tho. If you can stash the value somewhere outside the component (an EO) during takeValues, and then retrieve it in invokeAction, it should work too.
Ramsey
>
>> Do you have automatic binding turned off as well?
>
> Yes. And I inherit from ERXStatelessComponent
>
>>
>> On Nov 14, 2012, at 3:51 PM, Pascal Robert <email@hidden> wrote:
>>
>>> 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
>>
>
>
> _______________________________________________
> 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
_______________________________________________
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