Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: 1 2 [3] 4 5 6
31  Announcements and General Discussion / Public Demos, Tools and Applications / Re: Domino effect on: April 04, 2009, 12:08:56
Thank you both for your advises:)

When I said that my AIR application was huge, I didn't mean that it was one big unmanageable...something.

I use modules, but one of the modules contains a form, a huge one (cough).
Actually there are about 25 forms in a ViewStack, each in its own View or in another nested ViewStack, but in the end, when the user presses the save button I have to collect the data from all the forms and send it to the server.
Some of the forms, even if they are part of that big form, have a life of their own, meaning their data has to be saved separately dependent on various states of the application. Or, for example, the incoming data has different sources ( from searching the database and filling the form from a DataGrid selected item, from a feed, from user input, etc), that I need to know about, so different actions would follow.
 
When I started the project I had those ~25 forms designed as separate modules. I don't want to bore you with details about the reasons that made me change the modules belonging to that form into “normal” Flex components. Anyway those subforms keep having a modular behavior, that's why refactoring my code with puremvc is in fact pretty easy and most of its functionality has already passed the tests.

StateMachine is actually very straightforward, but I have no idea why it is  still difficult for me to implement it in my project.
I guess I'll have to wait for the promised StateMachine example to be able to use it efficiently.
And I'll search the forum for that “StateMachine markup tool “ you mentioned, because I don't know what you're referring to.

Ondina
32  Announcements and General Discussion / Public Demos, Tools and Applications / Re: Domino effect on: April 04, 2009, 04:45:51
Neil,

could you elaborate upon your Domino-Effect idea?

I find it interesting, but I'm not sure I understand it.( I've read the article on your blog as well)

I'm wondering if it could be used in combination with the StateMachine.

I haven't implemented StateMachine in my project yet, because I'm waiting for an example, that would clarify my doubts about it.
 
I know, a more “real world” example using StateMachine is on its way.

So until then I'm  trying to define the states of my application and see how many I need, how they are connected or how they would influence each other.

So far it seems that the XML  FSM definition will be huge, due to the fact that my application is really large and complex.

And also there would be a lot going on, back and forth, up and down, because a change of one defined state would trigger changes of other states as well pertaining other parts of my application. A Domino Effect?

But those other parts of my application need to have their own states defined, so they'd be able to change independently as well. That means I can't have just one state definition for different parts.
At least that's how I see it now.

Maybe is a silly question.... but wouldn't it be good if the states would be somehow mapped  or channeled or routed... so when you go from STATE_LOGIN to STATE_LOGGED_IN the “Domino Effect” would take care of the other states of the application, that would have to change one after another?

Hmm..I hope you'll excuse my confusing explanation, I don't know how to describe what I'm envisioning.
Maybe I will be able to be more specific after you tell us more about the DominoEffect and if it is suited to be used together with the StateMachine.

Thank you.
Ondina
33  Announcements and General Discussion / General Discussion / Re: ItemRenderer with pMVC on: April 03, 2009, 01:03:54
Well,then  I'll try  again  :)
You shouldn't access the Proxy from your ItemRenderer or any View component.
I would send an event (bubble=true)  that the mediator would handle, and from there I would try to access the Proxy. 

But I think there are some threads about that problem.
Search for “ItemRenderer”.
34  Announcements and General Discussion / General Discussion / Re: ItemRenderer with pMVC on: April 03, 2009, 12:15:14
Did I get it right?

You have, let's say, 2 database tables :

messageTable:
messageId
messageText
authorId


authorTable:
authorId
authorFirstName
authorLastName
authorStatus

You make a service call,  request data from the messageTable and when the data arrives your Proxy sends a Notification to the Mediator of the ListView component with the messageVo in the notification's body. The ListMediator updates the ListView's VO and the List gets populated with the messages.

Isn't it possible to have one server call for both, the messageTable and the authorsTable by using the authorId ( of course in case their structure is like I made it up above) and then the proxy should send both VO's to the mediator?
Like this you would have a ListView ( with the List component inside ), a ListMediator, a ListProxy and 2 VO's .
ListView->ListMediator->ListProxy->Database
Database->ListProxy->2VOs->listMediator->ListView

I don't know if that's your scenario or if I understood your question,  but in any case I think you should have a Mediator “mediating” between Proxy and View, not the Facade. I think the puremvc experts would agree on this.

