Thanks for the example.  I know that I could make certain things a lot easier 
by setting up classes and components, but I don't have a lot of practice at it. 
 Hopefully this will get me started and I'll get it figured out.  I know it 
would simplify my code - there are many places where I repeat the same kind of 
display, with different data, and so far just write functions that are result 
handlers from remoteobjects and the functions spit out the objects I need and 
addChild them.  At the moment I am a bit mired in the "repeat over a recordset 
and spit out code" mode of thinking, thanks to years ColdFusion, Perl, asp, 
HTML, etc.

--- In flexcoders@yahoogroups.com, "valdhor" <valdhorli...@...> wrote:
>
> As a quick and dirty...
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="vertical"
>      xmlns:custom="Components.*">
>      <mx:Script>
>          <![CDATA[
>              import mx.collections.ArrayCollection;
> 
>              [Bindable] private var staffArrColl:ArrayCollection;
>          ]]>
>      </mx:Script>
>      <mx:Repeater id="myStaff" dataProvider="{staffArrColl}">
>          <custom:CheckBoxComponent id="checkBoxs"
> person="{Person(myStaff.currentItem)}" />
>      </mx:Repeater>
> </mx:Application>
> 
> CheckBoxComponent.mxml:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";
> creationComplete="onCreationComplete()">
>      <mx:Script>
>          <![CDATA[
>              import ValueObjects.Person;
> 
>              public var person:Person;
> 
>              private function onCreationComplete():void
>              {
>                  // From person object make a remote object call to get
> Modules and Queues
>                  // When remote object calls return, create checkboxes
> appropriately
>              }
>          ]]>
>      </mx:Script>
> </mx:VBox>
> 
> Person.as:
> package ValueObjects
> {
>      [RemoteClass(alias="Classes.Testing.Person")]
>      [Bindable]
>      public class Person
>      {
>          //instance variables
>          private var _name:String;
>          private var _id:String;
> 
>          //accessor methods
>          public function get name():String {return _name;}
>          public function get id():String {return _id;}
> 
>          //mutator methods
>          public function set name(name:String):void {_name = name;}
>          public function set id(id:String):void {_id = id;}
>      } // end class
> }//end package
> 
> I have not included any remote object calls or result handlers. I'll
> leave that up to you.
> 
> Keep in mind that Flex is object oriented. One of the ideas behind OOP
> is encapsulation. If you can encapsulate all the properties and methods
> of something and then repeat that, the possibilities are endless.
> 
> 
> HTH
> 
> 
> 
> Steve
> 
> --- In flexcoders@yahoogroups.com, "postwick" <paul@> wrote:
> >
> > Can you give me a brief example of code that would achieve the part
> where you say "create a component"?
> >
> > Keep in mind the number of checkboxes and their labels is not static. 
> There are three tables involved: staff, modules, and queues.  The
> checkboxes are created dynamically from the records returned from the
> modules and queues tables.
> >
> > --- In flexcoders@yahoogroups.com, "valdhor" valdhorlists@ wrote:
> > >
> > > I use repeaters quite a lot and like them.
> > >
> > > What I do is to create a component (Which sometimes contains other
> components) and the repeat that.
> > >
> > > In your situation, I would create a component with all of your check
> boxes and save button. This component would have all of the
> functionality to display which check boxes are selected as well as the
> save button click handler. It would also have a public property that
> would take a data object. On creation complete of this component, it
> would check the values of the data object and set the check boxes
> appropriately.
> > >
> > > Then, I would repeat this component passing in the data objects
> returned from the remote object call...
> > >
> > > <mx:Repeater id="myStaff" dataProvider="{staffArrColl}">
> > > <custom:CheckBoxComponent id="checkBoxs"
> person="{Person(myStaff.currentItem)}" />
> > > </mx:Repeater>
> > >
> > >
> > > HTH
> > >
> > >
> > >
> > > Steve
> > >
> > >
> > > --- In flexcoders@yahoogroups.com, "postwick" <paul@> wrote:
> > > >
> > > > I don't like repeaters.  They are too clumsy.  The biggest
> drawback is an inability to access values after the repeater has finish
> executing.  It's not the same as, for example, looping over values and
> generating static HTML using ColdFusion.  I seem to always end up having
> to navigate up and down through the parents/children of the objects and
> storing values I need in properties like name, automationName, etc. 
> This is clumsy and messy.
> > > >
> > > > As an example, I have a section of my application where I want to
> list the names of people from a table, and for each person generate a
> set of checkboxes that designate access to certain areas of the
> application.  For example: http://www.ubeek.com/images/staffrepeater.jpg
> > > >
> > > > That is one main repeater that loops through the staff (records
> returned from remoteObject) and inside that repeater two other repeaters
> (also from remoteObjects) that generate the checkboxes.
> > > >
> > > > I can't simply pass the primary key of the staff for which the
> Save button was clicked, by putting
> click="saveClick({staffRepeater.currentItem.SEQ})" into the button
> object.  When I do that and click it I get an error about "repeater is
> not currently executing" or something like that.
> > > >
> > > > I don't want to resort to a datagrid and then "click to edit" then
> bring up a form kind of process.  I want it as few clicks as possible.
> > > >
> > > > Is there a better way to display data in a custom way like this,
> without using repeaters, so that I can more easily access the child
> objects and their properties?
> > > >
> > > > Thanks,
> > > > Paul
> > > >
> > >
> >
>


Reply via email to