Data binding occurs after onAdded() in CellRenderer?

Hi all, I extend the qnx.ui.listClasses.CellRenderer for my TileList. I noticed that sometimes the this.data would be null in my overridden onAdded() function.

After some tests, I realized that if I use a timer to check this.data seconds later, it would be filled with the correct data, it seems that the data binding happens a moment after the onAdded() function is called.

I'm happy to rely on the timer to the time delay, but someone has a better solution? Is there something else I should listen to instead of according to onAdded()?

Hey,.

This kind of thing makes me forget all sleep haha clearly that I don't SLEEP much at all!

OK, so I think I got the fix for this. instead of simply relying on onAdded() method that we must look in the drawLabel() method. in the contstructor this time, we do the new CheckBox object where our customization starts later with so we don't have duplicates of this object that is created each time the drawLabel method is called. instead of making the bulk of the work in the onAdded method, we will just to remove the object from the label that is displayed via the cell rendering engine. After that when the drawLabel() method is called, which is when we do our customization. mine includes a checkbox just to test. then we finally remove our object as usual in the onRemoved() method.

Here's the code for update for the rendering engine:

package
{
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextFieldAutoSize;

    import qnx.ui.buttons.CheckBox;
    import qnx.ui.buttons.LabelPlacement;
    import qnx.ui.listClasses.AlternatingCellRenderer;
    import qnx.ui.listClasses.List;
    import qnx.ui.text.Label;

    public class MyCustomCellRenderer extends AlternatingCellRenderer
    {
        /*
        * Place the object out here so that other methods can
        * access it
        */
        private var newCheckBox:CheckBox;

        public function MyCustomCellRenderer()
        {
            super();

            /*
             * Add the checkbox here so we dont keep re-adding a check box
             * whenever the onAdded method is called. other wise there
             * would be a lot of objects for checkbox
            */
            newCheckBox = new CheckBox();
        }
        override protected function onAdded():void
        {
            super.onAdded();

            /*
             * Do not want to use the label object at all. we want
             * to fully customize our cell renderer. for some reason
             * the label object is not considered a child object
             * when the drawLabel method is called so we must
             * removed it in this method where it is considered a
             * child object
            */
            removeChild(label);
        }
        override protected function drawLabel():void
        {
            if (this.data)
            {
                /*
                 * Sometimes this function is called prematurely when there
                 * is no data object available and it is null so we only
                 * do our custom label when there is a data object available
                */
                newCheckBox.width = 500;
                newCheckBox.label = this.data.label;
                newCheckBox.labelPadding = 10;
                newCheckBox.labelPlacement = LabelPlacement.RIGHT;
                newCheckBox.setPosition(10,10);

                addChild(newCheckBox);
            }
        }
        override protected function onRemoved():void
        {
            super.onRemoved();

            /*
            * Remember to remove the checkbox object
            */
            removeChild(newCheckBox);

        }
    }
}

I tested it on a list of single column and also a tilelist component and how it works to 100%. Let me know if I missed something. happy you raised this point! Good luck!

Tags: BlackBerry Developers

