Open lolodomo opened 7 years ago
If someone can give me tips on how is handled (and where in the code) the page refresh in the front side of Classic UI, I could take a look and try to fix this issue.
Have a look at SwitchRenderer . The classicui is prerendered on the server side and then the client only polls the newly created html site from the server in a loop
I see that we are using checked="true"
.
Wouldn't it be better to use checked
or checked="checked"
?
http://stackoverflow.com/questions/7851868/whats-the-proper-value-for-a-checked-attribute-of-an-html-checkbox
This bug is really not obvious to reproduce but I finally found how. To reproduce it with the demo sitemap, duplicate the "DemoSwitch" switch from the page "Widget Overview" into the page "Group Demo".
Text label="Group Demo" icon="firstfloor" {
Switch item=Lights mappings=[OFF="All Off"]
Group item=Heating
Group item=Windows
Text item=Temperature
Switch item=DemoSwitch label="Toggle Switch"
}
Text label="Widget Overview" icon="chart" {
Frame label="Binary Widgets" {
Switch item=DemoSwitch label="Toggle Switch"
Switch item=DemoSwitch label="Button Switch" mappings=[ON="On"]
}
Start OH and open the "Widget Overview" page in Classic UI and Basic UI. Use Basic UI to toggle the switch. The change is OK in Classic UI. Now go to the "Group Demo" with Classic UI. Toggle the switch again in Basic UI and you will see that the switch control is not updated in Classic UI.
I checked, there is nothing wrong on the backend, the switch renderer is adjusting the "checked" property as expected.
This might be a bug in frontend when "AsyncLoad" is used (only in a subpage) and you have two switch linked to the same items in 2 different pages.
When in a subpage like "http://192.168.1.x:8080/classicui/app#_1001" and requesting the source code in Firefox, unfortunately I only got the source code of the main page.
In my HTML page, I have:
function AsyncLoad(widgetId) {
WA.Request("app?sitemap=demo&w=" + widgetId, null, -1, true, null);
}
What is WA ? What backend method is finally called by "WA.Request" ?
Ok I found, WebAppServlet.service is called.
Ok, I can confirm that the backend is returning a correct page with or without "checked=true" to the frontend. I don't know how it is then handled by the frontend but there is probably a conflict between the result of 2 different pages in the time: http://192.168.1.x:8080/classicui/app#_1001 and http://192.168.1.x:8080/classicui/app#_1002. Could it be due to a kind of cache in the browser ? Is there a way in the frontend to first clear previous loaded subpages before loading a new siubpage ?
I stop here my analysis, I am not able to fix that, it requires someone having a good frontend knowledge. @resetnow : maybe you can help ?
Just to be clear, when you only access one of the 2 subpages, it is working well. The problem appears as soon as you have opened the 2 subpages.
@lolodomo Thank you for your extensive analysis!
In the long run we would like to get rid of the classicui anyway, in favor for the basicui. So if you find such nasty bugs which afford a lot of work, I think its not worth fixing them in classicui unless you are really really interested in fixing it :). However, if you find "one line fixes" for classicui, feel free to do them.
For a switch element located in a subpage, when the switch value is updated externally, the value of the switch and its icon are updated as expected but the switch control itself is not.
If the switch is in the main page, it is working as expected.