INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Flexunit + Parsley - re-creating error: "Object of type is already man

Flexunit + Parsley - re-creating error: "Object of type is already man

Flexunit + Parsley - re-creating error: "Object of type is already man

(OP)
Hello,
   This may sound a bit strange but I'm trying to force an "Object of type is already managed" error to recreate a bug we had in our app for
   flexunit testing purposes.   The problem arised when we upgraded to FB 4.5 and had a double parsley configuration in a popup launched from a module.
   Here's my flexunit test:

CODE

[Test]
public function testReportsPrintDialog1():void
{
    rpDialog = new ReportsPrintDialog();
    
    //attempting to forcibly re-create the project-70 bug:
    //"Object of type reportsDirectoryModule.views::ReportsPrintDialog is already managed"
    childContext.viewManager.addViewRoot(reportsDirectoryBase);
    childContext.viewManager.addViewRoot(rpDialog);
    
    trace("rpDialog: " + GlobalState.objects.isManaged(rpDialog));
    trace("reportsDirectoryBase: " + GlobalState.objects.isManaged(reportsDirectoryBase));
    
    rpDialog.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete, false, 0, true);
    PopUpManager.addPopUp(rpDialog, DisplayObject(FlexGlobals.topLevelApplication));
}

Unfortunatly, my attempts at 'forcing' the extra parsley object managment by using addViewRoot is not reproducing the error.

In my test suite I am setting up my main and module scoped parsley context in the next code snippit and it has
been working very well for other tests so far. Here's the context setup code:

CODE

import reportsDirectoryModule.parsleyConfig.ParsleyConfig;
public var context:Context;
public var childContext:Context;

//create base TDMSE parsley context
this.context = ContextBuilder.newBuilder()
    .config(FlexConfig.forClass(TDMSEAppParsleyConfig))
    .object(this)
    .build();

this.childContext = ContextBuilder
    .newSetup()
    .parent(context)
    .newBuilder()
    .config(FlexConfig.forClass(reportsDirectoryModule.parsleyConfig.ParsleyConfig))
    .build();


The ReportsPrintDialog actually inherits from a base popup class called ReportsDirectoryBase which has this parsley declaration:

CODE

<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:parsley="http://www.spicefactory.org/parsley"
                skinClass="common.skins.TitleWindowSkin">
    
    <fx:Declarations>
        <parsley:ContextBuilder id="childContext"
            parents="{app.module.getContext()}" domain="{app.applicationDomain}"/>
        <parsley:Configure />
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            [Bindable]
            private static var app:Object = FlexGlobals.topLevelApplication;

And the 'Object of type is already managed' exception was because ReportsPrintDialog had the following Configure declaration:

CODE

<rdv:ReportsDirectoryBase xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                xmlns:rdv="reportsDirectoryModule.views.*"
                xmlns:cc="common.components.*"
                xmlns:parsley="http://www.spicefactory.org/parsley"
                title="Print Reports Confirmation"
                width="300"
                creationComplete="init()"
                showCloseButton="true"
                close="closeWindow()">
    
    <fx:Declarations>
        <parsley:Configure/>
    </fx:Declarations>

I know this is a bit strange, but if nothing else, I'm chalking it down as a good flexunit/parsley learning experience.

Thanks,
Eric H

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close