Component defaults not available to logic?

Binding to the state of input components (at least Toggle, Checkbox, and Input) doesn’t seem to take place OnPageEntry.
UI
UI

Preview

These components have default settings (Checked for Toggle and Checkbox, Default Value for Input), but these show up only on the UI component; are not available to logic. The workaround is to set the bound values (via Page Data properties) which sets the components also, but this is poor/dangerous coding in that the default is set in two different places.

Is there a reason the default value for input components is not available to the logic?

Are you asking why the default values do not trigger data binding events?

Hmmm … perhaps we’re at a ‘learning moment’ here. I though binding linked components to logic (usually though Page Data properties) when the property name is entered into the logic (Check State Logic, Value Logic, etc.)

Are you indicating some triggering event (On Change, On Click, Set, etc.) must occur to cause that binding to take place? And On Page Enter is not such a triggering event?

Hello @Jim_Austin

Could we create a particular example of this issue, with a minimum of logic and results - actual and expected? I ask for this because I little messed up with where the problem is located.

Also, I do not clearly understand, where you try to print values from your first message. If you do it at ‘On Page Enter’ - that might be caused by not ready components(they don’t mounted when this handler running)

The test code URL is https://fleettop.backendless.app/api/files/ui-builder/containers/Test/index.html?page=toggle_default-test

The code is simple (‘toggle_state’, etc. are the bindings):

(app ID: 5DDDD554-906E-7866-FF50-BB0CA2C93300)

Your comment “If you do it at ‘On Page Enter’ - that might be caused by not ready components…” is likely the clue; that is where the values are printed and displayed in Alert message.

‘On Page Enter’ is the point where the logic needs to make ‘decisions’ based on the default settings. What has to happen to make the component default setting (toggle is the specific default needed) available to the logic?

Any defaults you set here (see below) will not trigger any of the logic:

The logic is triggered only when:

  • Page is initially loaded or refreshed/unloaded
  • User interacts with the UI
  • A data model is changed (which must happen through logic)

Does it answer your question?

Regards,
Mark

My question is about the Default Value setting for the Input component,
Default value
and Checked setting for the Toggle component:
Checked

I don’t see such a setting for Block, or the need for one.
What am I missing?

Block doesn’t have “Default Value” because it doesn’t make sense to have one. A block is something that contains other UI elements and controls their positioning.

We seem to have wandered far from my original question about the Toggle component ‘Checked’ setting and the Input component ‘Default Value’ setting (not Block) getting bound to logic: Checked State Logic (for Toggle component) or Value Logic (for Input component) binding to a Page Data property.

Dima said it can’t happen in ‘On Page Enter’

as my test code is trying to do.
My question: If not when the page opens, where?

My main point is that none of the default settings (styles, values, etc) are bound to logic. The default settings translate to static values being embedded in the resulting HTML. It is plain HTML that is loaded and rendered by a browser. Logic is not triggered by static data/settings in HTML.

So when you configure your toggle’s default state as Checked, none of the logic event handlers will do anything about it.

Thanks Mark, this is what I needed. I’ve been thinking of a component default value as an app value (available to the app logic); not the UI Builder/Codeless design.