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: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Dynamic browser invocation in qml

I have a button that should open a website.

The URL of the website is created on runtime.

 

If i create the invocation without a uri property i get an error message and it does nothing.

When i create it with something and try to change the uri on runtime it opens "something" instead.

 

 attachedObjects: [
         Invocation {
                    id: linkInvocation
                    query: InvokeQuery {
                        mimeType: "text/html"
                        uri: "http://www.isec7.com"
                        invokeActionId: "bb.action.OPEN"
                    }
                }
    ]

 i try to trigger it with another URI like this:

 

linkInvocation.query.uri = buttonInput.linkUrl;
linkInvocation.trigger("bb.action.OPEN");

 How can i open a dynamic url?

----------------------------------------------------------
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
Highlighted
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Dynamic browser invocation in qml

[ Edited ]

Try updating the query after making changes:

https://developer.blackberry.com/cascades/reference/bb__cascades__invokequery.html#updatequery


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dynamic browser invocation in qml

i did find that as well, just forgot to submit the edit to the post.
does not work, unfortunately.

currently implementing it in a c++ utility class, but it would be nice to know how it works in qml anyhow.
----------------------------------------------------------
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
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Dynamic browser invocation in qml

[ Edited ]

Have you seen this post? And the post next to it.

Seems it's neccessary to wait until onArmed is called.

http://supportforums.blackberry.com/t5/Cascades-Development/Dynamic-InvokeQuery/m-p/2084381#M10730

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dynamic browser invocation in qml

that sounds reasonable, i'll try it.
----------------------------------------------------------
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
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Dynamic browser invocation in qml

I was just going to say that I had figured that out...

Not only that though... but the original code with "query: InvokeQuery" gives me an error saying the query object can't be changed. Not sure if it's spurious or not.

What I was doing is just "query { ... properties and handlers here}" without either the colon (though the example code shows it) or the colon plus InvokeQuery class.

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
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dynamic browser invocation in qml

[ Edited ]

It is working, but i am not completely content with it as the invocation gives a lot of errors in the debug console, as mentioned in the other thread.

peter, do you have a solution that avoids this? could you share it?

 

edit:

the utility method in c++ works without any errors (as the invocation is created with the correct values), i'll use that until the qml way works without spamming my debug log.

----------------------------------------------------------
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
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Dynamic browser invocation in qml

This one is working for me. You could adjust as suitable given your situation. For example, I don't know if you actually needed the uri set initially, since with what you showed it isn't ever being used, but perhaps you have another way of triggering this elsewhere.

 

    actions: [
        ActionItem {
            title: "Test Action"
            onTriggered: {
                // will auto-invoke after re-arming
                linkInvocation.query.uri = "http://engcorp.com";
            }
        }
    ]

    attachedObjects: [
        Invocation {
            id: linkInvocation
            property bool auto_trigger: false
            query {
                uri: "http://peterhansen.ca"

                onUriChanged: {
                    linkInvocation.query.updateQuery();
                }
            }

            onArmed: {
                // don't auto-trigger on initial setup
                if (auto_trigger)
                    trigger("bb.action.OPEN");
                auto_trigger = true;    // allow re-arming to auto-trigger
            }
        }
    ]

 


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
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dynamic browser invocation in qml

when i copy and paste your code i get errors in my qml:
No default property defined for Invocation
----------------------------------------------------------
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
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Dynamic browser invocation in qml

Very strange... works without issue here.

I have this in page loaded dynamically through a ComponentDefinition. Maybe that's the difference?

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!