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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
raju_winit
Posts: 61
Registered: ‎05-21-2012
My Carrier: Aircel
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
Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
My Carrier: O2 Germany

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
Please use plain text.
Developer
peter9477
Posts: 5,616
Registered: ‎12-08-2010
My Carrier: none

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 -- (PlayBook 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!
Please use plain text.
Developer
raju_winit
Posts: 61
Registered: ‎05-21-2012
My Carrier: Aircel

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
Please use plain text.