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
Posts: 93
Registered: ‎08-18-2011
My Device: 9550
My Carrier: At&T

How to close Cascade WebView?

Hi,

 

I load a page in Cascade WebView. Should I close the WebView before opening another page?

 

 

Thanks,

Shwarup Biswas
Developer
Posts: 110
Registered: ‎10-22-2011
My Device: PlayBook, Bold 9650, Dev Alpha A
My Carrier: Sprint

Re: How to close Cascade WebView?

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/documentation/ui/webview/loadingwebcontent.html may be a very useful starting point, if you've not already found it.



Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Like this post too! Smiley Very Happy
Highlighted
Developer
Posts: 93
Registered: ‎08-18-2011
My Device: 9550
My Carrier: At&T

Re: How to close Cascade WebView?

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);

 }

 

 

Thanks,

Shwarup Biswas
Developer
Posts: 110
Registered: ‎10-22-2011
My Device: PlayBook, Bold 9650, Dev Alpha A
My Carrier: Sprint

Re: How to close Cascade WebView?

[ Edited ]

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/reference/bb__cascades__webview.html might be helpful so you know what WebView supports.

 

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.



Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Like this post too! Smiley Very Happy