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
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha
Accepted Solution

Monitoring web page progress is not working...!

Hi!

 

     I am trying to set the label text while the webview is loading...But the sample code given in the documentation is not working...! The sample code is given below.

 

Container {
                Label {
                    id: statusLabel
                    leftMargin: 10
                    text: "No webpage yet."
                }
                WebView {
                    id: myWebView
                    url: "http://developer.blackberry.com"
                    onLoadingChanged: {
                       console.debug("onLoadingChanged is called..........................");//printed in console
                       //below statements are not changing the text of the label.
                        if (loadRequest.status == WebView.LoadStartedStatus) {
                            statusLabel.setText("Load started.")
                        } else if (loadRequest.status == WebView.LoadSucceededStatus) {
                            statusLabel.setText("Load finished.")
                        } else if (loadRequest.status == WebView.LoadFailedStatus) {
                            statusLabel.setText("Load failed.")
                        }
                    }
                }
            }

 I have tried with statusLabel.text, but that one also not working....! If anyone knows plz reply me..!

 

-Regards

 

 Raju

- Raju
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Monitoring web page progress is not working...!

check with the debuger if the event is fired and received.
also check the status value and if it matches the queried constants.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Monitoring web page progress is not working...!

The documentation at https://developer.blackberry.com/cascades/reference/bb__cascades__webview.html#loadingchanged suggests you are using the wrong constants.  See if using, for example, WebLoadStatus.Started works any better...


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha

Re: Monitoring web page progress is not working...!

Thanks peter !!! It worked well.

 

But in the documentation of webview( https://developer.blackberry.com/cascades/documentation/ui/webview/loadingpage.html (in monitoring web page progress section) ), they gave wrong sample. I request those people to correct it!

This code works well.

 

onLoadingChanged: {
    if (loadRequest.status == WebLoadStatus.Started) {
        statusLabel.setText("Load started.")
    }
    else if (loadRequest.status == WebLoadStatus.Succeeded) {
        statusLabel.setText("Load finished.")
    }
    else if (loadRequest.status == WebLoadStatus.Failed) {
        statusLabel.setText("Load failed.")
    }
}

 Thank you!!!

 

- Raju