Passing a reference / variable to a Custom Component

Hi, I was wondering if someone could help me.
It seems like a very simple problem but I cant for the life
of me seem to work out a solution.
I have created a Custom Component that extends from the
UIComponent that consists of a “rev counter” style
clock face etc….
I want to use this component multiple times within my
application – however feed it different data so for example
each “rev counter” on the page will be displaying
different data etc…..
I want to be able to reuse my component and not have to
create a new component every time I add a “rev counter”
to my application, therefore I need some way of passing a reference
/ variable to the component (maybe from the <mx /> tag where
I declare it in the MXML code ??? )
<mx:Application ….
xmlns:comps="components.*" …..>
<comps:RevCounterComp id=”” (add something
here to reference???) />
</ mx:Application>
Doing this will allow me to reuse my ONE custom component
MANY times feeding it different data (different data provaiders for
each instance of the single component)
Hope this makes sense???
Any help / advice is much appreciated,
Thanks,
Jon.

Jon,
jmryan's suggestion is the preferred way to go. This way you
can use the simple MXML syntax that you described in your post.
If your custom component is defined in ActionScript, you can
use setters or the creationComplete event to update the component
when the values are passed in from the tag (they are set *after*
your constructor runs).
Even easier, if your component is defined in MXML, you can
add [Bindable] to your public field and then bind directly to it in
the custom component's MXML code.
- Peter