Even if you really need 2 Proxies for getting 2 different VO's you can still  have ONE Mediator communicating with them and the View.

Take a look at Commands, maybe you can use a Command, depending on your use case.

Older members will tell you more about that:)

Ondina
35  PureMVC Manifold / MultiCore Version / Re: Desktop Citizen Event.CLOSING on: April 03, 2009, 03:32:01
So I'm imagining that when my second monitor is gone, the stage bounds shrink to the size of the first screen.

That doesn't happen.

Look at my tracings. By the way my second monitor is smaller than the main monitor.

App starts on the first Monitor:

screens.length : 1
window is on FIRST monitor
screen.bounds (x=0, y=0, w=1280, h=1024)
event.afterBounds (x=293, y=192, w=719, h=619)
stage.nativeWindow.bounds (x=293, y=192, w=719, h=619)

I move the window, so it intersects the second monitor:

screens.length : 2
window is on both monitors ( do nothing )
screen.bounds (x=1280, y=0, w=1024, h=768)
event.afterBounds (x=904, y=125, w=719, h=619)
stage.nativeWindow.bounds (x=293, y=192, w=719, h=619)

Now the window is on the second monitor:

screens.length : 1
window is  on SECOND monitor
screen.bounds (x=1280, y=0, w=1024, h=768)
event.afterBounds (x=1465, y=57, w=719, h=619)
stage.nativeWindow.bounds (x=904, y=125, w=719, h=619)

Here the window is minimized:

screens.length : 0
window is minimized

When you just move the App, the stage.nativeWindow.bounds change their x and y values, not the size. Only the screen.bounds reflect the monitor's size.
And only the event.afterBounds rectangle shows the real position of the Application on the screen.

So even if you unplug your 2nd monitor, the above tracings will be the same.
If the App was on the second monitor last time you opened it, it will still be there when you start your App again, even if your second monitor is gone. If you then activate your second monitor, the App is still there (2nd Monitor), waiting for you :)

I don't know what would happen, if the MS Windows settings for the Dual Display changed, meaning that you'd have only one monitor defined in the settings and you tried the above. I don't want to try this on my computer, but I think it would be the same:
you would know that your App is NOT on the main monitor - eventually as in my code that it is on the second monitor, but you wouldn't know if other monitors are there or not.

So until you'll find an “edgy”   ;)  solution, I will just notify the user about the Application being on other monitors through the  App Title and add an item to the SystemTrayIcon, that will let them take the App back on the main monitor.
36  PureMVC Manifold / MultiCore Version / Re: Desktop Citizen Event.CLOSING on: April 02, 2009, 08:36:41
some apps are smart enough to move themselves to the first monitor

Those apps might have a way to communicate with the OS ??
Or do you know how to let an AIR app be aware of the absence of the others monitors?

I couldn't find a way of knowing if the other monitor is there by the time the application starts.

I only know that the application “is” on the second monitor, even if it's Nirvana:)

That's why I tried to change the application's title as a warning for the user.

Also, on the bottomFactor, don't assume the taskbar is on the bottom (or top of the screen.

Hmm, you are right!
That might complicate the repositioning on the right and on the left as well, as I did it in my code.

The right side laptop mirrors this with its taskbar vertically aligned on the right side of Its screen with the extra monitor extending the desktop to the left.

Are the extra monitors considered to be the 2nd and 3rd ... monitors, or I should ask where does  DesktopCitizen open  the app the first time (default).

Well well, so many scenarios... why did I start playing around with DesktopCitizen? :)

P.S. Maybe  changing the SystemTrayIcon (adding an item “Back to 1st Screen” or something) would be an acceptable compromise ?
37  PureMVC Manifold / MultiCore Version / Re: Desktop Citizen Event.CLOSING on: April 02, 2009, 06:34:52
I don't know if I was the only one in the world who was wondering where the Mozilla Firefox has gone while trying to launch it – a (long) time ago.
It appeared on the taskbar, but it wouldn't launch.
Anything else ( even IE ) worked fine.

I was sure it was a bug or who knows maybe a virus.
Or maybe MS Windows wouldn't like Firefox anymore.
Lots of stupid scenarios, you know...

It took me a while to realize that I had Firefox on my second monitor the other day, and now the monitor was closed. My Firefox was there!

