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
cascadedev
Posts: 39
Registered: ‎03-09-2014
My Device: Simulator
Accepted Solution

Cannot Recognize Property Variant Symbol

[ Edited ]

Hi guys, i tried to make saveValue and getValue function to work on my app. But, i get a warning "unknown symbol

'contentView' ", this warning makes the function doesn't work properly. What makes this warning occur, and how to solve it?

 

Here is my code :

 

main.qml

Tab {
        title: "Income"
        imageSource: "asset:///images/income_icon.png"
        Page {
            id: incomePage
            property variant contentView
            function clear(){
                income_name.text="";
                income_value.text="";
            }
            function setInfo() {
                editIncomeName.text=income.getValueFor("income_Name","");
                editIncomeValue.text=income.getValueFor("income_Value","");
            }
            Container {
                
                background: income_background.imagePaint
                
                attachedObjects: [
                    ImagePaintDefinition {
                        id: income_background
                        imageSource: "asset:///images/background.amd"
                        repeatPattern: RepeatPattern.XY
                    }
                ]
                
                id:imagecontainer
                ImageView {
                    maxHeight: 180
                    id:background
                    accessibility.name: "background"
                    imageSource: "asset:///images/income_page.png"
                }
                layout: StackLayout {
                
                }
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
                
                ScrollView {
                    id:scrollincome
                    accessibility.name: "scrollincome"
                    scrollViewProperties {
                        scrollMode: ScrollMode.Vertical
                    }
                    horizontalAlignment: HorizontalAlignment.Center
                    
                    Container {
                        id:mainincome
                        
                        Container {
                            topPadding: 20
                            id:inputborder
                            layout: DockLayout {
                            
                            }
                            ImageView {
                                maxHeight: 350
                                maxWidth: 750
                                id:incomebox
                                accessibility.name: "incomebox"
                                imageSource: "asset:///images/border.png" 
                                horizontalAlignment: HorizontalAlignment.Fill
                                verticalAlignment: VerticalAlignment.Fill
                            }    
                            Container {
                                id: income_inputwrapper
                                layout: StackLayout {
                                
                                }
                                horizontalAlignment: HorizontalAlignment.Center
                                
                                Container {
                                    topPadding: 30
                                    id: incomefield
                                    TextField {
                                        maxWidth: 500
                                        id: income_name
                                        accessibility.name: "income_name"
                                        hintText: "Income Name"
                                    }//incomecategory
                                    
                                    TextField {
                                        maxWidth: 500
                                        id: income_value
                                        accessibility.name: "income_value"
                                        hintText: "Income Value"
                                        inputMode: inputMode.NumbersAndPunctuation
                                    }
                                }//incomefield
                                
                                Container {
                                    maxWidth: 350
                                    maxHeight: 110
                                    topPadding: 30
                                    id:incomebutton   
                                    layout: StackLayout {
                                        orientation: LayoutOrientation.LeftToRight
                                    }
                                    horizontalAlignment: HorizontalAlignment.Center
                                    
                                    ImageButton {
                                        id: addincome
                                        accessibility.name: "income_button"
                                        defaultImageSource: "asset:///images/add_button.png"
                                        layoutProperties: StackLayoutProperties {
                                            spaceQuota: 1
                                        }
                                        onClicked: {
                                            income.addNewRecord(income_name.text,income_value.text);
                                            income_name.text="";
                                            income_value.text="";
                                        }
                                    }
                                    ImageButton {
                                        id: resetincome
                                        accessibility.name: "reset_income"
                                        defaultImageSource: "asset:///images/reset_button.png"
                                        layoutProperties: StackLayoutProperties {
                                            spaceQuota: 1
                                        }
                                        onClicked: {
                                        	income.resetIncome();
                                        }
                                    }  
                                }//incomebutton
                            }//inputwrapper
                        }//inputborder
                        
                        Container {
                            id: income_field
                            layout: StackLayout {
                            
                            }
                            horizontalAlignment: HorizontalAlignment.Center
                            verticalAlignment: VerticalAlignment.Bottom
                            
                            Container {
                                topPadding: 30
                                id: income_result
                                horizontalAlignment: HorizontalAlignment.Center
                                
                                Label {
                                    id: income_text
                                    accessibility.name: "incometext"
                                    text: "Income Total :"
                                    textFit{
                                        minFontSizeValue: 2
                                    }
                                }//incometotaltext
                                
                                Label {
                                    id: income_total
                                    accessibility.name: "incomelabel"
                                    text: "$"
                                    textFit{
                                        minFontSizeValue: 5
                                        }                        
                                    }//incometotallabel 
                                }//incomeResult
                            
                                Container {
                                id: incomeListView
                                ListView {
                                    translationY:0
                                    translationX:0
                                    accessibility.name: "income_List"
                                    objectName: "incomeList"
                                    id: incomeList
                                    preferredHeight:850
                                    
                                    dataModel: incomeModel 
                                    listItemComponents: [ 
                                        ListItemComponent {
                                            type: "item"
                                            StandardListItem {
                                                imageSpaceReserved: false
                                                title: ListItemData.income_Name
                                                status: ListItemData.income_Value
                                            }
                                        }
                          ]
                          onTriggered: {
                          incomeList.clearSelection();
                          select(indexPath);
                          income.findIndexPath(indexPath);
                          income.saveValueFor("title",contentView.income_name);
                                  income.saveValueFor("classes",contentView.income_value);
                          incomePage.setInfo();
                          editIncome.open();
                                    }
                                    onSelectionChanged: {
                                        if (selected) {
                                            var chosenItem = dataModel.data(indexPath);
                                            contentView = chosenItem;
                                        }
                                    } 	
                                    layoutProperties: StackLayoutProperties {
                                        spaceQuota: -1.0
                                    }
                                }//ListView
                            }//incomeListView
                        }//incomefield
                    }//mainincome
                }//scrollview
            }//imagecontainer
        }//incomepage   
        attachedObjects: [
            Sheet {
                id:editIncome
                content : Page {
                    titleBar: TitleBar {
                        id:editIncomeTitle
                        title: "Edit Income"
                        dismissAction: ActionItem {
                            title: "Back"
                            onTriggered: {
                                editIncome.close();
                                incomePage.clear();
                                
                            }
                        }
                        acceptAction: ActionItem {
                            title: "Submit"
                            onTriggered: {
                                if (editIncomeName.text.length>0 && editIncomeValue.text.length>0) {
                                    income.addNewRecord(income_name.text,income_value.text);
                                    editIncome.close();
                                    incomePage.clear();
                                }
                                else {
                                    editIncomeName.hintText="Enter Income Name";
                                    editIncomeValue.hintText="Enter Income Value";
                                }
                            }
                        }
                    }
                    Container {
                        topPadding: 20
                        id:editIncomeBorder
                        layout: DockLayout {
                        
                        }
                        ImageView {
                            maxHeight: 350
                            maxWidth: 750
                            id:editIncomeBox
                            accessibility.name: "incomebox"
                            imageSource: "asset:///images/border.png" 
                            horizontalAlignment: HorizontalAlignment.Fill
                            verticalAlignment: VerticalAlignment.Fill
                    }
                    Container {
                        id: incomeReview
                        layout: StackLayout {
                        
                        }
                        horizontalAlignment: HorizontalAlignment.Center
                        
                        Container {
                            topPadding: 30
                            id: incomereviewField
                            TextField {
                                maxWidth: 500
                                id: editIncomeName
                                accessibility.name: "income_name"
                                text: income.getValueFor("income_Name","")
                            }//incomecategory
                            
                            TextField {
                                maxWidth: 500
                                id: editIncomeValue
                                accessibility.name: "income_value"
                                text: income.getValueFor("income_Value","")
                                }
                            }//incomefield  
                        }//incomeBox
                        }//incomeBorder
                    }//reviewPage
                }//reviewSheet
            
        ]
    }//incometab

 

Any help would be appreciated. Thank you.

Developer
ekke
Posts: 1,562
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Cannot Recognize Property Variant Symbol

a little trick will help you:

define your variant this way:

 

 

property variant contentView: {
"income_name":"",
"income_value":""
}
-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
cascadedev
Posts: 39
Registered: ‎03-09-2014
My Device: Simulator

Re: Cannot Recognize Property Variant Symbol

Thank you for your answer ekke,

 

Unfortunately, the warning still there, and actually i got 3 warnings from this issue. Here is the line where the 3 warnings happen :

property variant contentView

(..............)

onTriggered: { incomeList.clearSelection(); select(indexPath); sql.findIndexPath(indexPath); sql.saveValueFor("income_Name",contentView.income_Name); sql.saveValueFor("income_Value",contentView.income_Value); incomePage.setInfo(); editIncome.open(); }
onSelectionChanged: { if (selected) { var chosenItem = dataModel.data(indexPath); contentView = chosenItem; } }

 

Looking forward for the possible solution. Thank you.

Developer
ekke
Posts: 1,562
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Cannot Recognize Property Variant Symbol

have you tried to full reference the property like

myPage.myVariantProperty

?

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
cascadedev
Posts: 39
Registered: ‎03-09-2014
My Device: Simulator

Re: Cannot Recognize Property Variant Symbol

Problem solved. I've decided not to use property variant, but merging chosenItem reference into onTriggered signal handler to get save value and get value working.

 

 onTriggered: {
                                                incomeList.clearSelection();
                                                select(indexPath);
                                                sql.findIndexPath(indexPath);
                                                var chosenItem = dataModel.data(indexPath);
                                                chosenItem.income_name;
                                                chosenItem.income_value;
                                                sql.saveValueFor("income_Name",chosenItem.income_Name);
                                                sql.saveValueFor("income_Value",chosenItem.income_Value);
                                                incomePage.setInfo();
                                                editIncome.open();
                                            }

 

Thank you for your effort in giving possible solutions for this issue.

 

Regards