VLWeb Deep Linking Sample
Posted: Thu Mar 08, 2018 4:07 am
Looking through the Deep Linking Sample trying to find a way to improve my own "View Navigation" mechanisms.
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
In the List.ItemClick event the view gets activated AND it is added to the history. When the history is added, the URLChanged event fires, activating the view a second time.
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.
The only way I have been able to solve this is to keep track of what "view" I am currently displaying. Then in the URL Changed event, If the URL view does not match my current view, I allow the view from the URL, BUT DO NOT ADD IT BACK TO THE HISTORY.
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.
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.