Flex Repeater: how to bind instances properties

I’m trying to build a recipe editor with a combination of Flex Repeaters. My recipe is made up of steps, each having its own parameters. Recipe values come from a query on the database, which query I’d like to be unique across the view lifecycle. At the same time I need to break the editor into groups, one group for each step, but I wouldn’t like to query my database so many times as the number of my steps, one time per group.
Therefore I created a view called RecipeEditor with a Flex Repeater, which repeats a SingleStepEditor view as many times as the number of steps. Each SingleStepEditor is a Flex Repeater itself: it should receive the result of the main big query - which I bound to a custom property in the root container of the main view - and build the list of parameters pertaining to the step through a transform. What I can’t manage to do is to pass the main big query to the Flex Repeaters.I’ve tried with messaging on a property changed event script on the big query custom property but with no success - and moreover I’m not sure it’s a best practice. Maybe session properties is the correct way?

Any suggestion is appreciated.

Thanks, regards

This sounds similar to something that I’ve been working on.

How often are the values in the DB changing? Are they only changing when you are writing to them with this editor?

If they only change when someone changes them via editor, you can add a message that gets sent on edit, which tells all other sessions that have the same recipe open to update their values, instead of relying on a query firing every x seconds. Helps to reduce the load, so this is what I use.

The way I handle my case is to transform the data from the big query into a list of dictionaries, with the normal expected keys for the first flex repeater. While I’m doing this transform, I then also add an ‘Instances’ key to each of the dictionaries in the list, which contains another list of dictionaries, all with the expected keys/data for the second level flex repeater of that step.

You can then either put this list of dictionaries into a separate session variable or just keep it on the original session variable. You then bind the first flex repeater’s Instances property to this session variable.

The view that contains the second flex repeater will then need a view param called ‘Instances’. This should be bound to said view’s Flex Repeater’s Instances prop.

Once that is complete, it should work as you expect. Each time the query fires it will rebuild the list of dictionaries, and both levels of flex repeater should get their needed data.

I don’t understand what you mean by this. Why would the query be unique? I would expect the query to be parametrized and for the parameters to change based on the step, but it sounds like you want the entire query to change, which doesn’t seem correct to me.

I would build your SingleStepEditor view with a parametrized query (Ideally a Named Query). Then in the Flex Repeater you can send those parameters through to the embedded view.

If you do like that, each SingleStepEditor will fire its query against the server to fetch the parameters it needs and that’s just what I want to avoid. Suppose you have 200 steps: each time you open the view you load your server with 200 queries. However, since the recipe params table is normalized, you just need one query to fetch all recipe parameters at once. Moreover if you need to refresh the recipe data from server, if you have just one query you need to run just one refreshBinding and all SingleStepEditor instances will get updated accordingly.

Hi ryan, this afternoon I did just what you are suggesting and it works. I’m wondering if in Perspective you have anything like Vision CellUpdate bindings which could be of help.

What’s the use case? Are you trying to have the query refresh when you enter something in a field? I’m not super familiar with vision equivalents in perspective. I’ve also not really used repeaters in Vision.

Edit: Just looked these up in the documentation, not sure of any equivalent in perspective. Are you trying to avoid rebuilding the entire dataset for 1 value update?

As I wrote in my reply to irose, my aim is an editor that loads SQL Server as little as possible, above all while fetching data. Therefore I’d like to define a unique query anywhere (session, main view, …), the result of which must be passed to all the sub-editors by using bindings if possible. The idea to use a flex repeater to instantiate each single step editor is due to its very nice feature of building UIs based on queries: as a consequence if some steps/parameters add to the recipe in the future, I’ll have non need to edit the view again, because query+flexrepeater will do the magic.

Single session property with parameterized named query binding and transform script will probably be your best bet for minimal load on your SQL server, since you would be only running 1 query, instead of however many per view/repeater.

For even less load, don’t have the query fire outside of initial data load (When you’ve selected which recipe to view/edit) or unless something else signals via message that there has been a change to the data, either from you editing via your interface or otherwise.

If you don’t mind me asking, why are you so concerned with SQL load? 5 or 6 queries per second per session with several sessions won’t really hurt most mid to enterprise level systems. If your poll rate is something even lower then its even less of a concern. This project doesn’t seem like it would have many sessions open at once anyways.

Most of our databases are running around 10/s, spiking to 30-80/s depending on certain applications, but I know through unfortunate circumstances it can handle ~400-500/s before it starts to fail, even then it can trudge through until ~800/s, which is when we start seeing complete loss of comms.

Yes, you are right, SQL Server can do much more work then a bunch of some hundreds of queries. But for me it’s a matter of design:

  • query as less as possible
  • single source of truth
  • binding refresh with just one command
  • don’t waste bandwith in case your project has still to grow