pass information to custom component

Hello

I'm new to BB10 apps development and its environment.

I use the latest IDE with 10.3 SDK in cascade mode.

I want to pass information to main.qml to another qml file.

The scenario is like this.

I have the second page that opens when a file is chosen by a filepicker.

onFileSelected: {
              selectedFile = selectedFiles[0]
              var myPage = pageDefinition.createObject()
              navigationPane.push(myPage)
         }

second page is attachedobjects as:

attachedObjects: [
    ComponentDefinition {
        id: pageDefinition
        source: "asset:///secondpage.qml"
    }
]

I want to use info in "selectedFile" on the second page. How can I do?

Thank you!

TRY THIS

onFileSelected: {
              selectedFile = selectedFiles[0]
              var myPage = pageDefinition.createObject()              myPage.fs = selectedFile; // new line
              navigationPane.push(myPage)
         }

second page is attachedobjects as:

attachedObjects: [
    ComponentDefinition {
        id: pageDefinition
        source: Page{            id: secondPage            property alias fs: fileinfo.text  // create an alias            Container{                 Label{                     id: fileinfo                     //this field will be populated width the name after you                     //create and push the new page onto your nav                     text: ""                  }            }        }
    }
]

Tags: BlackBerry Developers

Similar Questions

  • How to pass skinclass for custom component?

    Hi guys, I'm moving my main application of my custom component skinClass. Here is my code, but it gave me an error saying "initializer for 'skinType': values of type spark.componets.supportClasses.Skin' cannot be represented in the text. "  I don't know if it is possible to do. Any thoughts? Thank you very much.

    hand. MXML

    < components: loginPanel id = "loginPanel" horizontalCenter = "33" "-15" = Red

    skinType = 'skins. CustomPanel.

    loginButtonClick = "loginpanel_loginButtonClickHandler (event)" / >

    component loginPanel

    script

    [Bindable]

    public var skinType:Skin;

    MXML

    < s:Panel cornerRadius = "5".

    ID = "loginPanelComp".

    "32" = x y = '8 '.

    width = "373" height = "200".

    title = "sign in".

    skinClass = "{skinType}.

    >

    ...............

    < / sign >

    You try to pass a string to match the value of a class. SkinnableComponent skinClass property is a style.

    You must use styles css, or if you want to set this runtime do something like

    private var _skinRef: Class;

    public function set skinClassRef(value:Class):void

    {

    _skinClassRef = value;

    If (loginPanelComp)

    {

    loginPanelComp.setStyle (skinClass, skinRef);

    }

    }

    C

  • Label is not posting on custom component when I am in him passing through actionScript

    Hi all

    I created a custom component that extends from Panel. I added a LinkButton on title bar on this component. I'm passing the linkbutton through a property named label1 label.

    Now in my main mxml I call this component like this:

    < comp: MyPanel label1 = "Click Me" / >

    This works perfectly well and I am able to see the child with lable.

    But when I use the following 2 ways that label does not appear on the child. Child appears on the title, but without all the tags bar:

    1. [Bindable]

    myLab;

    init()

    {

    myLabb = "test";

    }

    < comp: MyPanel label1 = "{myLab}" / >

    2 < comp: MyPanel id = mypan / >

    init (): void

    {

    mypan. Label1 = "test";

    }

    Please help me!

    I'm glad to hear it. Please mark as completed

  • Pass a parameter for the custom component - get null

    Main MXML (part of the code):

    < s:Application

    "" xmlns:ns1 = "*".

    creationComplete = "init (); >

    import MyComponent;

    private function init (): void {}

    var myArray:Array is ["FFF", "TT", "RRR"];.

    myComp.width = 200;

    myComp.height = 200;

    myComp.getArray = myArray;

    myContainer.rawChildren.addChild (myComp);

    }

    < fx:Declarations >

    < ns1:MyComponent id = "myComp" x = "0" y = "0" / >

    < / fx:Declarations >

    custom component:

    package 
    {
              public var getArray:Array;
    public class MyComponent extends Sprite { } trace (getArray); trace null
    }
    }

    What is myContainer?

    I have a working version with my container as UICOmponent inside the hand.

    SerializableAttribute public class MyComp extends Sprite

    {

    private var _getArray:Array;

    public void MyComp()

    {

    }

    public function get getArray (): Array

    {

    Return _getArray;

    }

    public function set getArray(value:Array):void

    {

    trace ("setter", value);

    _getArray = value;

    }

    }

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx".

    "" xmlns:NS1 = "*".

    minWidth = "955" = "600" minHeight

    creationComplete = "init (); » >

    private function init (): void {}

    var myArray:Array is ["FFF", "TT", "RRR"];.

    myComp.width = 200;

    myComp.height = 200;

    myComp.getArray = myArray;

    myContainer.addChild (myComp);

    }

    ]]>

    Not sure whether what you are after but it traces:

    Setter FFF TTT, RRR

    Why do you add to rawChildren?

    C

  • Passing data between the component main enforcement through custom methods and custom

    Similar to what this article is talking about, I have a custom list that contains a list of names of State of the United States in chains. (Let's call this states.mxml) #comments http://www.boyzoid.com/blog/index.cfm/2006/11/22/Flex-Custom-Components-and-Custom-Methods

    I create an action script that is included in my states.mxml like < mx:Script source = "myScripts.as" / > so that I can call the method in mySpcripts.as

    Now, what I want to do is, whenever I click on an item in the list, I want this string is displayed on the Application of the hand (on a canvas or Panel) as a label.

    I don't know how I am supposed to refer to the canvas and wood, which lies on the main of the application of myScripts.as
    Is there a way to create an action script file where methods can reference components for the main application and the custom component file?

    Thank you

    this.parentApplication.canvas.label should do what you are looking for

  • listening in the main application for event from custom component

    I have a component that custom im using an identifier.  I watch videos and tutorials on how to pass variables between applications and custom components. the problem im having is that tutorials or explanation you put the event on the custom component and then it refers to a function in the main application.

    Is a fair way to listen on the main application at the event begins? Ive been tempting for hours and I know there must be something im missing may not be so difficult. any help, I would be really grateful.

    Thank you

    Miguel

    Hello

    The following example has been done as a simple demonstration of States, but the connection (state1) component, is a simple custom event which is sent by the ok button on the connection, the event could be extended to transfer the information to connect to the main application, in this case because the login screen is always public vars or fields of the box would be available for the main application anyway.

    http://gumbo.flashhub.NET/Wizard/ source included

    David.

  • Question about the use of the custom component class define what declarative component

    12.1.3 jdev

    I'm trying to define a declarative component with my custom component class.

    This is the code for my component jsf declarative. I'm trying to use the label on selectManyListbox attribute to pass queryClass for my component class name. It does not work. I also try to use f: attribute to my component class. It does not work too. Question 1: how to move my declarative component attribute to my class of component?

    < af:panelLabelAndMessage label = "#{attrs.displayLabel}" id = "dc_plam1" > "

    < af:switcher id = "dc_s1" defaultFacet = "a lot" facetName = "#{attrs.single eq 'true'?' unique ': 'a lot'}" >

    < f: facet name = "a lot" >

    < af:selectManyListbox id = "namingp1" simple = "true" label = "#{attrs.queryClass}" "

    ' autoSubmit Binding = "#{dropListComp.selectManyListBox}" = "true" valueChangeListener = "#{dropListComp.selectManyValueChange}" >

    < f: attribute name = "queryClass" value = "#{attrs.queryClass}" / >

    < / af:selectManyListbox >

    < / f: facet >

    < f: facet "single" = name >

    < af:selectOneListbox id = "sl_2" simple = "true" label = "#{attrs.queryClass} '"

    autoSubmit Binding = "#{dropListComp.selectOneListBox}" = "true" valueChangeListener = "#{dropListComp.selectOneValueChange}" > "

    < / af:selectOneListbox >

    < / f: facet >

    < / af:switcher >

    < / af:panelLabelAndMessage >

    That's how I try to retrieve the label or f: attribute queryClass in my component class. I get null for both directions.

    {} public void setSelectManyListBox (RichSelectManyListbox selectManyListBox)
    this.selectManyListBox = selectManyListBox;
    If (this.selectManyListBox.getChildCount () == 0) {}
    queryClass = (String) this.selectManyListBox.getLabel ();
    System.out.println (".. queryClass of the label..." + queryClass);
    If (queryClass is nothing)
    {
    queryClass = (String) this.selectManyListBox.getAttributes () .get ("queryClass");
    System.out.println (".. queryClass of attr..." + queryClass);
    }
    If (queryClass is nothing)
    queryClass = "glog.server.query.powerdata.InvolvedPartyQualQuery";
    this.selectManyListBox.getChildren () .addAll (buildDropListSelectItems (queryClass));
    }
    }

    Thank you.

    Hello

    If your declarative component has a defined class of request attribute then #{attrs.name_of_attribute} called from Java should be able to solve

    Frank

  • Need to include classes in the custom component

    Dear Experts,

    I have created custom components, for custom components, I used some different classes and jars and libs and now I want to include these pots, the lib and classes in the generation of custom component file.

    Please advise me how can I add these files in the component so that when I create the zip file included in the zip file.

    Please send me a link where I can get this information.

    Any help will be really appreciated.

    Kind regards

    Elena

    See the tutorial Services Intradoc

  • Not able to make a checkin to a custom component

    Hi all

    I'm building a custom component which should do a checkin in Webcenter Content.When we are trying to do and test what we get below error every time.

    The error is not so much more descriptive and tried to see if there is any more logs generated in the information system of verification of the Webcenter content but there is no more errors in the Audit log as well.

    Here is the error:

    ! csUnableToCheckIn, (null)! csSecurityGroupNotDefined

    If anyone has faced this problem before, please let us know the solution so that we can fix it immediately, because it becomes a Blocker for us.

    Kind regards
    Elena

    We have solved this problem by e-mail.

    You do not correctly set dSecurityGroup.

    You do this:

    String dSecurityGroup = "";

    serviceBinder.putLocal (dSecurityGroup, "Complaints");

    You must do this:

    serviceBinder.putLocal ("dSecurityGroup", "Complaints");

    The key for putLocal must be the literal string of the name of the metadata field. You will need to change all your other putLocal both method calls.

    Jonathan

    http://jonathanhult.com

  • 11g Custom Component with SQL IN (val1, val2,..., valN) query

    Hello

    I want to use a query with a parameter of varchar entry into a custom component. The query definition is like this:

    < b >
    QWhereIsAdministrator < td > < table >
    < td > SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN (?) < table >
    varchar < td > UserRoleList < table >
    < /tr >

    I can't pass the value correct settings at the request of IdocScript
    I tried the following:

    < $UserRoleList = $ "" valA1","valA2"" >
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    < $UserRoleList = "\'valB1\',\'valB2\'"$ > ".
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    < $UserRoleList = $ js ("' valC1', 'valC2'") >
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    < $UserRoleList = $ xml ("' valD1', 'valD2'") >
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    < $UserRoleList = $ url ("' valE1', 'valE2'") >
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    < $UserRoleList = $ urlEscape7Bit ("' valF1', 'valF2'") >
    < $executeService ("SITES_WHERE_IS_ADMINISTRATOR") $ >

    No result found, the syntax of the request for enforcement is not correct. Here is the REQUEST trace output:

    SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN ("'valA1","valA2" ') [executed. [Return line (s): false]
    SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN ("'valB1","valB2" ') [executed. [Return line (s): false]
    SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN ('-"valC1\"-"valC2\" ') [executed. [Return line (s): false]
    SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN (' & #002339; valD1 & #002339; & #002339; valD2 & #002339;) ") [Executed." [Return line (s): false]
    SELECT DISTINCT * FROM FWMTSITE WHERE the ADMINISTRATOR IN ('% 27valE1% 27 %2 c % 27valE2% 27') [executed. [Return line (s): false]
    SELECT DISTINCT * FROM FWMTSITE WHERE the ADMINISTRATOR IN ('% 27valF1% 27% 27valF2% 27') [executed. [Return line (s): false]




    Thank you for your help.

    Change the type parameter of varchar to varchar.in in your definition of the query. Like this:

    
    QWhereIsAdministrator
    SELECT DISTINCT * FROM FWMTSITE WHERE ADMINISTRATOR IN ( ? )
    UserRoleList varchar.in
    
    

    In your workbook, put a list separated by commas in param UserRoleList. In java, you can use:

    final List someListOfStrings = ...; // your list of strings
    final String yourUserRoleListParam = StringUtils.createStringSimple( someListOfStrings );
    m_binder.putLocal( "UserRoleList", yourUserRoleListParam );
    

    In your case

    <$UserRoleList = "val1,val2,...,valN"$>
    

    should do the job.

    Kind regards
    Fabian

    Published by: fscherpe on March 24, 2011 07:45 (added iDoc variable saw you want to begin the application of the model, not Java)

  • Custom component... Null object reference

    I'm having a hard time understanding how to solve a problem, I have met in my flex application and I hope someone here can help me out! I will try and provide a very basic example that illustrates my problem...

    <! - Main.mxml - >

    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="vertical"initialize =" init () "> "

    < mx:Script >
    <! [CDATA]

    private function init (): void {}

    I have a call here that connects to a server of clodfusion by a remote object that returns a user object

    }

    []] >
    < / mx:Script >

    Then, I call a component customized which manages permissions for my application.  I pass on the user object in the custom component

    < user comp: permissions = "{user}" / >

    < / mx:Application >

    <! - Permissions.mxml - >

    " < = xmlns:mx mx:VBox ' http://www.Adobe.com/2006/MXML "creationComplete ="init ()">

    < mx:Script >
    <! [CDATA]

    Basically, this function is triggered and gets some info that depends on the user loged in

    private function init (): void {}

    svc.getSomething (user. PKEY);

    }

    < / mx:Script >

    < / mx:VBox >

    So the problem is that my call to the main application takes a few seconds to run and as the client component is processed before the entire purpose of the use is returned I get the error "object Null Reference '...  How can I make sure that the user object has been created and returned prior to use in my custom components?

    Thank you

    Probably the error will disappear if you create an empty instance of the VO of the user.

  • How to import the custom component exported from flash cs3

    Hello

    I exported a custom component that I designed in flash cs3 as a SWC file. How to import it in my project flex and how to use it?

    Sorry if this is a stupid question. I'm new to flex. Thank you.

    You must add the swc file in your path of the project. Please check the following URL for more information about how to import Flash components in Flex project.
    http://www.Adobe.com/devnet/flash/articles/flex_component_workflow.html

    I hope this helps.

  • Custom component Help

    Hello

    I'm trying to pass a variable to a custom component that I did. Here is my list of import for the script AS:

    Import mx.controls.Image;
    Import mx.controls.Label;
    Import mx.containers.HBox;
    Import mx.containers.VBox;
    Import mx.containers.Panel;
    Import mx.containers.Canvas;
    Import mx.events.FlexEvent;
    import flash.events.Event;

    The script essentially make a picture of a thermometer and then I pass a value and it increases the level of 'mercury '. Here's my .mxml script that works fine:

    < mx:Canvas label = "Test" width = "140" height = "268" y = "10" >

    < custom id: thermometer = "thermo" y = "10" x = "10" Temperature = "27".
    high value = relax "50" = "0" title = "Office" width = "116" height = "245" / >

    < / mx:Canvas >

    That is why a photo of the thermometer exactly as it should. My problem is that when I moved the component a varaible like {pSrv.lastResult.data.current.RH_OFFICE_CURR} it doesn't work anymore! I have no idea why, and I hope that someone has had this problem before. Why can't I send these data to my component?

    Here is the solution discussed:

    package components
    {
    Import mx.containers.Canvas;
    Import mx.containers.VBox;
    Import mx.controls.Image;

    Thermometer/public class extends Canvas
    {
    / * Variables for the child components * /.
    protected var canvas: VBox;
    protected var top_img:Image;
    protected var bottom_img:Image;

    / * Flex calls the createChildren() method when
    * the components are added. This is the right place
    * implement control. Any final design, etc..,.
    * occurs in updateDisplayList * /.
    override protected function createChildren() (): void
    {
    super.createChildren ();
    If (! canvas)
    {
    canvas = new VBox();
    canvas.setStyle ("verticalGap", 0);
    addChild (canvas);
    }

    Create and initialize the top image.
    If (! top_img)
    {
    top_img = new Image();
    canvas.addChild (top_img);
    }

    If (! bottom_img)
    {
    bottom_img = new Image();
    canvas.addChild (bottom_img);
    }
    }

    / * Set the picture styles * /.
    override protected function commitProperties (): void
    {
    super.commitProperties ();
    top_img.source = ' img/blue.png;
    bottom_img.source = ' img/red.png ';
    }

    / * updateDisplayList positions, sizes and draw something it takes * /.
    override the updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void function
    {
    super.updateDisplayList (unscaledWidth, unscaledHeight);

    TODO: use the unscaledHeight property to determine the
    good scaling for the control.
    top_img. ScaleY = 20;
    bottom_img. ScaleY = _temp;
    }

    override protected function measure (): void
    {
    Super.Measure ();
    measuredWidth is measuredMinWidth = 75;.
    measuredHeight is MaxHeight = 200;.
    }

    public void Thermometer()
    {
    Super();
    }

    [Inspectable (defaultValue = 1)]
    private var _temp:uint = 1;

    [Bindable (event = "tempChange")]
    public function get time (): uint
    {
    Return _temp;
    }

    public function set time (value: uint): void
    {
    _temp = value;
    invalidateDisplayList();
    }
    }
    }

  • repeater nested with custom component problem

    Hello
    I'm really stuck with this problem and no help from you guys is greatly appreciated.
    For starters, I have a simple external nested xml file for the data: "book.xml".
    <? XML version = "1.0" encoding = "UTF-8"? >
    < book >
    < section >
    S1 < sectionnumber > < / sectionnumber >
    < chapter >
    C1 < chapternumber > < / chapternumber >
    < / section >
    < chapter >
    C2 < chapternumber > < / chapternumber >
    < / section >
    < / section >
    < section >
    s2 < sectionnumber > < / sectionnumber >
    < chapter >
    < chapternumber > c3 < / chapternumber >
    < / section >
    < / section >
    < / book >

    I also have a main app (NestedRepeater.mxml) of a control relay that contains a custom (Section.mxml) mxml component:
    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml " xmlns:comps ="rate"layout ="absolute">
    < mx:XML id = "data" source = "" data / book.xml "/ >"
    < mx:VBox >
    < mx:Repeater id = dataProvider = "{data.section"Repeater1"}" >
    < sectionNumber = "{Repeater1.currentItem.sectionnumber comps: Section}" / > "
    < / mx:Repeater >
    < / mx:VBox >
    < / mx:Application >

    And in my component (Section.mxml) custom, I have another relay that want it for the chapter in each section as a < mx: state > for the user to be able to show/hide the chapters in each section.

    <? XML version = "1.0" encoding = "utf-8"? >
    "< mx:Canvas xmlns:mx = ' http://www.adobe.com/2006/mxml" > "
    < mx:Script >
    <! [CDATA]
    [Bindable]
    public var sectionNumber:String;
    []] >
    < / mx:Script >
    "" < mx:XML id = 'data' source = '... / data / book.xml "/ >
    < mx:VBox >
    < mx:Panel id = "panel1" layout = "absolute" title = "Section" >
    < mx:VBox >
    < mx:Label text = "{this.sectionNumber}" / >
    < mx:Button id = "btnArticles" label = "show chapters" click = "this.currentState = 'Chapter'" / >
    < / mx:VBox >
    < / mx:Panel >
    < / mx:VBox >
    < mx: states >
    < name mx: State = 'Chapter' >
    < mx:AddChild relativeTo = "{panel1}" position = "after" >
    < mx:VBox >
    < mx:Repeater id = dataProvider = "{data.section.chapter"Repeater2"}" >
    < mx:Panel layout = "absolute" title = "Chapter" >
    < mx:Label text = "{Repeater2.currentItem.chapternumber}" / > "
    < / mx:Panel >
    < / mx:Repeater >
    < / mx:VBox >
    < / mx:AddChild >
    < / mx: State >
    < / mx: states >
    < / mx:Canvas >

    So the problem I have is the relationship of each chapter to its parent section, when I run the application, the result is:
    S1
    C1
    C2
    C3
    S2
    C1
    C2
    C3

    The correct output I want based on the xml, the data provider must be and don't have not all the chapters in each section:
    S1
    C1
    C2
    S2
    C3

    If anyone has any suggestion, would be appreciated greatl.
    Thank you

    Yes, do not try to get new data into the component, simply pass the crux of the entire section in the custom component:

    In this component has a public property or a setter function:
    [Bindable]
    public var xmlSection:XML;

    This variable will now have this in it:


    S1

    C1


    C2

    Repeater2 is therefore:





    Very simple, you follow? I do it very often. Repeater, XML and custom components are an impressive combination.

    Tracy

  • Getting the list of Custom Component ListView

    Hello

    I'm trying to figure out how to get the 'checked' property of a custom component of QML.

    Basically, it's the same as the first example on https://developer.blackberry.com/cascades/documentation/ui/custom_components/index.html

    This is a list, with a listItemComponents, whose type: "item" contains a check box and the label.

    I have an ActionItem whose job is to take all elements that are enabled and do something.

    The ActionItem triggers a C++ code that should get this list.

    Problem is, I can't figure out how to get the selected items. I tried the selected() function but it returns empty.

    I have to turn this into a multiple selection?

    I got so far is the back of GroupModel, after selection, but this does not include anything other than what I fed in the first place. Which makes sense.

    There are a lot of similarities between this issue and the other. Should help to my code and comments in this post, I think: http://supportforums.blackberry.com/t5/Cascades-Development/LstItemComponent-doesn-t-track-the-model...

Maybe you are looking for