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

Native Development

Reply
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Changing the root page in Cascades

Hi everyone,

 

Can someone please demonstrate how to change the root page/scene/document?  Forgive me, I'm sure that I'm using the wrong terminology.  I'm trying to switch over from Java development.

 

Right now, my application has a log-in page.  When the user is authenticated, I open a new page and I save the  received authentication token in QSettings.  When the user exits the application and comes back in, I've put logic in place to skip the log-in screen if the token is set:

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {

	QString orgId = getQSettingFor("orgId", "false");

	QmlDocument *qml;

	if(orgId == "false"){
		qml = QmlDocument::create("asset:///main.qml").parent(this);
	} else {
		qml = QmlDocument::create("asset:///networks.qml").parent(this);
	}

	qml->setContextProperty("app", this);

	AbstractPane *root = qml->createRootObject<AbstractPane>();

	// set created root object as a scene
	app->setScene(root);
}

 

When the user signs out of the application (as opposed to exiting), I destroy the QSetting and I want to replace the current page with the log-in page.  How can I do this?  Is this a recommended practice?

 

Ultimately, I plan to use a Navigation Pane for all pages AFTER the log-in screen (with multiple stacked screens).  It's just this one UI flow that I'm  having trouble with.

 

Thanks!

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Changing the root page in Cascades

[ Edited ]

If you are planning on using the navigationPane anyway later on why not set the first page as the registration Page/login page then push the next page when registration/login occurs?

 

The scenario you've described lends itself to doing it this way from the start as you want navigation to take you back to the login page.

 

If you didn't want to do this then I could understand the desire for the registration/login page to be separate from the natural flow.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Changing the root page in Cascades

I'll try that out, thanks BBSJdev.  And I'll hide the back button to limit the user from going back to the login page (unless they explicitly sign out).

 

With a NavigationPane, must I define all of my pages within the single QML file?  Or is it possible to set up the NavigationPane structure, and provide references to other separate QML files?  I'm just curious.

 

Thanks.

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Changing the root page in Cascades

[ Edited ]

It's up to you they can be defined in a single page, however the more complex the page becomes the more sense it makes to separate the pages out into separate QML pages.

 

[Edit] It's a legitimate navigation to return to the login screen so my recommendation would be to not hide the back button instead change the back icon and text to represent 'sign out'.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.