2016년 12월 26일 월요일

Run 'when page.initialize' when returning to a page


When a page first loads 'when page.initialize' is executed. I have a check in this block to see if a users details appear in a local TinyDB (used as cache).
If the cache is blank a login button is displayed for the user. If the user opts to login they are passed back to a login page and the page they were on is stored in TinyDB. Once the user has successfully logged in they will be passed back to the page they came from.

This all works fine except for the displaying of the user name. If the user logins in before going to any of the other pages their username is shown and a logout button is displayed instead of a login button. If however the user accesses a page before logging in when they are returned to the page the user name and logout button are not shown. This seems to be because the  'when page.initialize' block is not called when returning to the page after logging in. 

I have tried closing the page when the login button is clicked in hopes that reopening the page would re-execute the 'when page.initialize' block but this has not worked. I have included code form one such page in hopes someone might be able to point me in the right direction.


--
Remove the blocks set LogoutButton.Text to "Logout >" ?

-- 
Could you clarify how you would expect that to make a difference?

I am asking as this is required to set the correct text on the button and on the welcome greeting.

(Admittedly the name of the button is not great as it started as a logout button but is now multi purpose, I will get this renamed.)

-- 
Instead of all the switching screens, why not just check if the user has a login and name in TinyDB in Screen1 then log them in or set them as guest, then branch to the next screen?
If you are going to open a screen more than once you should use a screen manager.
manager.aia

-- 
The idea was that we wanted users to be able to move through the app wihout sigining in and only sigining in if they actually needed to do something.

I have resolved the issue now though there was an issue on the login page whereby the ordering of one of the code blocks was incorrect. In essence I was opening the new page before passing calling the valuse from TinyDB.

Thanks fro your replies though :)

-- 


댓글 없음:

댓글 쓰기