Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Trusted Contributor
bertho_joris
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780

Login - Logout Scenario

[ Edited ]

The scenario :

 

MAIN MENU -> LOGIN FORM -> Login Process -> If successful, move to USER MENU

 

When the process of checking username and password, I will get the data the user through the process from the server and will return the ID of the user. And I will make that ID as a parameter to perform the next process in the user menu. When it comes to stage Login Process I'll pass a parameter that will be used in the user menu.

 

bb.pushScreen('USERMENU.html','USER',{'ID': userid});

If seen in the above code, I am calling user menu.html file with the ID parameter (the result of the server submission)

 

And I put this code in index.html

 

ondomready: function(element, id, params) {
if (params) {
     userid = params.ID
}
}

The above code will make the data passing this ID on the page anywhere.

 

But for this case, I want to remove this parameter shipping when i clicked LOGOUT menu. For example, in the User Menu and I click LOGOUT will call back the login form using :

 

bb.pushScreen('MAINMENU.html','MAINMENU');

What should I make for such a case? Is the return to manufacturing of the new parameter is NULL?

 

bb.pushScreen('MAINMENU.html','MAINMENU',{'ID': null});

 

Or how about a good way?

Regards,
Bertho
Developer
nathanpc
Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha

Re: Login - Logout Scenario

The best way to do logins and logouts is by using the HTML5 localStorage API to store the parameter, which will stay in the device and will even be able to accessed by your application after the device was rebooted.

 

To login just store the ID inside the localStorage. To logout just change the ID to null, or delete the localStorage instance. That's what I use across all my applications, it's simple and works perfectly.

If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter
Trusted Contributor
bertho_joris
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780

Re: Login - Logout Scenario

I want to use the default function bbUI yourself for this. Actually unthinkable to use localStorage, only if the default bbUI this is no way to cases like the above? Perhaps no one ever used it for the same case

Regards,
Bertho
Developer
nathanpc
Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha

Re: Login - Logout Scenario

I've used localStorage with bbUI.js in almost all my projects. That's the best approach to it, the bbUI.js screen push params variable is just if you want to pass simple information between screens and shouldn't be used for information that needs to be global in the app.
If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter