Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

hermannee

Programmer
Nov 10, 2011
3
US
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="[URL unfurl="true"]http://ns.adobe.com/mxml/2009"[/URL] 
				xmlns:mx="library://ns.adobe.com/flex/mx" 
				xmlns:s="library://ns.adobe.com/flex/spark" 
				xmlns:parsley="[URL unfurl="true"]http://www.spicefactory.org/parsley"[/URL]
				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="[URL unfurl="true"]http://ns.adobe.com/mxml/2009"[/URL] 
				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="[URL unfurl="true"]http://www.spicefactory.org/parsley"[/URL]
				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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top