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
Contributor
singpolyma
Posts: 42
Registered: ‎11-15-2012
My Device: BB10 simulator
My Carrier: WIND
Accepted Solution

Dynamic InvokeQuery

Sorry if you saw this in the other forum, I'm re-posting because I just found this sub-forum and it seems a better fit.

 

I have a ListView and I'm trying to invoke the browser from onTriggered.  I want to create an Invocation with an InvokeQuery that has a uri based the user's list selection.  I tried this:

 

            onTriggered: {
               var selectedItem = dataModel.data(indexPath);
               invokeBrowser.query.uri = selectedItem.link;
               invokeBrowser.trigger("bb.action.OPEN");
            }

            attachedObjects: [
               Invocation {
                  id: invokeBrowser

                  query: InvokeQuery {
                     uri: ""
                  }
               }
            ]

But I just get: InvokeQuery: trying to set sealed property uri

 

What is the right way to do this from QML/JavaScript?

Please use plain text.
Trusted Contributor
georg22
Posts: 245
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: Dynamic InvokeQuery

I dont know if it has changed in Beta4 but in Beta3 it is not possible to change the InvokeQuery.uri dynamically. Once created this value it is read only - unfortunally. 

 

Instead you can call a c++ function to do it. 

 

I use:

void MyApp::invokeBrowser(const QString &uri) {
	InvokeRequest request;
	request.setAction("bb.action.OPEN");
	request.setMimeType("text/html");
	request.setUri(uri);
	const InvokeReply *reply = m_invokeManager->invoke(request);
}

UPDATE:

I just read, that it changed in Beta4.

You can change the Query but you need to call updateQuery() then. I will test it tomorrow.

look inside the documentation

Please use plain text.
Contributor
singpolyma
Posts: 42
Registered: ‎11-15-2012
My Device: BB10 simulator
My Carrier: WIND

Re: Dynamic InvokeQuery

[ Edited ]

Is there a better way than updating the query?  Can I make a new Invocation object on the fly?

 

I can build a C++ wrapper, but I'd rather do it all from QML+JavaScript if possible.

Please use plain text.
Trusted Contributor
georg22
Posts: 245
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: Dynamic InvokeQuery

Following the documentation this code should work, but it does not:

InvokeActionItem {
            id: invokeBrowser
            title: "Browser"
            imageSource: "asset:///images/browser_action.png"
            ActionBar.placement: ActionBarPlacement.OnBar
            
            onTriggered: {
                query.uri = "http://myNewUri.com"
            }
            
            query {
                uri: ""
                mimeType: "text/html"
                invokeActionId: "bb.action.OPEN"
                onQueryChanged: invokeBrowser.query.updateQuery()
              }
            
        }

 The onQueryChanged Signal is unknown...

 

Please use plain text.
Contributor
singpolyma
Posts: 42
Registered: ‎11-15-2012
My Device: BB10 simulator
My Carrier: WIND

Re: Dynamic InvokeQuery

That's still updating the query.

 

I'll try getting Beta4 and using an update-the-query method, then.

Please use plain text.
Contributor
singpolyma
Posts: 42
Registered: ‎11-15-2012
My Device: BB10 simulator
My Carrier: WIND

Re: Dynamic InvokeQuery

Yeah, this does not work, and trying to invoke updateQuery directly fails still under BETA4 (gives an error).

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Dynamic InvokeQuery

I am having an issue with updateQuery such as yours, was this resolved? I am using the gold version.

Please use plain text.
Contributor
singpolyma
Posts: 42
Registered: ‎11-15-2012
My Device: BB10 simulator
My Carrier: WIND

Re: Dynamic InvokeQuery

If it still doesn't work in gold, then they're probably not going to fix it.  I'm considering it a bug in the documentation for now.

 

I haven't yet, but am considering writing a shim in C++ that just gets included into my projects so that I can access a way to do invocations from QML.

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Dynamic InvokeQuery

I'll look into doing the same, it is unfortunate that some of the documentation for this is slightly inaccurate.

Please use plain text.
Contributor
sf18443
Posts: 16
Registered: ‎04-05-2009
My Device: Bold 9930, PlayBook, and Dev Alpha
My Carrier: Verizon Wireless

Re: Dynamic InvokeQuery

This works for invoking the browser in a dynamic fashion :smileyhappy:

InvokeActionItem {
			id: invokeB
			title: "Open in Browser"
			imageSource: "images/globe.png"
			
			query {
				uri: webView.url
				mimeType: "text/html"
				invokeActionId: "bb.action.OPEN"
				onQueryChanged: invokeB.query.updateQuery()
			}
		
		}

 In the code above I am using the InvokeActionItem to open the current webView url in the external browser.

Please use plain text.