Input value logic from page data, not refreshing On Change

I have an input box, and I want to filter the input. In the On Change event handler, I have logic to set a Page Data property to the value I want.

This is a simplified example -

image

The value logic gets the value from the Page Data variable -

image

The On Change logic updates the Page Data property, and the value logic runs (see prints below), but the input value doesn’t change -

image

Why isn’t the value of the input box getting overwritten?

Thanks,
Tim

This is what I got:
https://www.backendless.us/api/files/ui-builder/containers/support/index.html?page=timtest

The value is overwritten. The only difference is the Value Logic uses databinding:
UI Builder - ConsoleDemo - Backendless 2023-08-30 12-30-31

Changing the value logic to databinding also worked for me. I didn’t think there was a difference between databinding and codeless logic. Have you made a video that describes the difference?

Tim

I believe the difference is in the timing when it is executed. You change the underlying data model in the On Change event. That change triggers a re-render of the UI, this is when all bindable properties are re-evaluated.

If you have logic for a property it occurs at a different timing than if you have pure data binding. I am not entirely clear when exactly it happens, but it clearly has an impact on the execution. This is something @vladimir-upirov can clarify.

Thanks @mark-piller!

Would you recommend using data binding over codeless to assign values to inputs, etc.? I have been using codeless to keep things consistent, but this issue has me re-thinking.

Tim

You are welcome, Tim. If the data comes straight from the data model, use plain data binding every time. However, keep in mind that the data binding is bi-directional. So if you have a mapping in place, it will work for both updating the data model from the UI component and updating the UI component from the data model.

That is interesting. Am I understanding you correctly that by data binding the value logic of an input, any changes to the input from the UI will change the data model? What happens if there is logic in On Change? Does On Change run after the data binding, updating the data model again?

Tim

We explain it in the docs (I am sure I described it in multiple videos too):
https://backendless.com/docs/uibuilder/ui_data_binding.html#bidirectional-data-binding

Yes

That logic runs only when the value of the input is changed by the user.

Thanks, @mark-piller.

Have a great holiday weekend!