01-23-2013 06:02 PM
Hi,
I load a page in Cascade WebView. Should I close the WebView before opening another page?
01-23-2013 10:33 PM
I believe it's supposed to be safe to reuse the WebView. But please do report back here with any specific problems. ![]()
https://developer.blackberry.com/cascades/document
01-24-2013 03:50 PM
Hi,
I want to open a new page when url change in Cascade WebView. I am getting an error
"Context: Failed to find target node with id 17"
Is there any mistake i did while opening a new page?
My Code Sample:
MyApp::MyApp(bb::cascades::Application *app)
: QObject(app){
qmlRegisterType<PostHttp>("Network.PostHttp", 1, 0, "PostHttp");
//add a QTimer class as a qml type
qmlRegisterType<QTimer>("my.library", 1, 0, "QTimer");
qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("securityApp", this);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
app->setScene(root);
}
void MyApp::onUrlChangedEvent(QString url){
QStringList myStringList = url.split("|");
if(myStringList.length()>2){
if(myStringList.at(0).startsWith("empcmd:")){
createPageFromCpp();
}
else{
QString xmlData = myStringList.at(myStringList.length()-1);
ReadXMLDOM *readXMLDOM =new ReadXMLDOM(this);
readXMLDOM->readResponseXML(xmlData);
}
}
}
void MyApp::createPageFromCpp(){
// Create the root page and the button
Page* root =newPage;
Button* myButton = Button::create("My Rotating Button");
// Create a rotation animation and associate it with the button
RotateTransition* rotation = RotateTransition::create(myButton)
.toAngleZ(360)
.duration(350);
// value to detect any errors.boolres = QObject::connect(myButton, SIGNAL(clicked()), rotation, SLOT(play()));
Q_ASSERT(res);
// Indicate that the variable res isn't used in the rest of the app, to prevent// a compiler warning
Q_UNUSED(res);
// Set the content of the page and display it
root->setContent(myButton);
Application::instance()->setScene(root);
}
01-24-2013 04:30 PM - edited 01-24-2013 04:32 PM
I find it hard to follow the code as pasted (there's a clipboard with a "C" on it in the rich text editor; it allows you to paste code better).
However, at a glance, I do not see where you are passing a URL to the WebView, let alone using setURL to re-use the webview. Additionally, I see no reason here to be creating multiple WebViews.
https://developer.blackberry.com/cascades/referenc
You will, of course, want to destroy the WebView when your app closes, but until then you haven't given any good reason to "close" it.