techknight Well-Known Member Licensed User Longtime User May 13, 2026 #1 I haven't performed a deep level of searching to see if this already exists, but I figured I would ask here in case someone knows: Is there code/tool that would allow me to take layouts and convert them into JSON for dynamically loading them at runtime from a server? I am trying to build a dynamically configurable UI in the app which would be fed from a server that also includes control events that would also need to be handled at runtime vs compiled, and I Was wondering if this is possible or if it was done already. I would like to do something such as JSON instead of just passing a BAL file down from the server because the goal is to eventually use the same layout data and parse it in Node/React to render out a similar UI to keep things cross-platform. Thanks!
I haven't performed a deep level of searching to see if this already exists, but I figured I would ask here in case someone knows: Is there code/tool that would allow me to take layouts and convert them into JSON for dynamically loading them at runtime from a server? I am trying to build a dynamically configurable UI in the app which would be fed from a server that also includes control events that would also need to be handled at runtime vs compiled, and I Was wondering if this is possible or if it was done already. I would like to do something such as JSON instead of just passing a BAL file down from the server because the goal is to eventually use the same layout data and parse it in Node/React to render out a similar UI to keep things cross-platform. Thanks!
techknight Well-Known Member Licensed User Longtime User May 13, 2026 #2 Edit: Just saw BalConverter and its had a lot of updates, I might be able to use that to be able to bring in JSON, and run it in the LoadLayout function to at least use the layout engine which responds to scaling, anchors, etc. Upvote 0
Edit: Just saw BalConverter and its had a lot of updates, I might be able to use that to be able to bring in JSON, and run it in the LoadLayout function to at least use the layout engine which responds to scaling, anchors, etc.
Erel B4X founder Staff member Licensed User Longtime User May 14, 2026 #3 A bit related: https://www.b4x.com/android/forum/t...onize-json-and-binary-layouts.167398/#content It is however problematic to load dynamic layout files. During compilation the compiler expects to find the layout files and it reads their headers. And secondly the layouts are loaded from File.DirAssets, which is read-only. Upvote 0
A bit related: https://www.b4x.com/android/forum/t...onize-json-and-binary-layouts.167398/#content It is however problematic to load dynamic layout files. During compilation the compiler expects to find the layout files and it reads their headers. And secondly the layouts are loaded from File.DirAssets, which is read-only.
Sandman Expert Licensed User Longtime User May 14, 2026 #4 Erel said: It is however problematic to load dynamic layout files. Click to expand... That makes me curious... You say it's problematic, which doesn't mean impossible. Is it actually possible..? Upvote 0
Erel said: It is however problematic to load dynamic layout files. Click to expand... That makes me curious... You say it's problematic, which doesn't mean impossible. Is it actually possible..?
Erel B4X founder Staff member Licensed User Longtime User May 14, 2026 #5 In the current version - no, because of the input folder being limited to File.DirAssets. This can of course be more flexible in the future, however it will require some additional changes as the compiler expects the layouts to be available during compilation. Upvote 0
In the current version - no, because of the input folder being limited to File.DirAssets. This can of course be more flexible in the future, however it will require some additional changes as the compiler expects the layouts to be available during compilation.
techknight Well-Known Member Licensed User Longtime User May 14, 2026 #6 Ahh, darn. So this wont work for what I am trying to do. My goal was have a server-configurable layout where I can make UI changes without needing to re-release the apps to do so. Upvote 0
Ahh, darn. So this wont work for what I am trying to do. My goal was have a server-configurable layout where I can make UI changes without needing to re-release the apps to do so.
aeric Expert Licensed User Longtime User May 15, 2026 #7 Maybe this is why some developers prefer to use WebView to load webpages from the server. Upvote 0
hatzisn Expert Licensed User Longtime User May 17, 2026 #8 techknight said: Ahh, darn. So this wont work for what I am trying to do. My goal was have a server-configurable layout where I can make UI changes without needing to re-release the apps to do so. Click to expand... You can create an empty layout and then you can do the following: You can get Root panel dimensions (B4XPages) and have a json file you will create from a B4J app to be downloaded from your server. The json file will be a JSON array of JSON objects. Each JSON object will have six keys: type, name, top, left, width, height. The last four will be fractions in the range of values 0 to 1 which will be multiplied with Root.Width and Root.Height in order to get position and dimensions of each view. Then you will create the environment adding the views and associate the tag of each view with name which will be a value you will check to execute the apropriate code. For XUI views add the tag in {XUIView}.mBase.Tag because their tag represents the classes themselves. Last edited: May 17, 2026 Upvote 0
techknight said: Ahh, darn. So this wont work for what I am trying to do. My goal was have a server-configurable layout where I can make UI changes without needing to re-release the apps to do so. Click to expand... You can create an empty layout and then you can do the following: You can get Root panel dimensions (B4XPages) and have a json file you will create from a B4J app to be downloaded from your server. The json file will be a JSON array of JSON objects. Each JSON object will have six keys: type, name, top, left, width, height. The last four will be fractions in the range of values 0 to 1 which will be multiplied with Root.Width and Root.Height in order to get position and dimensions of each view. Then you will create the environment adding the views and associate the tag of each view with name which will be a value you will check to execute the apropriate code. For XUI views add the tag in {XUIView}.mBase.Tag because their tag represents the classes themselves.