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]
1  PureMVC Manifold / Standard Version / The good logic for command ? on: October 16, 2008, 12:51:03
Hello,

As many people before me, i've trouble in understanding when i can talk with proxy directly from mediator and when i 've to use a command.

But this morning, i was trying to implement a logic of deleting product. In fact when i delete a product i've to talk with product_proxy but also with description_product_proxy (another table in db).

So i was beginnning to implement it into the product_proxy but it seems to myself that was not a good solution to invoke description_proxy from product_proxy, so the logical of puremvc push me in thinking about a command where i can invoke product_proxy and all the others proxy i need.

So is it the good way of thinking a command ?

(please, do not tell me to read the doc, i read it all days (holly bible), but there's a difference between read the concept and understanding examples and work with them)

Thanks !
2  PureMVC Manifold / Standard Version / A view componet can register herself to the facade ? on: October 01, 2008, 02:11:18
Hello,

A little question . In my app, i have many component, each one has his mxml file.

So i have the MainView > ViewStack > TabNavigator > ComponentHomeMade

Today,  for register my ComponentHomeMade to the facade i do this inside the component itself :

:
private function registerComponent():void
{
ApplicationFacade.getInstance().registerMediator( new ProduitVOListMediator( this ) );
}

and this is invoked on the addedToStage Event.

It's very usefull to do that (i can unregister it with removeFromStage).

But i'm thinking that it's not very clean, it seems that a view component would not have this responsabilty ?

Am I true or Not ?

Thanks again...
3  PureMVC Manifold / Standard Version / First real project with puremvc : is my plan good ? on: September 24, 2008, 01:44:31
Hi,

After playing a little bit with puremvc. I start to planning a real project with it.

The project is an little e-commerce website.

The back offfice is under flex with puremvc

The front office is flash based with puremvc too.

First question : how can i re-use some puremvc code produced for back office to front office (methods for CRUD service for example) ? i mean in a architectural logic ?


Second question :
for the back office i see the thing like that :

2 states :

- 1 state for login operation that use puremvc for requesting database via model and service delegate


- 1 state for admin opération, that display a viewStack.

 Each view of the viewstack :
- use a specific component to display data

- manage one Value Object and use the puremvc logical to do it (CRUD via webservice...)

What are thinking about this plan ? is it a good way ?

Thanks again.
4  PureMVC Manifold / Standard Version / Open a popup form by MainViewMediator ? is it the good way ? on: September 23, 2008, 05:43:39
Hi,

I need to open a form with popupmanager.

The form is one of the components view.

So i've added a mediator to the MainView that have the responsability to manage the popup.


:
package com.freddufau.eshop.view
{
import com.freddufau.eshop.ApplicationFacade;

import com.freddufau.eshop.model.vo.*;
import com.freddufau.eshop.view.MainViewMediator;
import com.freddufau.eshop.view.components.*;
import flash.events.Event;
import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;

public class MainViewMediator extends Mediator implements IMediator
{


public static const NAME:String = 'MainViewMediatorMediator';


public function MainViewMediator(viewComponent:Object=null)
{
super(NAME, viewComponent);
// Add Listeners

}


public function get mainViewMediator():MainViewMediator{
return viewComponent as MainViewMediator;
}



override public function listNotificationInterests():Array
{
return [ ApplicationFacade.SHOW_CREATE_FORM

];
}

override public function handleNotification(notification:INotification):void
{

switch ( notification.getName() )
{
case ApplicationFacade.SHOW_CREATE_FORM:

createPopUpForm();

break;

default : break;
}

}

private function createPopUpForm():void
{
var createProductPopUp : ProductForm = PopUpManager.createPopUp( ApplicationFacade.MAIN_VIEW, ProductForm, false ) as ProductForm;
createProductPopUp.mode = "create";
PopUpManager.centerPopUp( createProductPopUp );
}

}
}

So i've needed to create the static var MAIN_VIEW in the facade to hold the popup on top.

Is this a good way ?

And to close, i will listen the closeNotification ?

Thanks;
5  PureMVC Manifold / Standard Version / Why my component doesnt dispatch the event ? on: September 23, 2008, 05:09:04
Hi,

I've a component view named "ProductForm", it comes with his mediator called "ProductFormMediator".

There are register in the facade with :

facade.registerMediator( new ProductFormMediator( app.productForm ) );

In the component, i dispatch an event for update some fields for a product.( call service, write in DB, etc... and return)

All work perfectly for the update loop.

But now, i'm trying to add a "create product" functionnality.

I copy / paste the code for update and do some renaming.

So, from the productForm, when user click button i do :

:
dispatchEvent( new ProductEvent(ProductEvent.EVENT_CREATE_PRODUCT, currentProduct ))
I have an Alert that show me that currentProduct exist and the ProductEvent exist too.

In the mediator, i listen but nothing happen :

Here's the médiator :

:
package com.freddufau.eshop.view
{
import com.freddufau.eshop.ApplicationFacade;
import com.freddufau.eshop.event.ProductEvent;
import com.freddufau.eshop.model.ProductProxy;
import com.freddufau.eshop.model.vo.Product;
import com.freddufau.eshop.view.components.ProductForm;

import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

import mx.controls.Alert;

public class ProductFormMediator extends Mediator implements IMediator
{

private var productProxy:ProductProxy;

public static const NAME:String = 'ProductFormMediator';


public function ProductFormMediator(viewComponent:Object=null)
{
super(NAME, viewComponent);

// Add Listeners to his view
productForm.addEventListener( ProductEvent.EVENT_UPDATE_PRODUCT, onUpdate );
productForm.addEventListener( ProductEvent.EVENT_CREATE_PRODUCT, onCreate );

productProxy = facade.retrieveProxy(ProductProxy.NAME) as ProductProxy ;
}


public function get productForm():ProductForm{
return viewComponent as ProductForm;
}

private function onUpdate(pEvt:ProductEvent):void
{
productProxy.updateProduct( pEvt.product );
}

private function onCreate( pEvt:ProductEvent ):void
{
Alert.show("onCreate", "infos");    // this alert is neveer showned !!!
productProxy.createProduct( pEvt.product );
}

override public function listNotificationInterests():Array
{
return [
ApplicationFacade.SELECT_PRODUCT

];
}

override public function handleNotification(notification:INotification):void
{

switch ( notification.getName() )
{
case ApplicationFacade.SELECT_PRODUCT:

var product:Product = notification.getBody() as Product;
//Alert.show(notification.toString(), "info");
productForm.product = product ;
break;

}

}

}
}

Here the component view :

:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" xmlns:vo="com.freddufau.eshop.model.vo.*">

<mx:Metadata>
<!--[Event(name="updateProduct", type="com.freddufau.eshop.event.ProductEvent")]
[Event(name="createProduct", type="com.freddufau.eshop.event.ProductEvent")]-->
</mx:Metadata>

<mx:Script>
<![CDATA[
import com.freddufau.eshop.event.ProductEvent;
import com.freddufau.eshop.model.vo.Product;
import mx.controls.Alert;

[Bindable]
public var product:Product;

[Bindable]
public var mode:String = "save";

private function clickHandler():void
{
if( mode == "create" )
{
Alert.show( "dispatch " + currentProduct.toString(), "info"); // this alert is showned
dispatchEvent( new ProductEvent(ProductEvent.EVENT_CREATE_PRODUCT, currentProduct ))
}
else
{
dispatchEvent( new ProductEvent(ProductEvent.EVENT_UPDATE_PRODUCT, currentProduct)) // here it work !
}

}
]]>
</mx:Script>

<vo:Product id="currentProduct"
id_product="{product.id_product}"
nom="{nomTi.text}"
prix="{int(prixTi.text)}"

/>

<mx:Form x="10" y="10" defaultButton="{saveBt}">

<mx:FormItem label="nom">
<mx:TextInput id="nomTi" text="{product.nom}"/>
</mx:FormItem>

<mx:FormItem label="prix">
<mx:TextInput restrict="0123456789-" id="prixTi" text="{product.prix}"/>
</mx:FormItem>



<mx:FormItem id="saveBt">
<mx:Button label="{mode}" click="clickHandler()"/>
</mx:FormItem>
</mx:Form>

</mx:Canvas>

thanks for your help !
6  PureMVC Manifold / Standard Version / Does mediator sendNotification to proxy or they can call directly ? on: September 22, 2008, 01:20:41
Hello,

I'm new to here.

I'm started by a simple question, i think.

Does mediator sendNotification to proxy or they can call directly ?

thanks.
Pages: [1]