Page variable object properties

Hi, I just found out how to add a variable as an object on the page, which is really cool, but it would be nice if Wappler could detect the object and parse out the properties. I can bind to the variable like so:

<dmx-value id="modal_users_title" dmx-bind:value="{ &quot;name&quot;: &quot;Create New User&quot; }"></dmx-value>

But the “name” property doesn’t show in the expression selector, only ‘value’. It’s a low priority issue, since I can add it manually:

<h5 class="modal-title">{{modal_users_title.value.name}}</h5>

:slight_smile:

So you are initializing a variable with JSON object? Why?

Because I wanted to use the var names like variable categories to control dynamic layouts, etc. One var could have multiple properties to control a modal layout, and another var more properties for some other layout section on the same page, etc. I didn’t want 20+ variables on a page in a flat list.

Got your point. What you need to use is a Data Store. Not a variable in that case. Or a JSON Data Store.

Also, if the param count is 20+, I would recommend to keep them in DB and get the list from there (if it suits your application).

I don’t need server side storage to create variables on the client side. I just wanted to use client side variables, and not have to load static server data, especially since I’m focusing on a PWA app.

The Data Store component is available in App Connect i.e. it’s a client side component.

Oh, you mean like local storage? But isn’t that persisted? I’ll look into it anyhow, thanks.

You can choose to store the Data Store data in the local storage or in a browser session.

Honestly it still seems a bit much. I don’t need to store anything. Local storage or session storage is more activity than I need, which is simple objects on a client. I don’t want to clutter local or session storage with dynamic scratch data. Setting an object to a variable was good enough, which I did already.

You can take a look at JSON Data Source. Keep all your params in a JSON file.
This should be much easier to maintain and use.

@sid, thanks for trying to help, but as I said, I do not want (or need) to store anything. :wink:

JSON Data Source does not store anything.

It implies storing static data in a JSON file on the server side to load to the client side, no? :wink:

Yes. Just like you store JSON data inside a variable on a file that is on server side. :man_shrugging:

Yes, and loading of stored data just for client side variables is what I’m trying to avoid. :wink:

I don’t see much cost to loading stored JSON. And it allows you to use the UI.

The variable has not been designed to be used as an object, which is why it does not have a “schema” which can be used in the UI.

I am not sure how useful this will be, since JSON Data Source is already present. I personally have never seen this use case of client side objects.

If Wappler team does implement this, it would then work something like the 'SET VALUE" server action step, which allows to define what “type” of data the variable has, and allows setting a schema.

FYI: You can vote for your own feature request. :slightly_smiling_face:

1 Like

When creating Progressive Web Apps they can operate offline. I don’t want to add too much reliance on server side stuff when I don’t have to, that’s why. :wink: Besides, it’s like binding parts of a client side page to JavaScript objects, which is a common practice in normal web development in some cases.

I store objects in variables from time to time but with the expected caveat of not being able to access them via UI. Not a big nuisance tbh.

Wappler could probably add a schema detection and generation feature so they show up in the UI when you add an object but I suspect that not many people will use this.

3 Likes