Announcement Announcement Module
Collapse
No announcement yet.
How could I inject Array object or ArrayCollection? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How could I inject Array object or ArrayCollection?

    Hi, I just got the latest version of spring actrionscript and trying to play around this news toy. One of the experiment is injecting array from application context into the application to generate a combo box.

    The result is, yes, it works! but I should have to declare the object in the right way. because the spring looks like inject the Array in array to the application for me.

    Did anyone try with this already?

    Config.xml
    HTML Code:
    <object id="userArray" class="Array">
        <constructor-arg>
          <array>
            <object class="com.teerasej.User">
              <property name="username" value="usernameAAA"/>
              <property name="password" value="mepass"/>
            </object>
            <object class="com.teerasej.User">
              <property name="username" value="usernameBBB"/>
              <property name="password" value="mepass"/>
            </object>
          </array>
        </constructor-arg>
      </object>
    and this is the code in MXML, _userArr variable has defined as bindable already.
    Code:
    protected function onACLoadComplete( event : Event ) : void
    {
    				
    	_userArr = ac.getObject("userArray");
    				
    }

    HTML Code:
    <mx:ComboBox x="313" y="375" dataProvider="{_userArr}" labelField="username"/>

  • #2
    Hi,

    you can create an ArrayCollection like this:

    Code:
    <object id="users" class="mx.collections.ArrayCollection">
      <constructor-arg>
        <array>
          <object class="com.teerasej.User">
            <property name="username" value="usernameAAA"/>
            <property name="password" value="mepass"/>
          </object>
          <object class="com.teerasej.User">
            <property name="username" value="usernameBBB"/>
            <property name="password" value="mepass"/>
          </object>
        </array>
      </constructor-arg>
    </object>
    An array should be:

    Code:
    <object id="userArray" class="Array">
        <constructor-arg>
            <object class="com.teerasej.User">
              <property name="username" value="usernameAAA"/>
              <property name="password" value="mepass"/>
            </object>
        </constructor-arg>
        <constructor-arg>
            <object class="com.teerasej.User">
              <property name="username" value="usernameBBB"/>
              <property name="password" value="mepass"/>
            </object>
        </constructor-arg>
      </object>
    regards,
    Christophe

    Comment


    • #3
      Thank you for your fast replied, Christophe.

      I have used Spring.net for a long time. So I think that make me doing wrong thing

      Comment

      Working...
      X