Similar Messages

  • Not able to Pass Reference Variables to Deferred task

    Hi All,
    I am not able to Pass the reference variables to Deferred task, With the following code, I am getting null values (for the passed refs) in Deferred Task.
    Code is as:
    <Action id='1' name='Set Deferred Task Action' application='com.waveset.session.WorkflowServices'>
    <Argument name='op' value='addDeferredTask'/>
    <Argument name='type' value='User'/>
    <Argument name='name' value='$(empId)'/>
    <Argument name='authorized' value='true'/>
    <Argument name='task' value='WF_User Deferred Task'/> // Task defination
    <Argument name='date'>
    <Date>2008-11-19T14:50:18.840Z</Date>
    </Argument>
    <Argument name='taskDefinition'>
    <block trace='true'>
    <defvar name='usrObject'> // This is the variable I am passing to 'WF_User Deferred Task'
    <new class='com.waveset.object.GenericObject'/>
    </defvar>
    <invoke name='setAttributes'>
    <ref>usrObject</ref>
    <map>
    <s>accId</s>
    <ref>empId</ref>
    <s>updStatus</s>
    <ref>newStatus</ref>
    </map>
    </invoke>
    </block>
    </Argument>
    </Action>
    <Transition to='End'/>
    Please suggest me.
    Thanks,
    Ravi.

    yeah, you don't have your usrObject available in the deffered task however all variables that you put inside the usrObject are avialble. Like <ref>accId<ref> and <ref>updStatus</ref>. If you still need them organized hierarchically, you might try to add one more level to the object before passing it to addDefferedTask
                <block>
                  <defvar name='objWrapper'>
                    <new class='com.waveset.object.GenericObject'/>
                  </defvar>
                  <defvar name='usrObject'>
                    <new class='com.waveset.object.GenericObject'/>
                  </defvar>
                  <invoke name='setAttributes'>
                    <ref>usrObject</ref>
                    <map>
                      <s>accId</s>
                      <s>yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy</s>
                      <s>updStatus</s>
                      <s>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</s>
                    </map>
                  </invoke>
                  <invoke name='setAttributes'>
                    <ref>objWrapper</ref>
                    <map>
                      <s>usrObject</s>
                      <ref>usrObject</ref>
                    </map>
                  </invoke>
                  <ref>objWrapper</ref>
                </block>I hope you ve got the idea. Cheerz.

  • Custom component problem

    I wrote a custom component:
    Here is the code for the UIComponent:
    package customcomponents;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import java.util.Vector;
    import jsf.*;
    public class UIEventsTable extends UIComponentBase {
         public String getFamily() {
              return "EventsTable";
         public void encodeEnd( FacesContext context ) throws java.io.IOException {
              Vector<Event> events = (Vector<Event>) this.getAttributes().get("events");
              ResponseWriter writer = context.getResponseWriter();
              writer.startElement("table" , this );
              for( int i = 0 ; i < events.size() ; ++i ) {
                   writer.startElement("tr",this);
                        writer.startElement("td",this);
                             writer.write( events.elementAt(i).getEvent_description() );
                        writer.endElement("td");
                   writer.endElement("tr");
              writer.endElement("table");
    }This is the tag class
    package customcomponents;
    import javax.faces.webapp.*;
    import javax.faces.component.*;
    import java.util.*;
    import jsf.*;
    public class EventsTableTag extends UIComponentTag {
         Vector<Event> events = null;
         public String getRendererType() {
              return null;
         public String getComponentType() {
              return "EventsTable";
         public void release() {
              super.release();
              events = null;
         protected void setProperties( UIComponent component ){
              super.setProperties( component );
              if( events != null )
                   component.getAttributes().put( "events" , events );
         public Vector<Event> getEvents() {
              return events;
         public void setEvents(Vector<Event> events) {
              this.events = events;
    }Taglib descriptor:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
         <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>d</short-name>
         <uri>http://eventsTable.com/</uri>
        <tag>
             <name>EventsTable</name>
               <tag-class>customcomponents.EventsTableTag</tag-class>
               <body-content>JSP</body-content>
             <attribute>
                  <name>events</name>
             </attribute>
             <attribute>
                  <name>id</name>
             </attribute>
             <attribute>
                   <name>rendered</name>
              </attribute>
              <attribute>
                   <name>binding</name>
              </attribute>
        </tag>
    </taglib>And finally how I invoke the tag
    <d:EventsTable events="#{location.events}" />
    ...Now location.events is a java.util.Vector with the events. But when I use this tag I get following error message:
    Servlet.service() for servlet Faces Servlet threw exception
    org.apache.jasper.JasperException: Unable to convert string "#{location.events}" to class "java.util.Vector" for attribute "events": Property Editor not registered with the PropertyEditorManagerI do not understand why this doesn't work. Because in a "h:dataTable" I can tell the component to use an array as an input. Even more I don't know what a PropertyEditorManager is.
    So how can I pass the vector object to this custom component?

    I have tried with tomcat-6.0.14 and RI 1.2_06-b02-FCS
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
       http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
       version="2.1">
       <tlib-version>1.1</tlib-version>
        <short-name>d</short-name>
         <uri>http://eventsTable.com/</uri>
        <tag>
             <name>EventsTable</name>
               <tag-class>customcomponents.EventsTableTag</tag-class>
           <attribute>
               <name>events</name>
             <deferred-value>
                <type>java.util.Vector</type>
             </deferred-value>        
          </attribute>
        </tag>
    </taglib>
    package customcomponents;
    import javax.el.ValueExpression;
    import javax.faces.webapp.*;
    import javax.faces.component.*;
    public class EventsTableTag extends UIComponentELTag {
         private ValueExpression events = null;
         public String getRendererType() {
              return null;
         public String getComponentType() {
              return "EventsTable";
         public void release() {
              super.release();
              events = null;
         protected void setProperties( UIComponent component ){
              super.setProperties( component );
              component.setValueExpression("events", events);
         public void setEvents(ValueExpression events){
              this.events = events;
    }

  • Custom Component or Other solution to this problem...

    Hello,
    In my pages I have a wizard type menu consisting of:
    [ prev   curr-title    next ]
    The code to build this menu looks like so:
    <h:panelGrid
         id="top_flow_navigation"
         columns="3"
         styleClass="wizardNavTable"
         columnClasses="wizardNavColumn_Prev,wizardNavColumn_Curr,wizardNavColumn_Next">
         <h:commandLink
              action="back"
              accesskey="n">
              <h:outputText value="#{messages['flow.user.other.main.heading']}"/>
         </h:commandLink>               
         <h:outputText value="#{messages['flow.user.personal.main.heading']}"/>
         <h:commandLink
              action="submit"
              accesskey="n">
              <h:outputText value="#{messages['flow.user.security.main.heading']}"/>
         </h:commandLink>     
         <h:outputText value="#{messages['global.button.prev']}"/>                    
         <h:outputText/>                                             
         <h:outputText value="#{messages['global.button.next']}"/>
    </h:panelGrid>This code is currently repeated at the top and bottom of each page, and also on all the pages involved in the wizard.
    The only difference in the code on each page is the messages string.
    What I would like to know is ...:
    (1) how best to solve not repeating myself at the top and bottom of each page.
    JSP include would solve this, is there a JSF way?
    (2) ...it possible to wrap this code in a jsp tag and pass in the messages binding string as a parameter...I have tried this before but sadly passing #{...} into a tag throws up errors.
    Is wrapping this all in a custom JSF component the solution?
    Thanks.
    JC.

    Create a custom component. You may define your own attributes to pass the parameters.
    For example:<custom:component messages="blah" />

  • How do I pass a local variable as a parameter to a JSP Tag File?

    I wrote a custom JSP tag file, and I want to pass a local variable to it through a parameter, like this:
    <% Integer someValue = new Integer(-5); %>
    <my:TestTag value="someValue"/>
    This doesn't work though - the result is the string someValue. Trying to do this doesn't work either:
    <% Integer someValue = new Integer(-5); %>
    <my:TestTag value="someValue"/>
    the value attribute ends up being null.
    I know I can work arount by putting the local variable in the request attributes then using ${}, but that seems like a lot of unecessary work. Does anyone know I can just pass a local variable to the custom tag through the custom tags parameter list?

    I'm far from beeing an expert, but this may be a clue (?)
    Basically, the rule is: everything you want to be considerred as Java must be in a
    JSP tag.
    As an example, think of how you would do to pass the litteral string "someValue" otherwise. Then you may imagine other related issues...

  • Pass an int64 variable by reference from CVI to Teststand

    I tried searching for this problem but couldn’t find a solution. I run test scripts that call a function in C AA_Dat_Get_Statistic( Stats_Record *p_stats ). If I call this function, I sometimes get system level errors (-17001, -17002), TestStand will sometimes crash, and a load of other problems. These errors do not occur until steps after. If I take out this call, TestStand will not crash. There is an obvious problem with this function.
    I wrote a program in C that calls this function. By bypassing TestStand, I avoid crashes too.
    Stats_Records contains a few unsigned _int64 variables. The custom struct in TestStand uses another custom struct called Int64. Int64 contains two double variables, High and Low. In short, the variables being passed as a 64 integer are being stored in two 32 double.
    Does anyone know if passing by reference an int64 will cause these memory crashes? Is this how I should handle this or is there a better way.
    Thanks in advance. ⨪

    Below is the structure and function:
    typedef struct
        unsigned __int64 frame_count;
        double                                   BER;
      }   Stats_Record;
    AA_Dat_Get_Statistics
                       (int p_card, int p_channel, Stats_Record *p_stats)
        typedef union
          { __int64  int64_BER;
            double   float64_BER;
          }  BER_Union;                  
       BER_Union  BER;
        memset (&aa_stats, 0, sizeof(aaSTATS_DATA64));
        aa_status = aa_datGet (aa_handle, aa_channel, AA_DATAID_STATISTICS64, &aa_d_ptr);
        p_stats->frame_count           = aa_stats.ullFrameCount;
       BER.int64_BER        = aa_stats.floatCumulativeBER;
        p_stats->BER         = BER.float64_BER;
        return (status);
     }⨪

  • Passing function to a custom component

    Hey so I have button that is in a custom component, say:
    <mx:HBox width="200" height="72" xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Button width="72" height="72"  styleName="{buttonStyleName}"/>              
        <mx:Text text="{description}" width="100%" height="100%" textAlign="justify"/>
    </mx:HBox>
    And on another file i use it simply like this:
    <local:LabelComponent buttonStyleName="componentRssButton"  />                          
    However, I want the button on my custom component draggable, so I would like to pass a mouseMove handler but i could not find  a way to do that. Of course that easiest way is to have my whole custom component draggable like so:
    <local:LabelComponent mouseMove="componentRssButton"  />                
    but i want the button in the custom component the only one draggable.
    Thanks.

    it's wired to pass a function.
    EventListener should be the way to go.
    give your button an id, say btn1
    <mx:Button id='btn1' width="72" height="72"  styleName="{buttonStyleName}"/>
    and in your code
    <local:LabelComponent id='myComp' creationComplete='makeButtonDraggable()' buttonStyleName="componentRssButton"  />  
    <script>
    function makeButtonDraggable():vd
         myComp.btn1.addEventListener(mouseMove, componentRssButton);

  • Passing arguments to a custom component in the constructor

    I would like to know if it is possible to pass arguments to a
    custom component in the constructor when I'm instantiating it
    within Actionscript. I've not seen anyone do this, so at the moment
    I have a couple of public properties defined on the custom
    component and then do the following:
    var myComponent:TestComponent = new TestComponent();
    myComponent.propertyOne = true;
    myComponent.propertyTwo = 12;
    etc.
    Whereas I'd like to do something like:
    var myComponent:TestComponent = new TestComponent( true, 12
    Any ideas if this is possible?

    Another approach as opposed to creating init function is to link symbol with autogenerated class (just assign it a class but do not create *.as file for it) and use it just as graphical view with no functionality (well only MovieClip's functionality).
    ViewClip.as
    public class ViewClip extends MovieClip {
        public var view:MovieClip;
        public function ViewClip(){
            this.view = instantiateView();
            this.addChild(view);
        protected function instantiateView():MovieClip {
            return new MovieClip();
    Circle.as
    public class Circle extends ViewClip {
        public function Circle(scaleX:Number, scaleY:Number) {
            super();
        override protected function instantiateView():MovieClip {
            return new ClassView();

  • How to code spark custom component with variable number of (skin)parts?

    Hello. I'm trying to code a complex Spark custom component that may have a variable number of parts. To help you understand the requirements, the component can be visualized as an HSlider with a unlimited number of thumbs (as opposed to one).
    How do I, in general, represent these thumbs in the host component as well as the skin? If I had a fixed number of thumbs, say 5, I could easily represent them as 5 button SkinParts declaratively. However, it's not immediately clear to me how to deal with a variable number of them.
    I've studied the HSlider implementation as well as other components and can't find an example that fits this pattern. The closest thing that I can think of is to represent the thumbs as a DataGroup and provide a custom item renderer to render them. Couple that with the general HSlider behaviors that I need to preserve, such as the fairly involved local/global coordinate translations, I don't know whether the approach will work.
    Any better ideas? Thanks.

    #2 sounds utterly strange to me. How would I utilize the phase id?The code below shows my idea whereas I never validate it in any real projects:
    public class MyPhaseListener implements PhaseListener {
         private static final String IDKEY = "PHASEID";
         public static PhaseId getCurrentPhaseId() {
              return (PhaseId) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(IDKEY);
         public void beforePhase(PhaseEvent event) {
    event.getFacesContext().getExternalContext().getRequestMap().put(IDKEY,event.getPhaseId());
         public PhaseId getPhaseId() {
              return PhaseId.ANY_PHASE;
    }You can write your constructor like as:
    if (MyPhaseListener.getCurrentPhaseId().equals(PhaseId.RENDER_RESPONSE ) {
         /* create children because this is the first time to create the component */
    }

  • Passing variable to an outside component

    I intent to create a web site of products. Since there will
    be too many lines of code to work only with one file, I decided to
    create component for each state. Those component are simply VBox
    component including everything necessary to display the nature of
    the state. For an example, calling the state local:stateContactComp
    will show the state for contact (equivalent to a page of contact
    from the web 1.0 philosophy if I can say it in that way).
    Now, the problem I encounter at this moment is the current
    product. The home page is designed to navigate through the products
    available and once the user click on one product, he/she will be
    redirected to the state of product where the system will call the
    stateProductComp.mxml based on a VBox (but followed by many
    component inside to show the details of the product). This is basic
    but what I don't know yet is how to pass the current product (the
    one that the user clicked on) to the component which is called. At
    the beginning I sort of though that the component called was
    automatically binded to the main component but it seems to not. I
    alreay declared a public var currentProduct:Product in my
    stateProductComp.mxml but I still searching how to transfer the
    information.
    Preferably, I would prefer to use the main variable which
    have a similar line (public var currentProduct:Product) associated
    to a class to define the Product. I would prefer to use the main
    variable for memory worry but maybe there is no way to take care of
    the memory in this case (which I doubt!).
    Anyway, what I need to know is the best practice to work with
    separate files (for lenght of code source issue) while we are
    working with states.
    I hope I was enough clear to understand my problem, if not,
    please let me know.
    Keywords should be: passing a variable to a component in
    another file.

    I knew it was possible to do it and I found how!!!
    Simply by adding the value through the call of the component.
    In my case, I was calling the component while changing state
    so the line of code was as follow:
    1) <mx:State name="stateProduct">
    2) <mx:RemoveChild target="{menu2Items}"/>
    3) <mx:AddChild relativeTo="{pageContent}"
    position="lastChild" creationPolicy="all">
    4) <mx:VBox id="pageContent2" width="100%"
    height="100%">
    5) <local:stateLampeComp
    currentProduct="{vCurrentProduct}"/>
    6) </mx:VBox>
    7) </mx:AddChild>
    8) </mx:State>
    So the line 5 show my call to the component containing all
    the layout to display the details of the product pre-clicked and by
    indicate currentProduct (variable from the stateLampeComp
    component) = {vCurrentProduct} (variable from the caller
    component), the system can now inter-connecting the values from one
    component to the other.
    Voilà!

  • How do you reference a valueObject located in main to a custom component created in Catalyst?

    Hello,
    I have been working with the Catalyst Beta 2 / Flash Builder beta trying to create a photogallery and have hit a little bit of a snag, try as I might I can't seem to find the answer anywhere. I am still new to Flex so please excuse me if this is a basic question, I have been trying to understand more about Flex to make my designs in Catalyst better.
    I found this video on Adobe TV: http://tv.adobe.com/watch/rich-internet-applications-101/ria-stepbystep-16-binding-a-data- service-to-flash-builder-components/
    It's wonderful and I have the datalist I created in Catalyst working with the XML file I generated but I designed my little photogallery a bit diffrent, I created a Custom Component in Catalyst so that when you click an item on the DataList it pop's up a little screen with a larger photo in on it, rather then having an image in the main application. Now my problem seems to be that I can't refrence the valueObject I created with the wizard as it's in my Main.mxml file, is there a way to refrence it from my Custom Component so the larger image will display? Is there a way to let the component know which item on the dataList in the main application is selected and display the correct image?
    I should also say I really enjoy working with the Beta for both Flash Builder / Catalyst, thanks for the hard work!
    Thanks for the help,
    Chris

    I am afraid you cannot bind to static properties in Windows Store Apps. It is simply not supported.
    You could create a proxy class that exposes the static command property and bind to this property of an instance of the proxy object:
    http://stackoverflow.com/questions/14186175/bind-to-a-static-field-in-windows-8-xaml
    http://stackoverflow.com/questions/4708711/how-can-i-use-the-xstatic-extension-for-phone7-silverlight-apps
    You will of course have to create an instance of the proxy object. There is no way around this.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

  • Best strategy for variable aggregate custom component in dataTable

    Hey group, I've got a question.
    I'd like to write a custom component to display a series of editable Things in a datatable, but the structure of each Thing will vary depending on what type of Thing it is. So, some Things will display radio button groups (with each radio button selecting a small set of additional input elements, so we have a vertical array radio buttons and beside each radio button, a small number of additional input elements), some will display text-entry fields, and so on.
    I'm wondering what the best strategy for tackling this sort of thing is. I'm sort of thinking I'll need to do something like dynamically add to the component tree in my custom component's encodeBegin(), and purge the extra (sub-) components in encodeEnd().
    Decoding will be a bit of a challenge, maybe.
    Or do I simply instantiate (via constructor calls, not createComponent()) the components I want and explicitly call their encode*() and decode() methods, without adding them to the view tree?
    To add to the fun of all this, I'm only just learning Faces (having gone through the Dudney book, Mastering JSF, and writing some simpler custom components) and I don't have experience with anything other than plain vanilla JSP. (No EJB, no Struts, no Tapestry, no spiffy VisualDevStudioWysiwyg++ [bah humbug, I'm an emacs user]). I'm using JSP 2.0, JSF 1.1_01, JBoss 4.0.1 and JDK 1.4.2. No, I won't upgrade to 1.5 (yet).
    Any hints, pointers to good sample code? I've looked at some of the sample code that came with the RI and I've tried to navigate the JSF Blueprints stuff, but I haven't really found anything on aggregating components into a custom component. Did I miss something obvious?
    If this isn't a good question, please let me know how I can sharpen it up a bit.
    Thanks.
    John.

    Hi,
    We're doing something very similar. I had a look at the Tomahawk Date component, and it seems to dynamically created InputText components in the encodeEnd(). However, it doesn't decode this directly (it only expects a single textual value). I expect you may have to check the request yourself in decode().
    Other ideas would be appreciated, though - I'm still new to JSF.

  • Pass a parameter to custom component -  get null

    Main MXML (part of code):
    <s:Application
    xmlns:ns1="*"
    creationComplete="init();>
    import MyComponent;
    private function init():void {
    var myArray:Array=["FFF","TTT","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 main.
    public class MyComp extends Sprite
            private var _getArray:Array;
            public function MyComp()
            public function get getArray():Array
                return _getArray;
            public function set getArray(value:Array):void
                trace("setter ", value);
                _getArray = value;
    <?xml version="1.0" encoding="utf-8"?>
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:ns1="*"
                   minWidth="955" minHeight="600"
                   creationComplete="init();">
        <fx:Script>
            <![CDATA[
                private function init():void {
                    var myArray:Array=["FFF","TTT","RRR"];
                    myComp.width=200;
                    myComp.height=200;
                    myComp.getArray = myArray;
                    myContainer.addChild(myComp);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <ns1:MyComp id="myComp"/>
        </fx:Declarations>
        <mx:UIComponent id="myContainer"/>
    </s:Application>
    Not sure this is what you after though but it traces:
    setter  FFF,TTT,RRR
    Why do you add to rawChildren?
    C

  • Dynamic datatable in custom component

    hi all,
    i'm working on a custom jsf component and this component will create a datatable dynamically. (you can see component details from http://www.jroller.com/page/hasant?entry=creating_dynamic_datatable_inside_of AND http://www.jroller.com/page/hasant?entry=jsf_question_for_community_what)
    the question is; when i want to add a selection column(dynamically), how can i handle its selected values?
    i mean, if i have created this datatable in a page with designer, i would bind an Integer[] to that selection column's checkboxes. But i have to add this selection column dynamically from my component. So, how can i GET and SET the selection columns values. Since this is a custom component, there is no backing bean for value binding to this component.
    when i resolve the request param string to get the selected rows, it's working(=i can see the selected rows somehow..) but, i can not set that values again while encoding that column after a submit.
    here is my row selection column encoding code;
         private void addSelectionColumnToTable(FacesContext context, UIData table) {
              UIColumn column = new UIColumn();
              HtmlInputRowSelect rowSelect = new HtmlInputRowSelect();
              rowSelect.setId("rowSelect1");
              rowSelect.setStyleClass("inputRowSelect");
              rowSelect.setValue(m_selectedRows);
              column.getChildren().add(rowSelect);
              table.getChildren().add(column);
         }In the code above, rowSelect.setValue(m_selectedRows); part not effecting anyhing. m_selectedRows variable includes row numbers(in an Integer array) that i want to see as selected.
    any solution/recommendation?

    Well if you are still interested in using a text component
    instead of a Button the way you would go about this is using
    textWidth. Here's how I've done it before using a text / label
    whatever you want that shows text.
    // => Set our text we got from database
    myText.text = "This is the text I got from the DB";
    // => Validate it so that way we make sure we get right
    numbers
    myText.validateNow();
    // => Find out how wide our text really is.
    var textWidth:Number = myText.textWidth
    // => Reset the width of our text component and add 20 for
    a little buffer
    myText.width = textWidth + 20;
    Now my suggestion is if your going to be dynamically creating
    these on the fly from a database call you throw it into a method /
    class and have that do all the work for you so all you have to do
    is pass the text to it and it resizes itself based on the example
    above.

  • Can I define a constructor for a Custom Component?

    I have a custom component which I instantiate through ActionScript.  For the sake of clean code, I would like to be able to assign the variables through the constructor like any other class:
    var myComp:CustomComponent = new CustomComponent(arg1, arg2, ...);
    However, when I try to write a constructor in the Script block for the component, it gives me a compile error telling me that I have multiple constructors:
    //In Script tag//
    public function CustomeComponent(arg1, arg2 ...):void { ... }
    Are we not able to define constructors for Custom Components?

    If this post helps, please mark it as such.
    If you create an array variable in your MXML component, and then set it with myVar="[val1, val2, val3]" in the opening tag of your component, then you basically have a constructor in MXML.
    You can use the [Bindable] metadata tag in three places:
    Before a public class definition.
    The [Bindable] metadata tag makes usable as the source of a binding expression all public properties that you defined as variables, and all public properties that are defined by using both a setter and a getter method. In this case, [Bindable] takes no parameters, as the following example shows:
    [Bindable]
    public class TextAreaFontControl extends TextArea {}
    The Flex compiler automatically generates an event named propertyChange, of type PropertyChangeEvent, for all public properties so that the properties can be used as the source of a data binding expression.
    If the property value remains the same on a write, Flex does not dispatch the event or update the property, where not the same translates to the following test:
    (oldValue !== value)
    That means if a property contains a reference to an object, and that reference is modified to reference a different but equivalent object, the binding is triggered. If the property is not modified, but the object that it points to changes internally, the binding is not triggered.
    Note: When you use the [Bindable] metadata tag before a public class definition, it only applies to public properties; it does not apply to private or protected properties, or to properties defined in any other namespace. You must insert the [Bindable] metadata tag before a nonpublic property to make it usable as the source for a data binding expression.
    Before a public, protected, or private property defined as a variable to make that specific property support binding.
    The tag can have the following forms:
    [Bindable]
    public var foo:String;
    The Flex compiler automatically generates an event named propertyChange, of type PropertyChangeEvent, for the property. If the property value remains the same on a write, Flex does not dispatch the event or update the property.
    You can also specify the event name, as the following example shows:
    [Bindable(event="fooChanged")]
    public var foo:String;
    In this case, you are responsible for generating and dispatching the event, typically as part of some other method of your class. You can specify a [Bindable] tag that includes the event specification if you want to name the event, even when you already specified the [Bindable] tag at the class level.
    Before a public, protected, or private property defined by a getter or setter method.
    You must define both a setter and a getter method to use the [Bindable] tag with the property. If you define just a setter method, you create a write-only property that you cannot use as the source of a data-binding expression. If you define just a getter method, you create a read-only property that you can use as the source of a data-binding expression without inserting the [Bindable] metadata tag. This is similar to the way that you can use a variable, defined by using the const keyword, as the source for a data binding expression.
    The tag can have the following forms:
    As far as binding, you can add the [Bindable] tag before the class declaration to make bindable all public properties defined as variables, and all public properties defined by using both a setter and a getter method.

Maybe you are looking for

  • HELP!!! - How to send a file to a server?

    How to send a file(as it is) to the server i'm connected to, if i have access to the output-stream?

  • Date into MySQL db

    Customer fills out a form, a hidden field is holding todays date, like so: <cfoutput>'#LSDateFormat(now(), "yyyy-mm-dd")#'</cfoutput> The date doesn't get inserted. If I put an actual date into the hidden field, it gets inserted, but I've tried just

  • Problem in configuring windows in FPM

    Need Suggestions to configure windows with message types with FPM

  • Exteme slow commits

    Hi, I am experiencing problems recently with Oracle XE running on server 2003. In my code (java) auto commit is set to false and I do explicit commit in the code. However, in last couple of days, I started noticing big delay between insert and actual

  • How to stream netflix with iOS 7

    Since updating to Apple iOS 7 I am unable to stream movies on my tv.  Could use some advise please. Dolores