It looks like the sample demonstrates the same issues I run into. Triggering a view change on a user action and triggering a view change on the URL change event causes the view to be "activated" twice.
The problem is here
Code: Select all
evtroutine handling(#sys_web.URLChanged)
* Browser URL has changed, so activate the employee specified
if (#sys_web.URLParameters<Employee> *IsNot *null)
#Com_owner.Activate( #sys_web.URLParameters<Employee>.Value )
else
#Com_owner.Activate( "" )
endif
endroutine
evtroutine handling(#List.ItemClick)
#Com_owner.Activate( #xEmployeeIdentification )
* User has clicked an item, so add it to the history
#Sys_Web.History.Add( ("Employee=&1").Substitute( #xEmployeeIdentification ) )
endroutine
You can see this in the chrome dev tools by monitoring the network traffic. On the initial load, everything is fine. But select an employee and two requests are triggered because the activate is caused twice.
Code: Select all
mthroutine name(Activate) help('Update the page to show a specific employee number') access(*PRIVATE)
define_map for(*INPUT) class(#xEmployeeIdentification) name(#EmployeeNumber)
* If an employee number is supplied...
if (#EmployeeNumber <> "")
* Position to the right one in the list
#Com_owner.PositionTo( #EmployeeNumber )
* Update the detailer to show the employee
#EmployeeDetails.ShowEmployee( #xEmployeeIdentification )
#EmployeeDetails.Opacity := 100
#EmployeeDetails.Enabled := true
endif
endroutine
Curious how other folks are solving this problem.
It would be nice to have a built in mechanism to handle issues like this. Much like a "router" in Angular, React or Ember. While VLWeb works great without it, it breaks the User's concept of how a web application should work. Meaning they can hit the back button and lose all state and navigation of where they were in the app.