PureMVC
Home
About
Code
Docs
FAQ
Forums
News
Showcase
Contact
Jobs
Welcome,
Guest
. Please
login
or
register
.
May 22, 2013, 02:13:58 AM
News:
ATTENTION: Spambots must die! Humans must visit
http://contact.futurescale.com
to request forum access.
PureMVC Architects Lounge
Announcements and General Discussion
Architecture
Best practice for XML-fed widgets
Pages: [
1
]
« previous
next »
Author
Topic: Best practice for XML-fed widgets (Read 1613 times)
raffjones
Newbie
Posts: 2
Best practice for XML-fed widgets
«
on:
February 02, 2009, 03:41:38 AM »
Hi guys,
I'm just wondering what the best approach is for building a screenful of expandable widgets in Flash, in terms of keeping track of dimensions, position, loading status etc. The only slight complication is that the layout of the widgets and the content that populates each one of them, as well as the assets file required to build them graphically, are loaded independently.
I have read that many architects prefer to have their Mediators as "dumb" as possible, so I don't want my WidgetMediator doing too much work to create them, but at the same time, I don't want any individual view components flexing their little muscles too much either, as that would just be contrary to what I think PureMVC is all about.
I'm trying to figure out how a data proxy can fit into the equation to keep track of everything.
The app loads a single config file, which then contains paths to 2 things:
1. a shared library which includes fonts (no widgets can even be initialised until this happens)
2. a path to the "widget list" - which in turn contains the setup for each widget, and a path to its XML feed.
Should I use a Proxy to create a "virtual layout" as various responses are received, and sending a notification when enough data has been received to create something visual? Or is it OK to have a Mediator picking up on the relevant notifications (such as config loaded, widget list loaded, assets initialised etc.) and doing the layout work itself?
Any advice welcome. I'll be happy to share source code when the app is complete.
Cheers
SJ
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Best practice for XML-fed widgets
«
Reply #1 on:
February 02, 2009, 06:34:28 AM »
Assuming the process is as simple as load widget combine it with its info and pass it to the view to be placed into the view hierarchy.
You may want to create a VO that carries the loaded widget and all its config info. the proxy loads the widget list then loops through, laoding the widgets and creating the widgetVOs sending them in an INJECT_WIDGET note, picked up by the appropriate Mediator
If these widgets are all siblings in the view hierarchy then one Mediator will be interested and do all the placements.
You may have different mediators throughout your view hierarchy, and some are interested in placing some widgets and others place the rest.
In that case you need to devise a set of 'type' strings that say where each widget goes.
For instance some widgets might go in a 'toolbar'. So in the xml that was loaded describing these widgets, add a 'type' attribute of 'toolbar'. The proxy creates the VO with the widget and all its info then sends an INJECT_WIDGET note with the VO as the body and 'toolbar' as the type.
The mediators that are interested in the INJECT_WIDGET note should now look at the note type (note.getType()) and only act if it is the type they are looking to place. In this case, the ToolBarMediator would be the only one to respond, taking the widget from the VO and adding it to its view component, the toolbar.
-=Cliff>
Logged
raffjones
Newbie
Posts: 2
Re: Best practice for XML-fed widgets
«
Reply #2 on:
February 02, 2009, 10:17:46 AM »
Thanks a lot, Cliff... some useful ideas here.
My layout uses a single "canvas" of three columns. The XML specifies which "slot" a widget should go into (via attributes ie. column="1", row="2").
I'm using "WidgetType" definitions to determine which class of widget to create - for example, VIDEO would create VideoWidget, RSS creates an RssWidget and so on, all of which extend a "BaseWidget" class, making use of the flash.utils.getDefinitionByName() method which turns strings into Class references.
The only complication is that these widgets have varying default sizes, and once their content loads (an RSS feed for example), they generate their display and some will expand or contract to fit, moving everything below them in their column if need be. I can expand a story in, say, the "NewsWidget" which would move everything below it downwards.
I've had no problem generating the widgets and adding them to the view. It is the maintenance of the overall column heights and positioning of the widgets themselves that I am struggling with... in terms of who should be looking after all that - the proxy, the mediator or the WidgetCanvas view component that contains the actual visual elements?
I will investigate further, and thanks again for your advice... Great to have the main man taking such an interest in the PureMVC posse at large!
From snowed-under London, warm regards
SJ
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Best practice for XML-fed widgets
«
Reply #3 on:
February 04, 2009, 09:57:22 AM »
Snowed under here as well today. Brrh!
Based on my earlier suggestion I would put those values on the WidgetVO used to carry the Widget to its destination in the view. So the VO is basically carries all the 'meta' info about the widget.
Then the view component that the WidgetVO is passed to would pluck the VO out and put it where it needs to go and size it appropriately.
Although it's not visually carrying a component, take a look at the EmployeeAdmin demo and how the UserVO is set on the UserForm component, where the data on the VO is distributed to the fields for editing. This is done by binding, but in the UserForm, but your receiving component could have an 'injectWidget' method that takes a WidgetVO and uses the meta info to handle it appropriately.
-=Cliff>
Logged
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements and General Discussion
-----------------------------
=> General Discussion
=> Getting Started
=> Architecture
=> Public Demos, Tools and Applications
===> Fabrication
-----------------------------
PureMVC Manifold
-----------------------------
=> Port Authority
===> Contributor Central
===> Client Side
===> Server Side
=> Port to AS2
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to AS3
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to ColdFusion
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to C++
===> MultiCore Version
=====> Demos and Utils
=====> Bug Report
=> Port to CSharp
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Dart
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Haxe
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Java
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to JavaScript
===> Demos and Utils
===> Native JS Branch
=====> Bug Report
===> PrototypeJS Branch
=====> Bug Report
===> Objs Branch
=====> Bug Report
===> MooTools Branch
=====> Bug Report
===> ExtJS Branch
=====> Bug Report
=> Port to Objective C
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Perl
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to PHP
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Python
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Ruby
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to TypeScript
===> Standard Version
=====> Bug Report
=====> Demos and Utilities
===> MultiCore Version
=====> Bug Report
=====> Demos and Utilities
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Powered by SMF 1.1.11
|
SMF © 2006-2007, Simple Machines LLC
Loading...
Copyright © 2006-2008 Futurescale, Inc.