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
Highlighted
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later
Accepted Solution

Call a server function after page loads

I have a qml page, i want to open this qml page

 

once this qml page is opened, it opens with activatyindicator...i want to launc a function, where i go server side retrieve data and show them in place of activity indicator..it takes a well 5 seconds to retrieve data.

 

how can this be done

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

QmlDocument *qml = QmlDocument::create("asset:///Tabs.qml").parent(this);

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

	if (!qml->hasErrors()) {
		qml->setContextProperty("app", this);
	}
	Application::instance()->setScene(root);

 

 

this is how i open the page. i want the qml opened now...

after its opened, and showing.i want to go to server side and bring a list..and replace the page with that data brought.

 

how can this be done?

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

void ApplicationUI::login() {
	QmlDocument *qml = QmlDocument::create("asset:///Tabs.qml").parent(this);


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

	if (!qml->hasErrors()) {
		qml->setContextProperty("alkhaliji", this);
	}
	ActivityIndicator* dataLoaderIndicator  = root->findChild<ActivityIndicator*>("dataLoadIndicator");
	dataLoaderIndicator->start();
	Application::instance()->setScene(root);
}

 

 

this is what i did

 

page loads with this

 

Page {
           
            
            Container {
                ActivityIndicator {
                    objectName: "dataLoadIndicator"
                    horizontalAlignment: HorizontalAlignment.Center
                    verticalAlignment: VerticalAlignment.Center
                    preferredWidth: 720
                    preferredHeight: 720
                }
                
            }
        }

 

 

how can i now replace activityindicator, with a data i will go and  bring from server side?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Call a server function after page loads

Take a look at this, which does exactly what you are asking for...

 

http://developer.blackberry.com/native/documentation/cascades/ui/lists/asynch_data.html

 

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

I downloaded that application

 

I get error 

 

bb::cascades::QmlDocument: error when loading QML from:   QUrl( "asset:///main.qml" )  
--- errors:  (asset:///main.qml:2:1: module "custom" is not installed)
bb::cascades::QmlDocument:createRootObject document is not loaded or has errors, can't create root

 

 

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

asynchronous data loading app
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Call a server function after page loads

This sounds like the custom library for is not being registered in the applicatioui.cpp.


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

why should there be an error in app put up for ducmentation?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Call a server function after page loads

@babakar I built and ran this one recently, make sure you have setup your project correctly and followed the documentation.

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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Call a server function after page loads

Here is what I did bro, you think its the right way to go?

 

 attachedObjects: [
            MyTimer {
                id: timer
                interval: 1
                onTimeout: {
                   
                    app.login2();
                    timer.stop();
                }
            }
        ]
        
        onCreationCompleted: {
            progressIndicator.active = true;
            timer.start();
    
        }

 

Basically i did a timer. after page creation complete...i call the timer... after 0.0001 seconds my function is called ( login2) ...

what does login2 do? i call a server function....retrieve data..might take 5 - 6 seconds.. ( this 5 - 6 seconds there is original acitivyt indicator on page)..

 

after i get data from server, i do this

 

				    ActivityIndicator *mActivityIndicator = root->findChild<ActivityIndicator*>("activityIndicator");
				    mActivityIndicator->stop();

 

And i show my data instead, the list.