Ohhhhhh! Of course. Thanks Chuck.
Miguel Torres. On 21/08/2012, at 16:29, Chuck Hill <[email protected]> wrote: > > On 2012-08-21, at 1:59 PM, WebObjects TORAcom wrote: > >> Thanks Chuck and Jesse. >> >> I think I understand the term lazy synchronization and it makes totally >> sense. >> >> But, how to handle a case like this: >> >> Three entities and their relationships: >> >> User <-----> Address >> Client <-----> Address >> >> I create a reusable component named EditAddress and use it inside two other >> components: EditUser and EditClient. I would pass the Address object via a >> binding. >> >> In the EditAddress I would use WOTextFields connected to the address' >> parameters: address.country, address.state, etc. >> >> How could I do that with lazy synchronization? > > The same way. Just put this in EditAddress: > > private Address address; > > public void awake() { > super.awake(); > address = null; > } > > public Address exampleValue() { > if (address == null) { > address = (Address) valueForBinding("address"); > } > return address; > } > > public void setAddress(Address newValue) { > if (ERXExtensions.saveDifferent(address(), newValue) { > setValueForBinding(newValue, "address"); > address = newValue; > } > } > > Then use WOTextFields connected to address.country, address.state, etc. > > > Chuck > > > >> >> On 21/08/2012, at 14:22, Chuck Hill <[email protected]> wrote: >> >>> Hi Miguel, >>> >>> On 2012-08-21, at 11:19 AM, WebObjects TORAcom wrote: >>> >>>> Hi List, >>>> >>>> I am trying to implement best practices in our applications, we want to >>>> take control of component's binding syncrhonization. >>>> >>>> First of all I understand that we should override the >>>> synchronizesVariablesWithBindings function like this: >>>> >>>> >>>> public boolean synchronizesVariablesWithBindings() { >>>> return false; >>>> } >>>> >>>> >>>> >>>> But where in the request - response loop should be the better place to >>>> synchronize our bindings, a lot of time ago (years) somewhere in the >>>> internet I found info that recommends Pull binding's values in the >>>> takeValuesFromRequest(WORequest r, WOContext c) method and Push binding's >>>> values in the appendToResponse(WOResponse r, WOContext c). >>>> >>>> I am not sure about that, so we have been working with the automatic >>>> synchronization of our bindings. >>> >>> I usually do lazy synchronization, and only do what I need. Something like >>> this: >>> >>> >>> private String exampleValue; >>> >>> public void awake() { >>> super.awake(); >>> exampleValue = null; >>> } >>> >>> public String exampleValue() { >>> if (exampleValue == null) { >>> exampleValue = stringValueForBinding("exampleValue"); >>> } >>> return exampleValue; >>> } >>> >>> public void setExampleValue(String newValue) { >>> if (ERXExtensions.saveDifferent(exampleValue, newValue) { >>> setValueForBinding(newValue, "exampleValue"); >>> exampleValue = newValue; >>> } >>> } >>> >>> >>> Chuck >>> >>> -- >>> Chuck Hill Senior Consultant / VP Development >>> >>> Practical WebObjects - for developers who want to increase their overall >>> knowledge of WebObjects or who are trying to solve specific problems. >>> http://www.global-village.net/gvc/practical_webobjects >>> >>> >>> >>> >>> >>> >>> >>> >>> >> >> >> >> > > -- > Chuck Hill Senior Consultant / VP Development > > Practical WebObjects - for developers who want to increase their overall > knowledge of WebObjects or who are trying to solve specific problems. > http://www.global-village.net/gvc/practical_webobjects > > > > > > > > >
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
