RE: [flexcoders] Re: better option than repeater?

2009-07-27 Thread Battershall, Jeff
This would be my approach:

You need two dataProviders (ArrayCollections), one being for the available 
modules and the other for your list of staff. You'd only need two remote 
objects to retrieve them.

Your modules dataprovider would be passed into each component instance and used 
by the component to generate your list of available modules with checkboxes.  

Your repeater is going to accept the staff list dataProvider.  As it loops over 
the ArrayCollection, it will pass the selected modules for a given staff member 
to your checkbox component. It's up to you to write the setter function to pass 
the selected values into your checkbox component and to set the 'selected' 
property of each checkbox accordingly.  

Jeff

-Original Message-
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of valdhor
Sent: Monday, July 27, 2009 2:22 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: better option than repeater?

I don't quite get what you are trying to do.

Create a component. This component will display each staff member. Create a 
public variable to hold each staff record (Value Object) and pass that record 
to the component inside the repeater. The example I posted shows how to do this.

So, there is only one call to the RemoteObject service that returns an array 
collection of staff objects. The data provider of the repeater is set to this 
array collection. As the repeater runs, each instance of the component gets one 
staff record. You use this record to figure out which checkbox is to be set.

An mx:RemoteObject can be used wherever you need it. I have components with 
Remote Objects that are repeated. The first remote object call gets the data 
for each component which then makes its own RO call to get further data if the 
user selects that component. As an example, in your situation, you could have 
each staff member displayed with a button labeled More Info. If a user clicks 
this button the RO in this component will make a call to the server to get more 
info for this staff member.


HTH



Steve




--- In flexcoders@yahoogroups.com, postwick p...@... wrote:

 OK, thanks to the below example, I have made some progress on setting up
 my first custom itemRenderer.  Code can be viewed here: 
 http://www.ubeek.com/Flex/testrend.mxml
 
 As I mentioned before, my goal is to display a list of Staff.  One of
 the fields (moduleAccess) in the Staff record is a list of integers
 (i.e.  1,3,17,25).  I have a table that contains a list of modules
 (SEQ, MODULENAME).  For each Staff displayed by the List's itemRenderer,
 I need to loop through all the modules and output a checkbox...and if
 the module's SEQ is in the Staff's moduleAccess list then the box should
 be checked.
 
 I tried setting up a remoteObject inside the custom renderer, but no
 matter where I put it it gave me a parse error.  I guess it doesn't like
 mx:RemoteObject inside a component.  So I put it outside the component,
 but then the script function inside the component didn't seem able to
 access the RemoteObject's data.  Although it was what I initially tried
 to do (with the RO inside the component) I don't really want to do that
 as it seems highly inefficient to query the database for every Staff
 record.  It seems I should be able to execute the RO just once and then
 pass the resulting list of modules to the component so I can loop
 through it to output all the checkboxes (and for each record check the
 SEQ against the Staff's moduleAccess, which I know how to do).
 
 So the question is - how do call the RO just once and pass the result
 into the component (as an ArrayCollection or something) so I can loop
 over it repeatedly instead of actually calling it and hitting the
 database repeatedly?
 
 Thanks,
 Paul
 
 
 --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ 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
   }
   ]]

Re: [flexcoders] Re: better option than repeater?

2009-07-20 Thread claudiu ursica
I'd use lists with custom item renderers. Repeaters are killers for perormance 
even when you tell them to cache children 

C





From: valdhor valdhorli...@embarqmail.com
To: flexcoders@yahoogroups.com
Sent: Monday, July 20, 2009 9:45:44 PM
Subject: [flexcoders] Re: better option than repeater?

  
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:CheckBoxCom ponent id=checkBoxs person={Person( myStaff.currentI 
tem)} /
/mx:Repeater

HTH

Steve

--- In flexcod...@yahoogro ups.com, postwick p...@... 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



   


  

Re: [flexcoders] Re: better option than repeater?

2009-07-20 Thread claudiu ursica
I'm talking in theory right now cause its late here ... you should have all 
your data structured in the model. As you have nested repeaters you can use 
nested lists Both of the are fed via data providers. Inside the first list 
you override the data setter and you there you can feed the second list 
dynamically.Keep in mind that you can inject data into the renderer where you 
have the nested list. Use binding also if you can (bind the list to the model 
data)... If you cannot manage it give me a private message or a reply to this 
tomorrow and I'll try to sketch something maybe you can send me your data 
structure and I'll mock something on that ...

C





From: postwick p...@ubeek.com
To: flexcoders@yahoogroups.com
Sent: Monday, July 20, 2009 9:54:46 PM
Subject: [flexcoders] Re: better option than repeater?

  
Can you give me a brief example of how you would convert a single repeater with 
two nested repeaters into a List with custom item renderers?

Thanks,
Paul

--- In flexcod...@yahoogro ups.com, claudiu ursica the_braniak@ ... wrote:

 I'd use lists with custom item renderers. Repeaters are killers for 
 perormance even when you tell them to cache children 
 
 C
 
 
 
 
  _ _ __
 From: valdhor valdhorlists@ ...
 To: flexcod...@yahoogro ups.com
 Sent: Monday, July 20, 2009 9:45:44 PM
 Subject: [flexcoders] Re: better option than repeater?
 
 
 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:CheckBoxCom ponent id=checkBoxs person={Person( myStaff.currentI 
 tem)} /
 /mx:Repeater
 
 HTH
 
 Steve
 
 --- In flexcod...@yahoogro ups.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