Hi,

Well, i think i didn't explain my problem very well.
The problem wasn't with the repeater, but the repeater parent.

let's say my application is like this

<mx:Panel id="displayScreen">
  <mx:Repeater id="rep">
     <mx:Button id="toto"/>
     <mx:TextInput id="tata"/>
  </mx:Repeater>
</mx:Panel>

I have to code a very generic code, which doesn't need to know the
component ids, even if they have some.

I made a method which need to know to component parent that need to be
match with the datas.

let say my method is fillFields(parent:UIComponent, datas:XML). then
i'll use it like this

fillFields(displayScreen, datas).

the method will check the parent childs, and recursively will find all
the component in the dispalyScreen and check in the XML document if
there is a data for the component.

Some guys will tell me to use the databinding, but the datas that i
receive from my httpService isnt well formed, that's why i have to
manually match datas with components.

Now the problem is that when i'll call the fillFields method on the
panel (like in the example), the getChildren method of the panel wont
give the repeater like a child. If i want to know the repeaters in the
panel, i have to use the mx_internal namespaced method childRepeaters.

I managed to change the way i use the repeater, and i created a custom
component which is a box with the repeater inside. This way the
getChildren method will be able to get the box and pass it the datas.

This make me create the repeater in ActionScript, what's a real pain.
I overrided the addchild method and used this one

override public function addChild(child:DisplayObject):DisplayObject {
        var descriptorProps:Object = {};

        descriptorProps.type = UIComponent(child).descriptor.type;
        descriptorProps.id = UIComponent(child).descriptor.id;
        descriptorProps.propertiesFactory =
UIComponent(child).descriptor.propertiesFactory;
        descriptorProps.events = UIComponent(child).descriptor.events;
        descriptorProps.effects = UIComponent(child).descriptor.effects;
        descriptorProps.document = UIComponent(child).descriptor.document;
        
        _repeater.childDescriptors.push(new
UIComponentDescriptor(descriptorProps));
        return _repeater.addChild(child);
}

And now i have a problem with the initializeRepeater method. all the
component i use are Box-based, and i have this error now

TypeError: Error #1034: Echec de la contrainte de type : conversion de
[EMAIL PROTECTED] en com.probtp.fwg.components.PButton impossible.
        at
mx.core::UIComponent/createReferenceOnParentDocument()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8199]
        at
mx.core::Container/createComponentFromDescriptor()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:3648]
        at
mx.core::Repeater/createComponentFromDescriptor()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Repeater.as:734]
        at
mx.core::Repeater/createComponentsFromDescriptors()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Repeater.as:786]
        at
mx.core::Repeater/initializeRepeater()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Repeater.as:529]
        at
com.probtp.fwg.components::Prep/fillInternalFields()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_Core\src\com\probtp\fwg\components\Prep.as:79]
        at com.probtp.fwg.components::Prep/set
dataProvider()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_Core\src\com\probtp\fwg\components\Prep.as:70]
        at
com.probtp.util::ScreenUtils/fillFields()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_Core\src\com\probtp\util\ScreenUtils.as:198]
        at
com.probtp.util::ScreenUtils/fillFields()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_Core\src\com\probtp\util\ScreenUtils.as:205]
        at
com.probtp.IG_ContactsModule.components::F0010/onResponseReceive()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_ModuleCore\src\com\probtp\IG_ContactsModule\components\F0010.mxml:32]
        at
com.probtp.IG_ContactsModule.components::F0010/initModule()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_ModuleCore\src\com\probtp\IG_ContactsModule\components\F0010.mxml:24]
        at
com.probtp.IG_ContactsModule.components::F0010/___F0010_Canvas1_creationComplete()[C:\Code\CC_Views\PB19664_IG_ClientLeger-project_Dev1_View1\vob0003-vob\IG_ClientLeger-project-component\IG_ModuleCore\src\com\probtp\IG_ContactsModule\components\F0010.mxml:2]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9051]
        at mx.core::UIComponent/set
initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
        at
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:698]
        at Function/http://adobe.com/AS3/2006/builtin::apply()
        at
mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460]
        at
mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403]



--- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> And a few hints:  Give the conponent you want to access an id. 
Repeater will automatically build an array of references to the
instances.  Access them using myId[n].
> 
>  
> 
> But I would suggest creating a custom component and repeating that.
 Encapsulate the reformatting functionality in that component.  Pass
in a reference to the entire currentItem via a public property.
Implement  the property as a setter function so you can invoke the
formatting when it changes.  Be aware that setters can fire before the
children are created.
> 
>  
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Paul Andrews
> Sent: Wednesday, October 15, 2008 7:28 AM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] The Repeater control and the getChildren()
method
> 
>  
> 
> ----- Original Message ----- 
> 
>       From: schwazel <mailto:[EMAIL PROTECTED]>  
> 
>       To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com>  
> 
>       Sent: Wednesday, October 15, 2008 9:02 AM
> 
>       Subject: [flexcoders] The Repeater control and the getChildren() method
> 
>        
> 
>        
> 
>       Hello,
>       
>       I'm working on a flex application and i've an issue with the
repeater control.
>       In my application, i fill my component when i get some datas from
my httpService component.
>       
>       I have to get every component of my application and go find its
prolly value in the datas.
>       I do that because whe i have a list the datas for the list arent
well formatted.
>       
>       The problem that i have with the repeater is that the getChildren()
method of the Container class doesn't count the repeaters as a child
of the container.
>       
>       I found that in the Container class there is a mx_internal get
méthod named childRepeaters that'd solve my problem, but as it's
specified on the adobe site,
>       Variables in the mx_internal namespace are ones that Adobe thinks
have a high probability of changing in future versions of Flex, so 
they reside in a special namespace so developers know they may change.
>       
>       How can i easily use the repeater control without directly using
variables under mx_internal namespace?
> 
>        
> 
> First step should be google.
> 
>  
> 
> http://www.adobe.com/devnet/flex/quickstart/using_the_repeater/
<http://www.adobe.com/devnet/flex/quickstart/using_the_repeater/> 
> 
>  
> 
> From the page:
> 
>  
> 
> The Repeater component places references to individual instances of
a repeated component in an array. You define the name of the array by
setting the id attribute of the component that you place in the Repeater.
> 
> In the following example, the RadioButton control in the
<mx:Repeater> tag has its id property set to buttonsArray. The
Repeater component adds into this array a reference to each child
RadioButton that it creates. You can refer to these individual
children by using an index-based look-up on the array. For example,
buttonsArray[0] returns a reference to the first RadioButton in the
Repeater.
> 
> Paul
> 
>       
>       
>       Thanks in advance.
>       
>       Feel free to ask for further details.
>       -- 
>       Choisel.
>


Reply via email to