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
Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

need advice about getting data from web

Hello devs.I am a newbie in developer world so please give advice.

I am trying to make a simple app with cascades. I've done all my qml and everything is working ok so far. This is where i am stuck. I want to make a page that gets data from the web and actually from http://betognosis.com/pamestoixima/index.php

I think it is a simple text page. Then i want all this data to appear in my qml page as a table but only some of the elements. not all of the data of each row. just the first 7.

What should i do? or what should i study/read before trying to do that myself?

Please use plain text.
Contributor
djmbb
Posts: 30
Registered: ‎06-14-2012
My Device: Simulator
My Carrier: all

Re: need advice about getting data from web

Hello.

 

You can get the data from the web via c++ and provide it to the qml when it arrives eg.

 

QNetworkAccessManager::get("http://betognosis.com/pamestoixima/index.php")

Youll also need to implement a slot to receive the data when it arrives and connect it to the signal from the QNetworkAccessManager that gets emitted when its ready.

 

eg

 connect(_NetAccMan,  SIGNAL(finished(QNetworkReply*)), SLOT(slotReplyFinished(QNetworkReply* )));

 

 

 

void MyNetworkClass::slotReplyFinished(QNetworkReply* )

{

     QString Text = QString::fromUtf8(Dev->readAll());

     // now pass Text to QML if necessary

}

 

 

see

https://developer.blackberry.com/cascades/reference/QNetworkAccessManager.html

 

Best Wishes,

Declan

Please use plain text.
Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: need advice about getting data from web

Man thanks for the reply. I'll give it a try. although an example should be better. lol. 

I imagined something like TableView or many ListViews....It is much more complicated. Or i say this because i am new.Anyway thanks. I ll be back for instructions.Thanks again.

Please use plain text.
Contributor
djmbb
Posts: 30
Registered: ‎06-14-2012
My Device: Simulator
My Carrier: all

Re: need advice about getting data from web

It is complicated. Im not sure if theres a good way to get the date more directly in qml.

If I understand you have to download a whole page (as opposed to each item in a listview being separately downloadable which might be much simpler) , and then provide various parts of this to qml in a List or Table.

My way would to create a controller (C++ class) that gets the complete data/page from the webpage when necessary ..see eg http://doc.qt.nokia.com/4.7/network-download-main-cpp.html

Then this class can provide the data to the Qml page, containig eg a ListView or TableView its controlls.eg via context properties or context items

 

(1) If I were you I would first write an example that displays  (dummy) data the way you want it in a ListView.

(2) When tahts working I would try to get the data from a C++ class (see also http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html)

(3) When thats working I would get theC++ class to get the data from the web via QNetworkAccesssManager.

 

-If- each elemnet of the listview were available as a separate url you could simple refer to this url in the delagate of the listview item (completely in QML)..see eg

http://doc.qt.nokia.com/4.7/qml-listview.html

 

Im presuming the Nokia versions work similarlyn to the blackberry versions here (I find it easier to find doc at the Nokia site)

Please use plain text.
Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: need advice about getting data from web

Hello again. I watched the webcast and at the end i asked about my thing. They told me i should wait for the next release of cascades.ListView will have many more options and i should be able to accomplish what i want in a much more easier way. Thanks mate for all the advice anyway.

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: need advice about getting data from web

See also the knowledge base articles on DataModel:

http://supportforums.blackberry.com/t5/Cascades-Development-Knowledge/Using-your-own-DataModel/ta-p/...

and then

http://supportforums.blackberry.com/t5/Cascades-Development-Knowledge/Using-a-Custom-DataModel-to-Fi...

 

The second article describes exactly how to to what you want in R4 by using your own DataModel.  The second article might be easier to understand if you first read the first article.

 

Stuart

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: need advice about getting data from web

Does this answer all of your questions?

If so, please mark a solution.

If not, how can we help?

 

Stuart

Please use plain text.
Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: need advice about getting data from web

actually i am a little bit lost and confused. I was told during the webcast that  the next release of native 10skd will help me. so i am waiting for it and then i ll get back . Thanks though!

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: need advice about getting data from web

Please use plain text.
Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha
My Carrier: Vodafone GR

Re: need advice about getting data from web

guys thanks for all the responses. i can't figure it out yet.... lol....

and the link is not reliable. it was down for about two weeks so i cannot depent on it.

this was very helpful actually in case of newbies like me.

https://developer.blackberry.com/cascades/documentation/device_platform/networking/tutorial_http_com...

 

Anyway, an rss feed sample code or a more complex web xml feed would be nice. we like sample codes and you know it! anyway, thanks again for all the answers you gave me. i ll be back!

Please use plain text.