Hi Luke,

Luke Vanderfluit wrote:
> Hi.
> 
> I have a master detail setup.
> 
> When I click the master item and the details are editable in the detail 
> section, 
> I need to bind them (the object's properties) to the relevant textinput 
> fields 
> so that when I save the object, the details I've entered go to the server.
> 
> I have a setter that sets the object in the detail when it's selected in the 
> master.
> 
> public function set premise(p:Premise):void {
>               _premise = p;                   
>       if (_premise.premiseId != 0) { //not a new premise
>               //do stuff
>          }
>       doBinding();
> }
> 
> //bind to text input fields
> 
> public function doBinding():void {
>       BindingUtils.bindProperty(_premise,"name",premiseName,"text");
>       BindingUtils.bindProperty(_premise,"street",premiseStreet,"text");
>       BindingUtils.bindProperty(_premise,"suburb",premiseSuburb,"text");
>       BindingUtils.bindProperty(_premise,"state",premiseState,"text");
>       BindingUtils.bindProperty(_premise,"postcode",premisePostcode,"text");
> }
> 
> However the binding only works for the first premise, then when I select a 
> premise in the master, this selection and consecutive selections set the 
> premises in the array to all be the same premise.
> 
> 
> Any suggestions?


I imagine that it's not setting to be all in the array the same premise 
but it still has the old premise object bound to the input field object.

To try and clarify; i think your "old" premise objects are still bound 
to the input fields, therefore all previously bound premise objects are 
being updated still.

One option might be to use bindSetter instead. I guess the downside is 
you need to write all those accessors.
FWIW I've never used this function so not sure if its right or not. Just 
a guess really.

doBinding(){
   BindingUtils.bindSetter(pName, premiseName, "text");
}

//[Bindable]  //?? dunno if need Bindable here or not?
public function get pName():String{
   return _premise.name;
}
public function set pName(s:String):void{
   _premise.name = s;
}

HTH.
cheers,
  - shaun

Reply via email to