TypeError: Result of Expression

TypeError: Result of expression 'blackberry.push.openBISPushListener' [undefined] is not a function.

This code is directly from the API documentation.  So what is wrong?



    
        
        Push Listener

    
    
        
bbwp "c:\applications\devBlog\devBlog.zip" /g 

will suffice

Tags: BlackBerry Developers

Similar Questions

  • TypeError: Result of expression 'item' [undefined] is not an object.

    Hello

    I can userstand the good way to spend the ListItemData given to a page entry. In the example ListView generated here is what is generated.

    import bb.cascades 1.2
    NavigationPane {
        id: nav
        Page {
            Container {
                ListView {
                    dataModel: XmlDataModel {
                        source: "data.xml"
                    }
                    onTriggered: {
                        if (indexPath.length > 1) {
                            var chosenItem = dataModel.data(indexPath);
                            var contentpage = itemPageDefinition.createObject();
                            contentpage.itemPageTitle = chosenItem.name
                            nav.push(contentpage);
                        }
                    }
                    accessibility.name: "Listing"
                }
            }
        }
        attachedObjects: [
            ComponentDefinition {
                id: itemPageDefinition
                source: "ItemPage.qml"
            }
        ]
        onPopTransitionEnded: {
            page.destroy();
        }
    }
    
    import bb.cascades 1.2
    Page {
        property alias itemPageTitle: titlebar.title
        titleBar: TitleBar {
            id: titlebar
        }
        Container {
        }
    }
    

    If I wanted to copy the input data to the push page, then I can do that.

    import bb.cascades 1.2
    NavigationPane {
        id: nav
        Page {
            Container {
                ListView {
                    dataModel: XmlDataModel {
                        source: "data.xml"
                    }
                    onTriggered: {
                        if (indexPath.length > 1) {
                            var chosenItem = dataModel.data(indexPath);
                            var contentpage = itemPageDefinition.createObject();
                            contentpage.item = chosenItem
                            nav.push(contentpage);
                        }
                    }
                    accessibility.name: "Listing"
                }
            }
        }
        attachedObjects: [
            ComponentDefinition {
                id: itemPageDefinition
                source: "ItemPage.qml"
            }
        ]
        onPopTransitionEnded: {
            page.destroy();
        }
    }
    
    import bb.cascades 1.2
    Page {
        property variant item
        titleBar: TitleBar {
            id: titlebar
            title: item.name
        }
        Container {
        }
    }
    

    And this also works except that it generates a

    TypeError: Result of expression 'item' [undefined] is not an object.

    error. Thus, it is written in the ebook learn Blackberry App Development 10. Anyone know how to get this to work without him spit the error type?

    Thank you

    the problem is that the point is not defined when the page is created.
    a solution would be to use onItemChanged to set the title.
    or use something like element? Item.Name;
    There are many other possible solutions, but these two come to mind that the easier.

  • Error in management: TypeError: result of expression 'blackberry.media' [undefined] is not an object

    I'm taking pictures in my widget, but when I make the call

    blackberry.media.camera.takePicture (successCB, closedCB, errorCB);

    I got this error in the Simulator as well as in a real device: "error in management: TypeError: result of expression 'blackberry.media' [undefined] is not an object.

    Also, I included the function in the config.xml file:

    I don't know what else could be.

    Hello

    I have not a 9360 around me at the moment, but I just tried it on a 9900 7.0 running and the above code ran very well.

    On your device, could you please navigate:

    Options > device > application > search and highlight her is > press the menu key, then select change permissions > set all allow (or as high as possible) > save options and re-run your application under test.

    It is more of a longshot, but get a little creative.

    Also, you use the latest version of the SDK software (2.3.1) smartphone while packing?

    https://bdsc.webapps.BlackBerry.com/HTML5/download/SDK

    I'll try and think a little more ideas, but the above code should work on a device of 7.0. Maybe someone from the community can check on them?

    Erik Oros

    BlackBerry Development Advisor

  • TypeError: Result of expression 'new blackberry.invoke' [undefined] is not an object. Application of bbUI

    I am facing an error during the use of the blackberry and the blackberry.invoke feature, invoke. BrowserArguments

    I have a group of items in an imageList, an element is defined as this line

    Minutes from anywhere

    function openUptownCairoLink() {}

    try {}

    var args = new blackberry.invoke.BrowserArguments ('http://blackberry.com');

    BlackBerry.Invoke.Invoke (blackberry.invoke.APP_BROWSER, args);

    } catch (e) {alert (e)}

    }

    and when I click on the element, it warns the error as in the subject of this topic.

    I'm using BB Bold 9900 with OS 7

    You will need to do the following:

    http://192.168.0.140:8888" subdomains="true">
      
      
      
      
      
      
      
      
      
      
    
    
  • SOLR search returns 0 results if expression is of double quotes

    If having a search result that looks like this:

    Perspectives on the Office Assistant

    July 28, 2014 - to turn on the out of Office Assistant: on the Tools menu, click out of Office Assistant. In the out of Office Assistant dialog box, select the automatic replies option send out of office. If you want to specify a fixed time and date Select range only send it during this time box range. Then set the start time, and then assign it...

    When I do this research, I get 10 back, including the above results.

    < cfsearch

    name = "qTechTips".

    collection = "" #collection # ""

    criteria = "secondary_id_i:24 out of office.

    OrderBy = 'sort_date_s desc '.

    / >

    But when I do a phrase search for "out of Office":

    < cfsearch

    name = "qTechTips".

    collection = "" #collection # ""

    criteria = "secondary_id_i:24 «out of Office"»

    OrderBy = 'sort_date_s desc '.

    / >

    or

    < cfsearch

    name = "qTechTips".

    collection = "" #collection # ""

    criteria = "secondary_id_i:24"out of the Office.

    OrderBy = 'sort_date_s desc '.

    / >

    I get 0 results. What I am doing wrong? I would like to make an exact expression for what is in the body, not the 'title '.

    I'm on ColdFusion 11, update 3

    Escape the quotes didn't help. I already read examples of search solr by Adobe, but that doesn't help me much. I don't know if it is documented in the CF documentation anywhere (I couldn't find it). I have worked for me after watching the Apache Solr documentation, it is that you need to add "+" between words in the sentence:

    <>

    name = "qTechTips".

    collection = "" #collection # ""

    criteria = "secondary_id_i:24" Out + of + desktop "" "

    OrderBy = 'sort_date_s desc '.

    />

    Waiting for my users to enter '+' is a bit much, but I know they can handle to put quotes on the phrases they want an exact match. After some googling, this is my solution to automatically add the '+' between the exact phrase for the treatment of the cfsearch (if you have a better solution, please let me know):


     
     
     
     
     
     
     
       


               
       


     
       
     

     
     
      <>
    name = "qTechTips".
    collection = "" #collection # ""
    criteria = "" #solr_criteria # ""
    OrderBy = 'sort_date_s desc '.
    />
     

    #solr_criteria #.


     

  • onCreationCompleted shipped before import JavaScript is over

    Hello

    I have a very small QML that matters a little JavaScript (128 lines) file that matters in turn another small JavaScript file (80 lines). In summary QML--> JS A--> JS B. In the JS files are essentially class definitions, and some small global code running. JS files have zero dependencies of the QML.

    The problem is that when the rootComponent.onCreationCompleted signal is distributed on the QML, JavaScript dependencies are not ready yet.

    I get a lot of erros as:

    asset:///Test.qml:10: TypeError: Result of expression 'ONA.inst' [undefined] is not an object.
    

    I also use the reminder of the Qt.include, Qt.include ("b.js", function() {}), a.js wait b.js be fully charged to a.js.

    I expect the onCreationCompleted signal of the element root to be shipped after all imports of JavaScript and its dependencies, where it is fully charged.

    I use BlackBerry10Simulator-BB10_2_1-3502 with VM Ware Fusion 7, under Mac OS X 10.10.3. Unfortunately I have not access to any real device.

    Please advice.

    You can try RenderFence, add this code to your object of root (TabbedPane, Page or NavigationPane) instead of onCreationCompleted:

       attachedObjects: [
            RenderFence {
                raised: true
                onReached: {
                    \\ your code goes here
                }
            }
        ]
    
  • JS function as a type of page in QML property

    Hi all

    I'm trying to create useful js 'class' for my blackberry application and save here some information about qml object here is the example of such file js:

    /* * my js */
    
    function Utils(devInfo){ this.devInfo = devInfo; this.text = "test text";
    
     this.getInfo = function(){ return this.text; };}
    

    I want to group some utils functions here and use this js in qml file object, but I don't want to create "Utils" every time, I would like to have a single instance of page qml. I tried to use properties:

    import bb.cascades 1.3
    import com.example.bb10_samples_states 1.0
    import "myscripts.js" as Scripts
    
    Page {
        property variant utils : new Scripts.Utils(deviceInfo)
    
        Container {
            Label {
                id: myLabel
                text: "Hello World"
            }
    
            onTouch: {
                var newLabeltext = utils.getInfo(); // freezing
                myLabel.text = newLabeltext;
            }
        }
    
        attachedObjects: [
            DevInfo{
                id: deviceInfo
            }
        ]
    }
    

    * DevInfo is registered object c ++

    I got the following in the notecard event error message:

    "asset:///main.qml:15: TypeError: result of expression 'utils.getInfo' [[object Object]] is not a function."

    If I do not use the property and only with variable work, everything is ok. The following code works correctly:

    import bb.cascades 1.3
    import com.example.bb10_samples_states 1.0
    import "myscripts.js" as Scripts
    
    Page {
        //property variant utils : new Scripts.Utils(deviceInfo)
    
        Container {
            Label {
                id: myLabel
                text: "Hello World"
            }
    
            onTouch: {
                var utils = new Scripts.Utils(deviceInfo);
    
                var newLabeltext = utils.getInfo();
                myLabel.text = newLabeltext;
            }
        }
    
        attachedObjects: [
            DevInfo{
                id: deviceInfo
            }
        ]
    }
    

    In general, I don't know where I can store object js in qml page to access my functions utils without need to create each time. Any ideas?

    I think I found the answer

    According to this link, there is no global js object and every instance of component QML has own unique copy resources imported from JS:

    ...

    Code-Behind implementation resources

    Most of the JavaScript files imported into a document QML are implementations with State of the QML importation document. In these cases, each instance of the QML object type defined in the document requires a separate copy of the JavaScript and State objects to behave properly.

    The default behavior when importing the JavaScript files must provide a unique and isolated copy for each instance of the QML component. If this JavaScript file any resources or modules with a statement .import, its code will be executed in the same scope as the instance of the QML component and therefore can access and manipulate objects and properties declared in the QML component. Otherwise, it will have its own unique scope, and the objects and properties of the QML component should be passed to the JavaScript file as parameters functions if they are required.

    ...

    http://Qt-project.org/doc/Qt-5/qtqml-JavaScript-resources.html

    So it seems there is no need to implement the model of sigleton or store JS resources in the QML document. I changed my code as follows:

    /**
     * js
     */
    var utils = {
      devInfo : null
    };
    
    function init(deviceInfo){
      utils.devInfo = deviceInfo;
    };
    
    function getText(){
      return utils.devInfo + " done.";
    };
    

    and qml:

    import bb.cascades 1.3
    import com.example.bb10_samples_states 1.0
    
    import "myscripts.js" as Scripts
    
    Page {
        Container {
            Label {
                id: myLabel
                text: "Hello World"
            }
    
            onCreationCompleted: {
                Scripts.init(deviceInfo);
            }
    
            onTouch: {
                myLabel.text = Scripts.getText("Tra-ta-ta");
            }
        }
    
        attachedObjects: [
            DevInfo{
                id: deviceInfo
            }
        ]
    }
    

    It works fine - I can store information in the variable 'utils' and work with qml js objects. Hope so, it will help someone

  • Appeal to the segment of javascript control

    Hi try to remove an Option from a Segment control in QML file using Javascript, but can't seem to get the correct argument.

    Anyone have an example of what I have tried the search for several hours now and no examples.

    The call, I'm trying to make is:

    segControl.remove (segControl.optionSchedule);

    where optionSchedule is the id of the control of the Segment "Option" element

    Other functions work, but it happens with the error;

    TypeError: Result of expression 'segControl.remove' [undefined] is not a function

    Did I miss a typecast or if this function is not supported?

    Hello

    Unfortunately remove() cannot be called since QML/JavaScript because it isn't Q_INVOKABLE, so you don't have to call from C++ instead.

    I would like to know if there is anything else I can do for you.

    See you soon,.

    Daniel

  • How to set the Volume on the media player in QML

    Hello

    I would like to adjust the volume of my QML Media Player object. According to the documentation:

    http://developer.BlackBerry.com/native/reference/Cascades/bb__multimedia__mediaplayer.html

    MediaPlayer class has a setVolume method, but I get:

    TypeError: Result of expression 'myPlayer.setVolume' [undefined] is not a function.

    How can I adjust the volume in QML?

    Hi burakk,

    Here are the steps that you must follow to adjust the volume by QML programming:

    (1) define a signal myVolumeChanged to the main control QML

    (2) define a slot that handles the signal preceding once it is triggered by the volume control of the MediaPlayer with the new volume

    (3) fire this signal into the slots of the buttons onClicked two volume

    I tried the above using the nowplaying waterfalls sample app and were able to achieve what you're trying to do, which is affecting the volume of the MediaPlayer using two buttons volume QML. Here's the code I added in the file main.qml from the sample application for your reference:

    import bb.cascades 1.2
    import bb.multimedia 1.0
    
    Page {
        property double newVolume: 4
        signal myVolumeChanged()
    
        onMyVolumeChanged: {
            player.setVolume(newVolume);
        }
    
        Container {
            layout: DockLayout {}
    
            ImageView {
                ...
            }
    
            Label {
                ...
            }
    
            //! [1]
            ProgressBar {
                   ....
            }
            //! [1]
    
            Container {
                layout: StackLayout {
                    orientation: LayoutOrientation.LeftToRight
                }
    
                Button {
                    text: "Increase Volume"
                    onClicked: {
                        newVolume = newVolume + 1
                        myVolumeChanged();
                    }
                }
                Button {
                    text: "Decrease Volume"
                    onClicked: {
                        newVolume = newVolume - 1
                        myVolumeChanged();
                    }
                }
            }
        }
    
        attachedObjects: [
            //! [2]
            MediaPlayer {
                id: player
    
                sourceUrl: "music/song.mp3"
            },
            //! [2]
    
            //! [3]
            NowPlayingConnection {
                id: nowPlaying
                ...
    
            }
            //! [3]
        ]
    }
    
  • Personalized with custom functions callabe DataModel

    Hi all

    I am creating a data template customized with some features available in the QML code. This is the header file:

    #ifndef XMLDATAMODEL_HPP
    #define XMLDATAMODEL_HPP
    
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    #include 
    #include 
    
    class XmlDataModel: public bb::cascades::DataModel{
    
    public:
        XmlDataModel();
        virtual ~XmlDataModel();
    
        // Required interface implementation
        virtual int childCount(const QVariantList& indexPath);
        virtual bool hasChildren(const QVariantList& indexPath);
        virtual QVariant data(const QVariantList& indexPath);
    
    public:
    
        Q_INVOKABLE
        void load(const QString& file_name);
    
        Q_INVOKABLE
        void setHeaderName(const QString& headerName);
    
    private:
        QVariant *m_sourceList;
        QString *m_headerName;
    
    };
    
    #endif
    

    And it's the QML app:

    onCreationCompleted: {
            console.log("main.qml loaded");
    
            _model.setHeaderName("hello");
        }
    

    But when the QML code try to run the setheaderName function, I get this error:

    TypeError: Result of expression '_model.setHeaderName' [undefined] is not a function.
    

    I have the _topSpeed is accessible by the QML code, but I don't know why I can't run my own functions...

    Can someone help me?

    Make a Q_OBJECT:

    class XmlDataModel: public bb::cascades::DataModel{  Q_OBJECT  ...
    
  • To access the values from the row outside the ListView ListItem

    Hello

    I spent two hours browsing the forums and documentation with no chance of finding a solution on how to access the list item data from outside the listview.

    Let explain me my code. It is marked with I work and what does not work and its expected behavior.

    Should work behavior


    Tapping & getting data

    The arrayDataModel is filled with 4 rows. Firstly the list item, second item in the list... etc.

    • Tapping on the order of the day, label with the id of triggeredText displays the value of a threaded list item.
    • The index of the tapped icon appears in the label with the id of triggerredIndex.

    Incrementing Index using ActionItems onBar

    By pressing action items 'previous' and 'next', you can increment the index value to the label with the id of triggeredIndex. The order of the index is 0-4, even as total of the items in the list.

    How to extract data from the index when the value of triggeredIndex?

    Buttons

    The buttons at the bottom of the screen... Select 1, select the 2nd, 3rd Select should select indexes 0,1,2 of the list and display the value in triggeredText and triggeredIndex. They do not work.

    How did I pull the values when you click the buttons?

    import bb.cascades 1.3
    
    TabbedPane {
        id: root
        showTabsOnActionBar: false
    
        Tab {
            id: mainTab
            title: "Test List"
                Page {
                    id: mainPage
                    titleBar: TitleBar {
                        title: "List Traversal Test"
                    }
                    actions: [
                        ActionItem {
                            title: "Previous"
                            ActionBar.placement: ActionBarPlacement.OnBar
                            onTriggered: {
                                // get current selected index from list=
                                var currentIndex = parseInt(triggeredIndex.text);
    
                                if(currentIndex <= 0){
                                    //do nothing already at first item
                                }else{
                                    // subtract 1 from index ( ci - 1) ?
                                    var newIndex = parseInt(triggeredIndex.text) - 1;
    
                                    // show data from new selected index
                                    // ???
    
                                    // triggeredItem.text = XXX // the data
                                    // ???
    
                                    // triggeredIndex.text = X // the current index
                                    triggeredIndex.text = newIndex;
                                }
                            }
                        },
                        ActionItem {
                            title: "Next"
                            ActionBar.placement: ActionBarPlacement.OnBar
                            onTriggered: {
                                // get current selected index from list=
                                var currentIndex = parseInt(triggeredIndex.text);
    
                                if(currentIndex == 4){
                                    //do nothing already at lastitem
                                }else{
                                // add 1 to index ( ci + 1) ?
                                var newIndex = parseInt(triggeredIndex.text) + 1
    
                                // show data from new selected index
                                // ???
    
                                // triggeredItem.text = XXX // the data
                                // ???
    
                                // triggeredIndex.text = X // the current index
                                triggeredIndex.text = newIndex;
                            }
                            }
                        },
                        ActionItem {
                            title: "Clear"
                            ActionBar.placement: ActionBarPlacement.OnBar
                            onTriggered: {
                                // set current index to 0 (top item in list)
                            }
                        }
    
                    ]
                    Container {
                        preferredHeight: maxHeight
                        layout: StackLayout {
                            orientation: LayoutOrientation.TopToBottom
                        }
    
                        Label{
                            id: triggeredItem      // value of listitem from current index
                            text: "0"
                        }
                        Label{
                            id: triggeredIndex    // current index
                            text: "0"
                            onTextChanged: {
                                // set triggeredItem.text to contents of selected ListItem with same index
                                // STUCK HERE cannot access ListItem.dataModel(indexPath) from here....
                            }
    
                        }
                        Container{
                            ListView {
    
                                id: theList
                                objectName: "dalist"
                                dataModel: ArrayDataModel {
                                    id: theListModel
                                }
                                listItemComponents: ListItemComponent {
                                    StandardListItem {
                                        id: itemRoot
                                        title: ListItemData
                                    }
    
                                }
                                onTriggered: {
                                    var si = dataModel.data(indexPath);
                                    triggeredItem.text = "LIST ITEM CONTENT: " + si;  //set content when user taps on item
                                    triggeredIndex.text = "LIST ITEM INDEX INDEX: " + indexPath;  // set index when user taps
                                }
    
                                onSelectionChanged: {
                                    //console.log(selected);
                                }
    
                                onCreationCompleted: {
    
                                    //add some data to the listview
                                    theListModel.append("First List Item");
                                    theListModel.append("Second List Item");
                                    theListModel.append("Third List Item");
                                    theListModel.append("Fourth List Item");
                                }
                            }
    
                        }
                        Container{
                            layout: StackLayout {
                                orientation: LayoutOrientation.LeftToRight
                            }
                        Button{
                            text: "Select 1st"
                            onClicked: {
                                theList.clearSelection();
                                theList.select(0);
    
                            }
                        }
                        Button{
                            text: "Select 2nd"
                            onClicked: {
                                theList.clearSelection();
                                theList.select(1);
    
                            }
                        }
    
                        Button{
                            text: "Select 3rd item"
                            onClicked: {
    
                                //expected behaviour is to show data from Third List Item
    
                                // triggeredIndex.text = INDEX 3
                                // triggeredText.text = (DATA FROM THIRD LIST ITEM)
    
                                // THIS IS NOT WORKING ....
                                theList.clearSelection();
                                theList.select(2);
                                console.log(theList.dataModel(3));
                                triggeredItem.text = theListModel.dataModel(3);
    
                            }
                        }
                    }
                   }
                }
            }//tab
    }
    

    Thank you and have a happy and healthy 2015!

    Your help will be greatly appreciated.

    I ran and got this:

    asset:///main.qml:161: TypeError: Result of expression 'theList.dataModel' [bb::cascades::ArrayDataModel(0x1091a838)] is not a function.
    

    But it works

    theListModel.data([3])
    

    But this isn't the solution, you have a more serious problem. You select a value, you trigger. If you add this in onTriggered you select it (and you can see that it changes color when it is selected).

    theList.select(indexPath);
    

    If you want to use option to deselect

    theList.select(indexPath, !theList.isSelected(indexPath));
    

    And if you want to have that one chose this

    theList.clearSelection();
    theList.select(indexPath);
    

    Inside the button 'Select the 3rd point' allows to select programmatically

    theList.select([2]);
    

    It works but I'm not sure what you're trying to do

  • Community API - PlayBook Barcode

    Hello

    I try a playbook 'Barcode' https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Tablet/Barcode extension, but the application does not work. I have a lot of mistakes, when I click on

    'Namespaces test'-> BB ns: [object Object]-> blackberry-media ns: undefined-> error with namespace: TypeError: result of expression 'blackberry.media' [undefined] is not an object.

    When I click on 'Decode barcodes'-> error occurred when scanning barcodes: expression TypeError:Result 'blackberry.media' [undefined] is not an object...

    I think that the blackberry.media object is not available on playbook (os 1.0), where is error ?

    CU

    UserNeo

    Have you copied the extension in the "ext" of Tablet SDK folder?

  • Property variant removes the animations?

    Start at the beginning.

    property variant images
    

    I have my container where I add images to.

    Container {
                id: drawContainer
                layout: AbsoluteLayout {
                }
    }
    

    from there...

        attachedObjects: [
            ComponentDefinition {
                id: imageDefinition
                content: ImageView {
                    imageSource: "cute_cat102.jpg"
                    preferredHeight: imageHeight
                    preferredWidth: imageWidth
                    animations: [
                        TranslateTransition {
                            toX: 400
                            duration: 1000
                        }
                    ]
                }
            }
        ]
    

    I add images dynamically, like this

    var imagesTmp = Array();
            for (var n = 0; n < 3 * numberOfTiles; n ++) {
                imagesTmp[n] = imageDefinition.createObject();
                imagesTmp[n].translationX = getX(n);
                imagesTmp[n].translationY = getY(n);
                drawContainer.add(imagesTmp[n]);
            }
            images = imagesTmp;
    

    So far so good. I can access any of these images and move them if I use images [0] .translationX.

    However, the animations are a problem! They work for imagesTmp but not for images!

    imagesTmp[0].animations // [object Object]
    imagesTmp[0].animations[0].play() // works
    
    images[0].animations // QVariant(QDeclarativeListProperty)
    images[0].animations[0].play(); // TypeError: Result of expression 'images[0].animations[0]' [undefined] is not an object.
    

    I wish I could be able to play animations of images, but as you can see, it won't let me. What I've done wrong?

    I need to have access to the images outside the service in what I create them.

    Hello
    Please try if it works:

    the property list images

  • How to refresh the Listview after adding a new item

    Hello

    I have the following list:

     ListView {
                                        id: channelsList
    
                                        dataModel: categoryModel
    
                                        listItemComponents: [
                                            ListItemComponent {
                                                type: "item"
                                                StandardListItem {
                                                    title: ListItemData.name // Channel name
                                                    imageSource: ListItemData.imageFile
                                                    status: ListItemData.id
    
                                                    id: channelItemId
    
                                                    contextActions: [
                                                        ActionSet {
                                                            //title: contentView.title
                                                            ActionItem {
                                                                title: "Add to Favorites"
    
                                                                onTriggered: {
                                                                    console.log(ListItemData.id + " will be added to the Favorites");
                                                                    //categoryModel.addFavorite(ListItemData.name, ListItemData.imageFile, ListItemData.id);
                                                                    channelItemId.ListItem.view.viewTriggered(ListItemData.name, ListItemData.imageFile, ListItemData.id);
                                                                }
    
                                                            }
    
                                                        }
                                                    ]
                                                }
                                            }
                                        ]
    
                                        onTriggered: {
                                                var chosenChannel = dataModel.data(indexPath);
                                                console.log("indexPath: " + indexPath);
    
                                                var playingPage = playpagedef.createObject();
    
                                                playingPage.chname = chosenChannel.name;
                                                playingPage.cid = chosenChannel.id;
                                                playingPage.init();
    
                                                Qt.nav.push(playingPage);
    
                                        }
    
                                        attachedObjects: [
                                            // The bucket categoryModel is a non visible object so it is set up as an attached object.
                                            // The categoryModel itself is a QListDataModel defined in categorymodel.h and registered
                                            // as a type in the creation of the application.
                                            CategoryModel {
                                                id: categoryModel
                                                // The path to the JSON file with initial data, this file will be moved to
                                                // the data folder on the first launch of the application (in order to
                                                // be able to get write access).
                                                jsonAssetPath: "models/channels.json"
    
                                                // The filtering is initially set to "Category 1" to show category channels
                                                filter: label.text
                                            },
    
                                            ComponentDefinition {
                                                id: playpagedef
                                                source: "PlayingPage.qml"
                                            }
                                        ]
    
                                        function viewTriggered(name, imageFile, id)
                                        {
                                            categoryModel.addFavorite(name, imageFile, id);
                                            categoryModel.clear();
                                        }
    
                                    }
    

    and the categoeymodel.h is as follows:

    #ifndef _CATEGORYMODEL_H
    #define _CATEGORYMODEL_H
    
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::data;
    
    // The category categoryModel is based on the QListDataModel template, which in turn
    // implements the abstract DataModel class.
    typedef bb::cascades::QListDataModel CategoryListModel;
    
    /* CategoryModel Description:
     *
     * CategoryModel class for the Category List application, the data categoryModel
     * reads and write from a JSON file that keeps all item data
     * for the list.
     */
    class CategoryModel: public CategoryListModel
    {
    Q_OBJECT
    
    Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
    
    Q_PROPERTY(QString jsonAssetPath READ jsonAssetPath WRITE setJsonAssetPath NOTIFY jsonAssetPathChanged)
    
    public:
        /**
         * Constructor that sets up the recipe
         * @param parent The parent Container, if not specified, 0 is used
         */
        CategoryModel(QObject *parent = 0);
        ~CategoryModel();
    
        QString filter();
    
        void setFilter(const QString filter);
    
        QString jsonAssetPath();
    
        void setJsonAssetPath(const QString jsonAssetPath);
    
    signals:
    
        void filterChanged(QString filter);
    
        void jsonAssetPathChanged(QString jsonAssetPath);
    
    public slots:
        void addFavorite(QString channelName, QString channelImageFile, int channelId);
    
    private:
        bool jsonToDataFolder();
    
        // Property variables
        QString mFilter;
        QString mJsonAssetsPath;
        QString mJsonDataPath;
    
        // A list containing all data read from the JSON file
        QVariantList mData;
    
        //Invocation variables
        bb::cascades::Invocation* mInvocation;
    };
    
    #endif // ifndef _CATEGORYMODEL_H
    

    My problem is that the listview is not get automatically updated when a new item is added to the datamodel (a favorite channel is added). I have to exit the application and restart to see the updated list.

    categoryModel.addFavorite(name, imageFile, id);
    categoryModel.clear();
    

    categoryModel.clear ();

    does not work. I get:

    Asset: / / / hand. QML:180: TypeError: result of expression 'categoryModel.clear' [undefined] is not a function.

    I would like to know how to achieve using approach "more correct".

    QListDataModel does not expose its internal storage directly. It is possible to reconstruct the map by performing an iteration in a loop (with the help of data() and size() methods), the dataModel entries:

    http://developer.BlackBerry.com/Cascades/reference/bb__cascades__qlistdatamodel.html

    but I don't see how this could help. If the filtered data is changed, it must be merged with the original sort data.

    Why the original approach has not worked?

    I could not understand from the description appearance of the interface user, please post a screenshot if possible.

  • Application.unsetClosePrompt does not exist in the Cascades

    Application.setClosePrompt documentation (...) I'm supposed to use .unsetClosePrompt when I want more dialog, but seems to throw

    Asset:///redacted.QML:65: TypeError: result of expression 'Application.unsetClosePrompt' [undefined] is not a function.

    When it is called. Is this a known problem (in point 10.2)

    I think it is called clearClosePrompt.

Maybe you are looking for