Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
October 19, 2017, 02:44:03 PM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: ReverseText - A PureMVC Dart Demo  (Read 5326 times)
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« on: February 26, 2012, 07:30:49 PM »

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.
« Last Edit: July 30, 2012, 05:08:00 PM by puremvc » Logged
maddec
Courseware Beta
Newbie
***
Posts: 7



View Profile WWW
« Reply #1 on: July 04, 2012, 05:36:05 AM »

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 Wink

Running Reverse Text Demo on latest Dart Editor Version 0.1.0.201206291313, 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:

A:

since dart:dom is deprecated

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

TextComponent.dart

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):

  TextComponent()
  {
    // 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]');

...
C:
every
.addEventListener(
become:
.$dom_addEventListener(

...
D:
 ProcessTextCommand.dart

    while (chars.length > 0) {
      buffer.add(chars.removeLast());
    }

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]);
      i--;
    }
    chars = null;


Best regards.
Cedric Madelaine aka maddec


Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #2 on: July 04, 2012, 08:24:12 AM »

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.

-=Cliff>
Logged
maddec
Courseware Beta
Newbie
***
Posts: 7



View Profile WWW
« Reply #3 on: August 21, 2012, 02:19:47 AM »

Thank you for the update. It is great that everything moved to git, then Pub package manager might be possible Wink

Dart Editor
Version 0.1.0.201208201142, build 10994
Dart SDK version 10993

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

Demo_Dart_ReverseText:
model/proxy/TextProxy.dart
line 4:

static String TEXT_CHANGED = "text/changed";

should be:

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

B______________________________
Demo_Dart_ReverseText.dart

line 5:
#import('http://svn.puremvc.org/PureMVC_Dart/trunk/src/puremvc.dart');

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



Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #4 on: August 21, 2012, 07:23:36 AM »

Quote
should be:
static final String TEXT_CHANGED = "text/changed";
(expected constant expression)
Good catch.

Quote
#import('http://svn.puremvc.org/PureMVC_Dart/trunk/src/puremvc.dart');
this is still the SVN path, shouldn't it be the git one?
or
#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.

-=Cliff>
Logged
Pages: [1]
Print
Jump to: