|
|
Show Posts
|
Pages: [1]
|
2
|
PureMVC Manifold / Standard Version / overload in facade and Notification class
|
on: January 04, 2009, 07:39:47
|
In java you can't use default parameter so i think it's better to overload some pureMVC methods
in Notification class
public Notification( String name, Object body, String type ) { this.name = name; this.body = body; this.type = type; }
public Notification(String notificationName, Object object) { this(notificationName, object, null); } public Notification(String notificationName) { this(notificationName, null); }
in facade classe
public void sendNotification( String notificationName, Object body ) { notifyObservers( new Notification( notificationName, body, null ) ); }
public void sendNotification( String notificationName ) { notifyObservers( new Notification( notificationName, null ) ); }
so it is quite more usable
i still have problems undestanding how to link views and mediators in java because i can't use bubbled events so a lot fo boring code is required
i'm studing a better way to handle notifications in mediator because we can't use String with switch statement, probably the best way is tu use enumeration but we can't extend it later so i don't know if it is a good solution, what do you think about ?
Teo
|
|
|
4
|
PureMVC Manifold / Standard Version / model vs proxies
|
on: January 02, 2009, 07:50:39
|
Hi everyone, why in java version of pureMVC is introduced model class which can store proxies?
when have i to use proxies and when model ?
another thing, can anyone show me a typical package structure for a socket java client ?
thanks Teo
|
|
|
6
|
Announcements and General Discussion / Architecture / Re: Architecting a simple videoplayer in PureMVC and Flex
|
on: December 06, 2008, 10:43:47
|
when i used cairngorm i implemented netStreams and NetConnection in delegates in order to call them with a command.
now i tried to make something like a remoteproxy but i really don't know if this is a good solution. One of the most amazing thing which is troubling my mind is that i wrote a lot of code to write a simple videoPlayer. Another thing which i was thinking about is: Have i to instantiate many netStreams proxies such how many streams i have or is better to notify application about stream event and specify the stream involved ?
i really don't know if this could be a good solution, it works but could it be done better?
public class StreamProxy extends Proxy { /*CONST */ public static const NAME : String = "streamProxy" ; /* protected */ protected var streamList : Dictionary ; /***************************************************************** * PROPERTIES * **************************************************************/ /***************************************************************** * CONSTRUCTOR * **************************************************************/ public function StreamProxy(proxyName:String=null, data:Object=null) { super(proxyName, data); init () ; } private function init () : void { streamList = new Dictionary () ; } /***************************************************************** * FUNCTIONS * **************************************************************/ /** * * getStream * helper function to mange multiple streams * */ protected function getStream (nc : NetConnection, streamName : String ) : ExtendedNetStream { var ns : ExtendedNetStream ; //-- check if NetStreamAlreadyExists if (! streamList.hasOwnProperty( streamName )) { ns = new ExtendedNetStream ( nc ) ; ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError ) ; ns.addEventListener(IOErrorEvent.IO_ERROR, onIOError ) ; ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus ) ; ns.addEventListener( ExtendedNetStreamEvent.META_DATA, onMetaData ) ; ns.addEventListener( ExtendedNetStreamEvent.PLAY_STATUS, onPlayStatus ) ; streamList[ streamName ] = ns ; } else ns = streamList[ streamName ] as ExtendedNetStream ;
return ns } /** * * @ playStream * */ public function playStream (nc : NetConnection, streamName : String, seek : Number = 0 ) : ExtendedNetStream { var ns : ExtendedNetStream = getStream( nc , streamName ) ; if ( ns.state == PlayerState.PAUSE_STATE ){ ns.resume(); } else ns.play( streamName ); ns.state = PlayerState.PLAY_STATE return ns ; } /** * * @pauseStream * */ public function pauseStream ( nc :NetConnection, streamName : String ) : ExtendedNetStream { var ns : ExtendedNetStream = getStream( nc , streamName ) ; ns.pause(); ns.state = PlayerState.PAUSE_STATE; return ns ; } /** * * @stopStream * */ public function stopStream ( nc :NetConnection, streamName : String ) : ExtendedNetStream { var ns : ExtendedNetStream = getStream( nc , streamName ) ; ns.close(); ns.state = PlayerState.STOP_STATE; return ns ; } /** * * @seek * */ public function seek ( nc :NetConnection, streamName : String , position : Number ) : ExtendedNetStream { var ns : ExtendedNetStream = getStream( nc , streamName ) ; ns.seek( position ) ; return ns ; } /** * * @ getSeek * get the current seek position of a * selected netStream * */ public function getSeek ( streamName : String) : Number { var ns :ExtendedNetStream = streamList[ streamName ] as ExtendedNetStream ; if (! ns ) return -1 ; return ns.time / ns.duration *100 ; } /***************************************************************** * EVENTS * **************************************************************/ private function onAsyncError ( e: AsyncErrorEvent ) : void { facade.sendNotification( MainFacade.NS_ASYNC_ERROR ,e ) ; } private function onIOError ( e : IOErrorEvent ) : void { facade.sendNotification( MainFacade.NS_IO_ERROR, e ) ; } private function onNetStatus ( e : NetStatusEvent ) : void { trace ("[ StreamProxy ]", e.target, e.info.code ); switch ( e.info.code ){ case "NetStream.Play.Stop" : // TODO : send to interface state == STOP break ; } } /** * * onMetaData * */ private function onMetaData ( e : ExtendedNetStreamEvent ) : void { try { //-- save in a dynaimc var the (e.target as ExtendedNetStream ).duration = (e.info as Array)["duration"]; }catch (err : Error){} } /** * * @ onPlayStatus * */ private function onPlayStatus ( e : ExtendedNetStreamEvent ): void { trace (e.info.code) ; switch (e.info.code) { case "NetStream.Play.Complete": (e.target as ExtendedNetStream).close() ; facade.sendNotification( MainFacade.NOTIFY_PLAY_COMPLETE, e.target as NetStream) ; break ; } }
thanks Teo
|
|
|
7
|
Announcements and General Discussion / General Discussion / Re: MVP and pureMVC differences
|
on: December 01, 2008, 09:15:12
|
MVP Presenter is a code-behind class, which acts like a puppet master to a view component with no intelligence of its own. It is too 'familiar' with the view component.
-=Cliff>
Thnaks Cliff and Pablo, what do you mean with code behind? which are presenter's tasks? have we got advantages implementing an mvp patterns? any link is great accepted thanks for now Teo
|
|
|
8
|
Announcements and General Discussion / General Discussion / MVP and pureMVC differences
|
on: November 06, 2008, 11:16:20
|
Hi everybody, discussing with a friend we were talking about pureMVC. I'm using pureMVC since the le beginning of the year and he studied something about MVP smalltalk pattern. MVP pattern is used for .net application too so i decided to discover more about it As every time i have to start with a new thing open wikipedia and i read this http://en.wikipedia.org/wiki/Model_View_Presenterso i thought "ok, Presenter is a new layer between controller and view... so it is the pureMVC mediator"... i think i'm wrong because I'm reading this one http://www.wildcrest.com/Potel/Portfolio/mvp.pdf and presenter is described as controller so please someone can explain me which are differences between the 2 patterns and why some one think MVP is so better then MVC ? thanks Teo
|
|
|
|
|