Similar Questions

  • Save the data before and after the occurrence of a Trigger Condition.

    Hello

    I am worrking on an application that acquires data from 64 channels and performs many analyses.

    Necessary to implement something is recording the data in the event of alarm condition.

    I've implemented datalogging in many previous applications, but this one is difficult.

    I need to save data for a few seconds before and a few seconds after the alarm has occurred in a single file.

    I thought constantly write data to a file PDM and at the same time deleting the old data, until the alarm trigger occurs.

    but I was not able to do, since I have no blocks to remove data from a PDM file.

    I'm looking for the ideal approach to this recording.

    Any help will be appreciated.

    What I have to do this in the past, use of a queue with loss as a circular buffer.  When you get the relaxation, dump you the data in the queue to your file and then save however many data you want after the outbreak.

    For the purposes of the memory allocation, do not use the queue to rinse.  Use rather a Dequeue element inside a conditional FOR loop with a 0 timeout (reading the queue stops when you have a timeout or you read X samples).

  • Error when you try to install Mass Effect 2: failed installation. A data error occurred.

    problems of mass effect 2

    Hello

    I have windows XP media center edition 2005 and are unable to install 2 mass effect. After some installation, it says: failed installation. A data error occurred.  It is supposed to be windows 7 compatible. I tried running the compatibility problems, but the same thing happens. Someone knows how to fix this?

    Hello

    Try the methods below:

    Method 1:

    Try to copy the contents of the CD to your hard drive to check if your CD has gone wrong.

    Method 2:

    Try to install the application with administrator privileges and check for the issue.

    If you always fall on the issue, you can view the query in the mass effect Community Forum:

    http://meforums.bioware.com/viewforum.html?Forum=127

  • ADF table with checkbox refresh data binding problem

    Hello.

    I use JDeveloper 11.1.1.3. I need to use the table with checkboxes in each row of the table in my project. I use VO with transitional 'Selected' attribute that has a boolean type.
    Everything works well, wait one thing:
    When you click checbox with valueChangeListener and try to get the selected line in the managedBean you won't get any selected lines. After selecting second maaged bean evil shows that 1 single line is selected. It's my managedBean method:

    public void SelectCountyClick (ValueChangeEvent valueChangeEvent) {}

    DCIteratorBinding it = ADFUtils.findIterator (ITERATOR_NAME);

    int selectedRowCount = 0;
    RowSetIterator laughs = it.getRowSetIterator ();
    Line r = rit.first ();
    If (r! = null) {}
    If ((Boolean) r.getAttribute ("Selected"))
    selectedRowCount ++;
    }

    While (rit.hasNext ()) {}
    r = rit.next ();
    If ((Boolean) r.getAttribute ("Selected"))
    selectedRowCount ++;
    }

    System.out.println ("selected all THE LINES:" + selectedRowCount);


    }

    I tried to change this event to the client event, I got the line number, I put 'true' or 'false' to the code data binding, but whenever I can't correct data after the value change event.

    Please help me.

    The latest idea is updated databing after click of checkbox, I think. Please help me.

    Thank you!

    You must go through the concepts of life cycle of page ADF. In simple terms the Boolean value in the model is not defined in valueChangeListener. Try adding (.processUpdates) valueChangeEvent.getComponent (FacesContext.getCurrentInstance ()); on top of your listener method and see the effect.

    Reference:
    http://docs.Oracle.com/CD/E15051_01/Web.1111/b31974/adf_lifecycle.htm

  • Conditional data binding

    I would like to bind data to a table on the condition that one of the child tags has some value.

    For example, let's say that my XML file has the following structure:

    < tag >

    < condition > 1 < / condition >

    ....

    < / tag >

    I want to connect only if the condition tag is set to '1'. Does anyone have an idea how this can be done?

    Thank you

    You must use the SOM predicates in your data binding expression. For example the expression of your entire table with the common parent liaison

    Let's say you could put:

    $. Table. [tag.condition.value is '1']

    Don't forget the '.' (period) after the table since that indicates the parser XFA expect a Boolean value to determine whether to link or not.

    If you want more details, please provide more xml and your names/hierarchies of form.

    Kyle

  • How to fix this bug in data binding?

    Hi all

    I need a mutual-except component as ToggleButton behaves. There is a public property viewMode, which indicates which button is selected. It works fine when I click on other buttons. But when I click the button selected again, it seems that the link does not work.

    The project file is attached. Please help me to fix this problem.

    Thank you and best regards,

    Try adjusting the rocker to false.  Data binding does the right thing, but because you have to toggle the value true, the button is activating / disabling selected after data binding has done his thing.  Try looking at Button.setSelected () to see what I mean.

  • refresh of data binding problem

    Hello

    I am a beginner in Flex, and I have a problem with data binding. I have this little program:

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"> "
    < mx:Script >
    <! [CDATA]
    [Bindable] public var value: String;
    []] >
    < / mx:Script >

    < mx:ViewStack id = "mainViewStack" width = "100%" height = "100%" >
    < mx:Panel id = "panel1" >
    < mx:TextInput id = "text1" / >
    < mx:Button label = "A" click = "value = 'test'; mainViewStack.selectedIndex = 1; "/ >
    < / mx:Panel >
    < mx:Panel id = "panel2" >
    < mx:TextInput id = "text2" text = "{value}" / >
    < mx:Button label = "B" click = "mainViewStack.selectedIndex = 0; "/ >
    < / mx:Panel >
    < / mx:ViewStack >
    < / mx:Application >

    -J' I spend 2 panels ('A' button).

    -When I go to the panel1 to panel2 (click on event), I change the variable 'value' for 'test' (with data binding, Text2 is updated).

    -After this, I manually change the value in Text2 (for example "valeur123").

    -J' I spend panel2 to panel1 (button 'B')

    -J' I go once more of the panel1 to panel2 ('A' button)

    = > and this time, the "Text2" TextInput is not being updated. the value is not changed (always "valeur123").

    So why the data binding does not work in this case?

    Thank you for your help.

    Concerning

    Greg

    Yes you were not trying to bind your data to 2 channels, but I said that because assumes that if you have two way data binding support now, so know you only problem.consider the following two lines, which run two way data binding

      
      
    

    try to run the following application and see what happens

    
    
        
            
        
        
            
                    
                    
            
            
                
                
            
        
        
        
        
    
    
  • Data binding does not detect changes

    During the passage of property that may be related to the function and assigning a new object data binding breaks
    Take a look at the following example.

    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "absolute" initialize = "init ()" >

    < mx:VBox >
    < mx:Text id = text = "{user.name"textbox"}" / > "
    < mx:Button label = "Update user" click = "updateUser (user)" / > "
    < mx:Button label = "Update User2" click = "updateUser2 ()" / > "
    < / mx:VBox >
    < mx:Script >
    <! [CDATA]
    [Bindable]
    private var: user;

    private function init (): void
    {
    User = new User();
    User.Name = "first name";
    }

    private void updateUser(newUser:User):void
    {
    newUser = new User();
    newUser.name = 'new name ';
    }
    private function updateUser2 (): void
    {
    User = new User();
    User.Name = "new Name2";
    }
    []] >
    < / mx:Script >
    < / mx:Application >

    File User.as
    package
    {
    [Bindable]
    public class User
    {
    public var name: String;
    }
    }

    Why the function updateUser break data binding?
    The updateUser2 function works

    Thanks for all replies ;)

    Suggestion of levancho on sends an event seems good to me.

    This could look like this:

    var userEvent:UserEvent = new UserEvent ("new user", newUser);
    dispatchEvent (userEvent);

    Where UserEvent is an event with the new object.
    Then all the elements that need this change pourraient, follow these steps:

    addEventListener ("new user", userChanged);

    private void userChanged(evt:UserEvent):void
    {
    evt. User; Update the link with the new user...
    }

    After looking more on the problem, I found:
    Initially, the main problem was that the variable in the function will not update the refence sent in the function when you create a new instance, regardless of the use of data binding or not...

  • &amp; quot; data binding will not be able to detect assignments &amp; quot; warning

    new features in Flex Builder 3, Beta 2 (I did not have this problem with Beta 1), I have randomly (it seems) get warnings "data binding will not be able to detect assignments to < property >" for properties that are Bindable. If I run my AIR application while I have these warnings the app will not be able to detect assignments to these properties, as warning says. However do a rebuild/clean removes these warnings and my app then works well, with data binding works as expected. I have not found a way to force this behavior, it seems just occur occasionally during development.

    others have this problem?

    Hi snowymike,
    Please connect this FB bugapp problems that can be found here: http://bugs.adobe.com/flex/
    Provide as much information as possible.
    Thank you!
    -Tanya

  • How to use the data binding on a cluster?

    Hello

    I just discovered the data binding and used it on some primitive controls/indicators. I love the cleanliness of the approach (no additional querying and son required!)

    Now, this page gives to think I can link a cluster with a shared too variable. However, when I right click-> properties, I see that the tabs appearance and Documentation (and I know that I did not accidentally choose an element inside the cluster, because (1) there is a typedef strict, and said the title of (2) 'The Cluster Properties' dialog box). Where can I find the data binding tab?

    Thank you

    Hi JKSH,

    What you're doing is possible if you make the file .ctl as the definition of type rather than a strict definition of type. With a strict definition of type all instances of the same .ctl file link that is why you cannot use data binding.

  • Symbol of the triangle in data binding

    Hello

    I'm lie some elements of graphical interface directly to the shared Variables by using the GUI element data binding property. However, there is a small triangle at the top right of the element symbol, it shows the status of the connection. If it is properly connected, it green beds. How can I hide this symbol?

    Oh, sorry, I found it. It is under the visible elements.

  • I regularly get wrinkles dividing the text which I cannot remove. The lines seem to occur after the typing of consecutive asterisks intended to divide the text segments.

    Original title: wrinkles in text

    I regularly get wrinkles dividing the text which I cannot remove.  The lines seem to occur after the typing of consecutive asterisks intended to divide the text segments.

    Much appreciated assistance by removing the lines.

    Thank you ~.

    1. you must identify which application you use to create your documents.

    2. in addition to the name of the application, you must specify its version.

    3. Please ask your question in the appropriate forum.  Assuming that you are dealing with a version of Microsoft Word, which would be the forum Microsoft Office Word.

    4. Notwithstanding the foregoing, if you use Word 2003, 2007 or 2010, see--> http://www.techrepublic.com/blog/msoffice/add-horizontal-lines-to-a-word-document/3886

  • I can receive, but not send. Error (0 x 80004003) occurred after sending photos from Picasa.

    I get the following error in WLM: 0 x 80004003 while trying to send messages.  I can receive, but not send.  Error occurred after sending photos from Picasa.

    Delete the emails in your Outbox and close Windows Live Mail. Open Windows Live Mail and send a test message to yourself. Is the problem solved?

  • Can someone help me solve the problem APPCRASH on Windows 7? The problem occurs after installation of Office 2010

    Hi all

    the OS is Windows 7 SP1 32-bit Enterprise Edition.

    I use an important banking software package called ORF more than Misys, the application is critical for the company, the problem occurs after the installation of Microsoft Office 2010 Professional Plus with Service Pack 2; the ORF more crashes when you try to print to a PictBridge compatible printer.

    I get the following message from crash:

    Signature of the problem:
    Problem event name: APPCRASH
    Application name: orfplus.exe
    Application version: 5.0.1.0
    Application timestamp: 3f6f479b
    Fault Module name: StackHash_802d
    Fault Module Version: 6.1.7601.22436
    Timestamp of Module error: 521eaab0
    Exception code: c0000374
    Exception offset: 000c38b7
    OS version: 6.1.7601.2.1.0.256.4
    Locale ID: 2057
    Additional information 1: 802d
    More information 2: 802d0d721d077b7993d17470b8164201
    3 more information: d6a2
    Additional information 4: d6a2e9e6b15ae70428294b9407d7e88d

    Read our privacy statement online:
    http://go.Microsoft.com/fwlink/?LinkId=104288&clcid=0x0409

    If the online privacy statement is not available, please read our offline privacy statement:
    C:\Windows\system32\en-US\erofflps.txt

    ----

    I tried to exclude the orfplus.exe of the DEP, but that does not solve the problem, the application always crashes when I try to print a report.

    ----

    As a result, we are unable to upgrade our office staff of Office 2010 Professional Plus application.

    I appreciate if someone can help me solve this problem.

    Thanks in advance.

    Hello Matt,

    According to the issue description, it seems that you are connected to a network domain, so I suggest you to republish your query on the TechNet forum and I hope that you will receive a response it a better way that they are trained on the computers in the domain and their settings.

    http://social.technet.Microsoft.com/forums/en-us/home?category=w7itpro

    Thank you.

  • How much time does it take for creative cloud activation occur after the order?

    How much time does it take for creative cloud activation occur after the order?

    Hello

    In order to activate the creative cloud, please see: -.

    Learn how to enable or disable Adobe applications.

    Connect and disconnect activate Cloud Creative applications

Maybe you are looking for