This content has been marked as final. Show 12 replies
The dynamic "Object" data type is not bindable.
Create your own class and implement properties you need on it.
I suppose I used the wrong word "object".
These are not dynamic objects. I have an instance of a class called ProjectDetail. I call a webservice that returns my data and I update an instance of that class _projectDetail = .......
I am using a component that is a wrapper of a textInput field that is bound to _projectDetail.PPLocation
When my UI component is updated, the screen shows the changes but my instance never gets the new data. _projectDetail.PPLocation still has the old value in it.
Still not clear.
The WebService result returns
A handler takes the event.result and does:
_projectDetail.PPLocation = event.result.Whatever.PPLocation.
Is that correct so far?
but you say that _projectDetail.PPLocation does not have the value from event.result? But the bound IPETextInput DOES show the value from event.result?
I don't see how that could be. It sounds backwards but that is what you said.
Sorry for not being clear. Let me explain it better . . .
My webservice fetches some data and updates the values of _projectDetail one of which is PPLocation.
I use that value in a component that is a wrapper around TextInput. See below.
When the component updates the value, it should update the value here as well _projectDetail.PPLocation so if I want to send the data back to the webservice to update the back end db . . . But the component is not updating _projectDetail.PPLocation.
I'm trying to figure out why this isn't happening. I thought if _projectDetail is declared as bindable and the class for the text input component was also declared as bindable all would update bidirectionally so to speak.
Is there a reason that doesn't happen?
Ah, no. Binding is one direction only. Event if your IPETextInput is dispatching the binding event, your _projectDetail does not have a listener for it. Binding is really just an automatically generated event handling framework..
You can use BindingUtils to set up a binding the other way. I prefer to have all my ui components use the change event to call into a single function, where I can update the model (projectDetail ) and do things like conditionally enable/disable tool buttons and menu options. I have the event pass the function the property name and the value.
A change event can directly update the model as well.
That makes sense. Actually, I have been trying to get my application to listen to events dispatched from the component. The component dispatches events for each IPEControl, see below . I was hoping to somehow listen for all the events in one listener then using a case statement pull the event.target.id to determine which control it is and pull the data manually. Is there a way to listen to all events from the component? If I have 50 fields I don't want to have 50 listeners . . .
I tried the following code: this.addEventListener( "valueCommit", commitValues );
In my component this is how events get dispatched . . .
Where editableControl is the textInput field . . .
Hmm, that might work, but you don't really want all events from all fields do you? That would be zillions.
I would just have all the fields call an onChange handler within the component. I would have that handler dispatch a single bubbling event, with some unique name, like IPEChangeEvent. I would put a single listener on the application(or whererver _projectdetail is in scope):
You have two ways to get the data into the handler. One is a custom Event, in which you can actually pass the data. This is not hard and there are examples in the docs. The other way is to expose public properties on the IPE component. In this case, your internal change function woudl set the public property values, say:
sLastPropertyName and sLastPropertyValue.
You can then access those values through the event.target reference.
I'm only processing the fields that use this control so it's not horrible yet I do not like having to add an entry to my case statement every time I add a field.
Can you shed some light on using the custom events. I've seen a couple of examples yet I am not sure how to pass the specific data that I need. I need to pass the text value plus the variable name to update in my object. The idea being I would like to have one function be able to update all fields with out having to use a case statement for each field.
Yes, as I said, pass the property name and the value into the change handler.
You use bracket notation to set the value, not a switch statement. Below is some example code.
I actually do a lot more in that onChange handler, but I deleted it for clarity. The last line in the handler updates my main data model.
Also, the ComboBoxSelect component is an extended ComboBox that sets its selectedIndex based on the dataField and selectedValue properties.
Thank you so very much!!! Sometimes it takes a bit of code to get through my thick skull.
That makes perfect sense. As always you are amazing!