So I thought, if that would happen to others too while opening an AIR Application managed by the DesktopCitizen, it would be nice to tell the user where the window is, just in case there are multiple monitors available.

So when the application is on the second monitor I send a notification to the ApplicationMediator, that will change the title of the WindowedApplication:
“MyTitle -> Second Monitor”, and that's what the user would see on the taskbar.

In the code from my previous post I would do that:
if( screen.bounds.x > 0 ){
  isOnSecondMonitor = true;
  trace("window is on SECOND monitor");
  sendNotification(SET_APP_TITLE, "Second Monitor");
}
and in the ApplicationMediator
case WindowMediator.SET_APP_TITLE:
   app.title = " ->"+note.getBody() as String;
break;
38  PureMVC Manifold / MultiCore Version / Re: Desktop Citizen Event.CLOSING on: April 02, 2009, 04:31:06
Hi Cliff

Here is how I solved the positioning of the window when using 2 monitors.

:
  private var windowRectangle:Rectangle;
  private var isOnSecondMonitor:Boolean = false;

   protected function onResize( event:NativeWindowBoundsEvent ):void
   {
windowRectangle = event.afterBounds;
detectScreens();
if ( windowMetricsProxy.displayState == NativeWindowDisplayState.NORMAL ){
windowMetricsProxy.bounds = windowRectangle;
sendNotification( WINDOW_SHOW );
}
  }
  protected function detectScreens():void
  {
var screens:Array = Screen.getScreensForRectangle(windowRectangle);   
var screen:Screen;
var screenIndex:uint = screens.length - 1;
if( screens.length == 1 ){ 
   screen = screens[screenIndex]; 
if( screen.bounds.x > 0 ){
isOnSecondMonitor = true;
trace("window is on SECOND monitor");   
}else{
isOnSecondMonitor = false; 
trace("window is on FIRST monitor");
}
keepOnScreen(screen.bounds);
}                                                                    
else{ 
screen = screens[screenIndex];       
trace("window is on both monitors ( do nothing )");
}  
  }
  protected function keepOnScreen( screen:Rectangle ):void
  {
var rightMargin:Number = screen.x + screen.width + 1;
var bottomFactor:Number = 84;
if( !isOnSecondMonitor ){
if( windowRectangle.left < 0 ){
windowRectangle.offset( -windowRectangle.left, 0 );
}
}
if( isOnSecondMonitor ){
  if( windowRectangle.right > rightMargin ){
windowRectangle.offset( -(windowRectangle.right-rightMargin), 0 );
}
}
if( windowRectangle.top < 0 ){
windowRectangle.offset( 0, -windowRectangle.top );
}
if( windowRectangle.bottom > screen.bottom ){
windowRectangle.offset( 0, -(windowRectangle.bottom-screen.bottom-bottomFactor) );
}
  }

That's far from being perfect, but it's a start.

I couldn't test it on more than 2 monitors, but I think little changes to the code would make it work on multiple monitors as well.

The bottomFactor, you'll see in my code, is an ugly thing. I didn't know how to get the height of the (MS Windows) taskbar for the first monitor. The second monitor doesn't have a taskbar.

There was this post
http://forums.puremvc.org/index.php?topic=1145.0
about DesktopCitizen and a Window object opening from the main mxml.

That made me think about how would DesktopCitizen remember the position of that Window object. I don't know the answer yet, but I think it's worth finding a solution, since there might be a need for having Windows objects opening together with the WindowedApplication.

Enjoy the Spring,
Ondina
39  Announcements and General Discussion / General Discussion / Re: ItemRenderer with pMVC on: April 01, 2009, 12:55:47
I don't know how you get the data from evt.target.data.
Data is a variable in your view?

But wouldn't

evt.target.cb.selected

do it?

Actually it will  always be “true” since you've clicked it and dispatched your event on checkbox click.

EDIT: Sorry, of course it will be "false" if you deselect  it.
40  PureMVC Manifold / Standard Version / Re: handleNotification and order on: April 01, 2009, 12:18:38
I don't think that's a puremvc issue.

It rather has something  to do with the execution order of  AS3 code in general.

private function superMediator():void{
  mediatorA();
  mediatorB("b1"); //3
}
private function mediatorA():void{
  trace("mA "); //1
  mediatorB("b2");
}
private function mediatorB(s:String):void{
  trace("mB "+s); //2
}

