Hi guys,
Maybe we are missing something and, perhaps, it would be "interesting" to 
investigate a bit more "when we have time to dedicate to it".....
First I want to say that "there was a time" when this was happening to me: crux 
did not work directly in a PopPup and I had to activate and deactivate it 
manually, as Brian says, BUT at a certain point "it started to work" and 
nowadays it still works for me ☹

I briefly describe the components and the calling method:


  *   Component to display in the PopUp (= SomePopupContent, from Brian's 
example):
     *   <j:SectionContent>



     *   <j:beads> <ContainerDataBinding/> </j:beads>



     *   I define injections as follows:



                                               [Bindable]

                                               [Inject(source="shellModel", 
required="true")]

                                               public var shellModel:ShellModel;



               … source="shellModel", Corresponds to the localId of the model 
defined in the BeanProvider, inside App.mxml

                                               <crux:BeanProvider>
                                                               <wp:ShellModel 
id="shellModel"/>
                                                               
<wp:ShellController/>
                                               </crux:BeanProvider>


  *   Example of Call (the view from where the call is made also has injected 
models)

            private var popupAux:PopUp;
            public function showPopUpForm():void
            {
                    var contentPopup:PermissionsPopUp;
                    contentPopup = new PermissionsPopUp();
                    contentPopup.id = "vContentXX";
                    contentPopup.description = "Level: " + tCodigo.text + " - " 
+ tDescription.text;

                    if(_currentResponsiveSize == ResponsiveSizes.PHONE)
                        contentPopup.percentWidth = 80;
                    else
                        contentPopup.width = 500;
                    contentPopup.percentHeight = 80;
                    contentPopup.readOnly = (primaryModel.currentGrState != 
UtilConstants.GRSTATE_EDITING);
                    contentPopup.addEventListener("closePopUp", onPopUpClose);

                    if(!popupAux)
                    {
                        popupAux = new PopUp();
                        popupAux.modal = true;
                        popupAux.content = contentPopup;
                        addElement(popupAux);
                    }
                    else
                    {
                        popupAux.content = contentPopup;
                    }
                }

                if(!popupAux.open)
                    popupAux.open = true;
            }

Why does it work? I don't know ☹... Roman could you compare this example with 
your completed code?

Hiedra
De: Brian Raymes <[email protected]>
Enviado el: lunes, 22 de noviembre de 2021 23:29
Para: [email protected]
Asunto: RE: [EXTERNAL] Re: Crux - ItemRenderer

To make Crux work within popups, simply dispatch the ADD_BEAN event for the 
content before opening it. For example:

var somePopupContent:SomePopupContent = new SomePopupContent();
dispatchEvent(new BeanEvent(BeanEvent.ADD_BEAN, somePopupContent));

var popup:PopUp = new PopUp();
popup.modal = true;
popup.content = somePopupContent;

addElement(popup);

popup.open = true;

Then, before closing, remove it:

dispatchEvent(new BeanEvent(BeanEvent.REMOVE_BEAN, this));
dispatchEvent(new Event('closePopUp'));

Hope this helps.

Brian


From: Roman Isitua <[email protected]<mailto:[email protected]>>
Sent: Monday, November 22, 2021 12:33 PM
To: [email protected]<mailto:[email protected]>
Subject: [EXTERNAL] Re: Crux - ItemRenderer

I can confirm that crux setter injection does not work inside pop up. The work 
around I have come up with is to do the setter injection in the parent view 
then pass the variable to my pop.

By setter injection I mean,

 [Inject( source = "acctController.estateSearchList", bind = "true" )]
        public function setEstateSearchList(val:ArrayList):void
        {
             trace(" injected estateSearchList. hurray !! ");

            this.estateSearchList = val;

            trace(" estateSearchList has been set ! ");
        }


However, I have noticed this style of injection works

  [Inject]
        public var configData:ConfigData;


Regards,



On Sun, Nov 21, 2021 at 1:07 AM Greg Dove 
<[email protected]<mailto:[email protected]>> wrote:
I can't say for certain Maria, because it's been some time since I used Crux.

Are your renderers in the main app, or are they in a popup? Crux may not work 
inside a popup, without some tweaking and tuning for JSStageEvents, iirc.

Beyond that I think Crux is not particularly suitable for ItemRenderers. At 
least I would personally try to avoid using it in this case, unless the 
renderer count is always relatively low.

One of the key differences between the JS implementation vs. the Flash 
implementation is when the bean setup is run to support processing the view. 
This is triggered by 'addedToStage' event, which does not have directly 
comparable support in the browser.
JSStageEvents bead creates a simulated 'addedToStage' event. But the way that 
works is asynchronous (delayed) compared to the way it works in flash (which is 
synchronous) as soon as the renderer is added to the stage. So that is one 
possible reason for things not working the same, because often the code that is 
creating the renderers is also explicitly running code in the newly created 
renderer instance (like setting data and possibly other calls). It might be 
doing this after it has been 'addedToStage' and there is no chance for the 
PostConstruct method to run first, because it would be delayed. But if 
PostConstruct is never running at all then it could be related to use in a 
Popup.
Another thing to check is to make sure the package filtering on the 
JSStageEvents is not excluding your renderers from having the simulated events 
being created.





On Sun, Nov 21, 2021 at 11:51 AM Maria Jose Esteve 
<[email protected]<mailto:[email protected]>> wrote:
Hi, Is there any explanation for the fact that "[PostConstruct]" does not work 
in the itemrenderers?

Thx.
Hiedra

Reply via email to