AC2 server connect autoload issue

Wappler Version : 6.2.1 BETA channel; all files current as of this post
Operating System : mac
Server Model: node
Database Type:
Hosting Type:

Expected behavior

A server connect with Auto Load enabled, should refresh if its dynamic parameters change.

Actual behavior

The server connect does not reload and thus retains its old data

How to reproduce

Here is a trimmed down example of the issue:

On the layout, a server connect…

<dmx-serverconnect id="recipes_search" url="/api/1/4/recipes/recipes" dmx-param:search_text="content.inp_search_text.value" dmx-param:tags="''" dmx-param:limit="10"></dmx-serverconnect>

On a content page, an input for the search_text parameter on the server connect…

 <input  type="search" class="form-control" name="search_text" id="inp_search_text">

When executed, the page loads without errors. If a value is typed into the input, the server connect will execute and return the proper dataset.

If I navigate to another page, and then navigate back to this search, the input is now blank (expected) but if I type a different search term, the previous dataset is displayed. In dev console I can see that the server connect did not reload.

Do you mean after the server connect first autoloads, if you change the input field the server connect is re-performed automatically?

And then if you navigate away and go back, the exact same behaviour doesn’t happen?

Correct

I’ve tested it and it works for me. Is the expression content.inp_search_text.value correct?

1 Like

Yes it is correct, and is working under AC1

Here are 2 videos showing AC1 vs AC2

AC1

AC2

In both you see a clean refresh of the page followed by searches and their results.

Everything works on AC1, but AC2 fails after navigating to another page.

Ideas on how I can help track this down?

ok, the problem is different then I first was thinking. I thought the input change didn’t trigger any load, but it seems it does load. The problem seems to be related to the content that is being replaced on the page after navigation and it needs to bind to a new input which it doesn’t. If you move the serverconnect to the content page, does it then work correctly?

In App Connect 1 it did evaluate all expressions in the app on each update while in App Connect 2 it binds directly to the data and only updates when that data changes. In your case the navigation did remove the input it was listening to and later a new input was created which wasn’t bound. At least I think that is the case, will do some tests to verify and see if I can change the behavior that it binds to the new input after navigation.

Yes, if the sc is moved to the content page, the problem goes away.

@patrick in another instance within my app, the issue occurs even though the server connect is on the content page.

I was hoping to go to production with AC2 this week, should I abandon that or do you think a solution will be found soon?

When does it happen on that other instance? Is it also after navigating or is it another situation there?

Yes, after navigating away but also something different.

If I load this particular page directly, everything works, but then if I navigate away it breaks…this is just like the original report.

However, if the initial page load is on a different page, and then I navigate to this page (internal link) then it is broken from the very beginning.

In this second case, the input is in a modal, if that matters.

Do you have many expressions on the main template page that point to components on some content page? Why do you have them on the template page and not on the content page?

Ken,

You should always put components that are used only on a single content page on the page itself. There is no point of making them global when they are actually local to the content page. Our data pickers have never supported this.

Having them global and also doing a specific binding from the main page to a specific content page will be very error prone because the content page is not always there as it is usually loaded on demand.

So this is bad design - it might have worked on AC1 in a hacky manual way - because AC1 used to continuously reevaluate everything, but in AC2 everything is optimized and bindings are made one time from parent to child so it won’t work.

You should really consider using single responsibility pattern and put things where they belong and let them do as what they are supposed to do. This will make you main page also much lighter and content pages more dedicated.

Hi George,
Apologies if I have misunderstood but if you have global data such as common lists, used throughout multiple pages do you create a separate SC on each page for them? In Ken’s case meals that might be on the page in the video but are likely used elsewhere for tagify elements, dropdowns, lists, menus etc. Are you suggesting those lists (containing the same information) should be reloaded in a separate SC on each content page and no dynamic data should be pulled from the layout at all?

No it is the other way around - the global object refers to a specific data in a child object like content page - which is not always available. So it is difficult to have live binding to something that is not always there…

Ah - I did misunderstand. It’s the parameter link to the child page that’s the issue. Sorry for chirping in…

@mebeingken
Have you tried linking the parameter to a variable on the layout page instead and using the update event of your input to update the variable value? (assuming you don’t tidy it up as George suggested)

Thanks for this George and Patrick. I never really contemplated it, but what you say makes perfect sense. I don’t make a habit of doing it, and will look for any other mis-use across the app.

1 Like

Fixed in Wappler 6.3.1