The trace should give you this:
mA
mB b2
mB b1

which is perfectly normal.


If Notification were AS3 Events you could set the priority parameter to change the order of execution.


Essential ActionScript 3.0
Colin Moock

By default, when multiple event listeners are registered for a single event type with a
given object, those listeners are triggered in the order in which they registered
...
To alter the default order in which event listeners are triggered, we can use the
addEventListener( ) method’s priority parameter, shown in the following generic
code:
addEventListener(type, listener, useCapture, priority, useWeakReference)
The priority parameter is an integer indicating the order in which the event listener
being registered should be triggered, relative to other listeners registered for the same
event with the same object. Listeners registered with a higher priority are triggered
before listeners registered with a lower priority.
For example, a listener registered
with priority 3 will be triggered before a listener registered with priority 2. When
two listeners are registered with the same priority, they are executed in the order in
which they were registered. When priority is not specified, it defaults to 0.

But Notifications in puremvc aren't Events.

Let's see what the puremvc experts will say about this. :)

Ondina
41  Announcements and General Discussion / General Discussion / Re: Load file using native application on: March 31, 2009, 03:33:05
A better communication between an AIR application and the underlying operating system ( launching native executables from an AIR application ) has been on my wishlist forever!

You cannot open MS Office documents in your Flex/AIR application. I wish someone proved me wrong about it.

For PDF look at these links:

http://www.adobe.com/devnet/air/flex/quickstart/scripting_pdf.html

http://raghuonflex.wordpress.com/2006/12/07/flex-i-frame/

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=10183
42  Announcements and General Discussion / General Discussion / Re: DesktopCitizen and Main Window's visibilty on: March 31, 2009, 02:36:06
Even the simplest WindowedApplication behaves like this.

If in  your descriptor file ( DesktopCitizenTest-app.xml) you have

<visible>true</visible>
<systemChrome>none</systemChrome>

you'll see something (the rectangle of the window without any chrome) before the WindowedApplication builds the window with the FlexChrome.

Solution:
set visible explicitly to false
<visible>false</visible>
The default is false, but it seems not to work.

Maybe that was your problem.

Ondina
43  Announcements and General Discussion / Fabrication / Re: Reaction to FlexEvent? on: March 30, 2009, 11:36:33
How can you react to an event, if you aren't there by the time the event  is occurring?

In a classic puremvc application you could, if you wanted/needed to, initialize the Facade on creationComplete and then in your mediator listen for applicationComplete, which is the last event dispatched during an application startup.
Look at this:
http://www.wietseveenstra.nl/blog/2007/02/understanding-the-flex-application-startup-event-order/

On creationComplete or on applicationComplete you first initialize the PureMVC apparatus:
First the Facade, then the Commands, Proxies, Mediators.


In Fabrication ( as I understand it ) FlexApplicationFabricator is the first one that handles the FlexEvent.CREATION_COMPLETE, so if you'd trace it you'd see that the creationComplete that you're handling in your main app is called after the initializeEnvironment() in Fabricator, which does:
facade.registerCommand(FabricationNotification.STARTUP, ApplicationStartupCommand);
which does :
facade.registerMediator(new ApplicationMediator(app));

So your Mediator can't listen to anything happening before its own creation. It just isn't there, and it surely isn't God :)

Please correct me if I'm wrong.

Is it possible that you can't listen for FlexEvent calls with reactions? 

You can. Try BUTTON_DOWN.
44  Announcements and General Discussion / Fabrication / Re: Reaction to FlexEvent? on: March 30, 2009, 12:21:26
I solved my small problem by just listening for the Event.ADDED_TO_STAGE in my Mediator

This would be the same as using the onRegister method, meaning that you only can do something/anything in your mediator after it has been created.

Isn't that so?
45  Announcements and General Discussion / Fabrication / Re: Reaction to FlexEvent? on: March 29, 2009, 02:42:13
Maybe because of this:

puremvc Best Practice:
"Since we are initializing the variable with a call to the static ApplicationFacade.getInstance method, this means that by the time the Application’s creationComplete event fires, the Façade will have been created and along with it, the Model, View and Controller, though no Mediators or Proxies will have been created yet. "
Pages: 1 2 [3] 4 5 6