PureMVC Architects Lounge

PureMVC Manifold => Demos and Utils => Topic started by: puremvc on February 26, 2012, 07:30:49

Title: ReverseText - A PureMVC Dart Demo
Post by: puremvc on February 26, 2012, 07:30:49
This simple demo shows the most common actors and collaborations found in a PureMVC application. A form allows you to enter text, click a button and have the text reversed and displayed in another text box. A check box allows you to have your text reversed continuously as you type. Finally, when the text in the input box is the same as the text after reversal, the output text box's label changes to indicate that a palindrome was detected.

Demonstrated are how to...
  • Use an MVCFacade to initialize and startup a PureMVC core.
  • Prepare the Model, View, and Controller regions of the PureMVC core using MVCMacroCommand and MVCSimpleCommands.
  • Use an MVCMediator to forward user input from view components on to other parts of a PureMVC core for processing.
  • Use business logic in a MVCSimpleCommand that both updates data in an MVCProxy and conditionally notifies an MVCMediator with information about the process.
  • Store data in an MVCProxy, and have the MVCProxy notify the rest of the core when that data is changed.
  • Have an MVCMediator show interest in certain MVCNotifications and handle them by updating its view component.

Internet Explorer is not supported by this demo. In order to bring you a demo that shows only PureMVC and the DOM with no other interference or abstractions, we decided to support only on W3C compliant browsers.

Twitter's Bootstrap is used only for its Base CSS, to make it look pretty.

The demo has historically been located at http://trac.puremvc.org/Demo_Dart_ReverseText
It has now been moved to https://github.com/PureMVC/puremvc-dart-demo-reversetext/wiki

The authors are Cliff Hall and David Foley.

Title: Re: ReverseText - A PureMVC Dart Demo
Post by: maddec on July 04, 2012, 05:36:05
Hello Cliff,

to start with thank you for having taken the early initiative of the Dart port of PureMVC, being a long time user and fan of PureMVC, it is a good starting point to me to come on known ground ;)

Running Reverse Text Demo on latest Dart Editor Version, Build 9261
Dart SDK version 9258, I had errors. The version of Reverse Text example I'm using was checked out 07.03.2012 17h.

I know you are aware of this (from g+), but I feel this info could help before you fix this:


since dart:dom is deprecated

Demo_Dart_Reversetext.dart Line 1:
// DART DOM Library
#import('dart:html');//before #import('dart:dom');


vars definition (changes of class denominations):

  FormElement   textForm;
  InputElement  textInput;
  InputElement  textOutput;
  LabelElement  textOutputLabel;
  InputElement  checkbox;
  ButtonElement reverseButton;

components initialization ($dom_ prefix must be added to querySelector method):

    // use HTML5 querySelector for DOM retrieval
    textForm         = document.$dom_querySelector('#textForm');
    textInput        = textForm.$dom_querySelector('#inputText');
    textOutput       = textForm.$dom_querySelector('#outputText');
    textOutputLabel  = textForm.$dom_querySelector('#outputTextLabel');
    checkbox         = textForm.$dom_querySelector('input[type=checkbox]');
    reverseButton    = textForm.$dom_querySelector('button[type=submit]');



    while (chars.length > 0) {

does not work it sends an exception, since List chars is considered to be fixed size List (which doesn't allow removeLast), if I understand this correctly.

instead I did the following:
    var i = chars.length;
    while (i > 0) {
      buffer.add(chars[i -1]);
    chars = null;

Best regards.
Cedric Madelaine aka maddec

Title: Re: ReverseText - A PureMVC Dart Demo
Post by: puremvc on July 04, 2012, 08:24:12
Sorry about this. I've actually corrected it a few weeks back in the repository, but failed to update the downloadable archive. I'll take care of that today.


Title: Re: ReverseText - A PureMVC Dart Demo
Post by: maddec on August 21, 2012, 02:19:47
Thank you for the update. It is great that everything moved to git, then Pub package manager might be possible ;)

Dart Editor
Version, build 10994
Dart SDK version 10993

By the way using latest version of PureMVC_Dart 1.3 and Demo_Dart_ReverseText 1.3:
I think there's a typo:

line 4:

static String TEXT_CHANGED = "text/changed";

should be:

static final String TEXT_CHANGED = "text/changed";
(expected constant expression)


line 5:

this is still the SVN path, shouldn't it be the git one?
#import('../PureMVC_Dart/src/puremvc.dart'); //when working with local

Title: Re: ReverseText - A PureMVC Dart Demo
Post by: puremvc on August 21, 2012, 07:23:36
should be:
static final String TEXT_CHANGED = "text/changed";
(expected constant expression)
Good catch.

this is still the SVN path, shouldn't it be the git one?
#import('../PureMVC_Dart/src/puremvc.dart'); //when working with local
It will still work for now, since both repos are still supported. However, the migration to GitHub is nearly complete, so I will definitely want to change this one as well. And of course if you want to load the framework locally and change the path to relative, you can always do so, but in the repo we'll want to keep things so they work out of the box even if you haven't got the framework on your local system.

Thanks for the heads up on these. I'll be changing them soon.