2

I'm trying to create a sample CRUD application using Dart and Polymers.

One think I noticed is almost all dart polymer examples have only one page. I'm trying to look for samples with multiple pages.

i.e.

  • Screen contains table of Person objects
  • Then when an Add button is clicked, it goes to the add view of the Person object
  • On the add page, there is a link to add some other child object.

This is very doable using only one screen, but am looking for a best practice in implementing multiple screens. In GWT it uses the Activities and Places. What is the dart counter part?

I saw on some other post using routes, but seems does not work on my Dart Editor. And I am not sure if this is still current as that posted almost a year now.

Route Example

 ShadowRoot.resetStyleInheritance and ShadowRoot.applyAuthorStyles now deprecated in dart:html.
 Please remove them from your code.

 Uncaught Error: Illegal argument(s): No handler found for /routes_example.html#one
 Stack Trace: 
Community
  • 1
  • 1
javapadawan
  • 897
  • 6
  • 12
  • 29

1 Answers1

2

I just published a package for routing with Polymer (see https://github.com/bwu-dart/bwu_polymer_routing) There are two links to simple demos available online. I have a SDK dependency on 1.6.0 (dev-channel release) because I haven't tested it with Dart 1.5.x. I might remove this restriction with the next release.

Some highlights:

  • Hierarchical views are automatically created and inserted depending on the current route.
  • Route parameter values are automatically passed to the view attributes on route or parameter value change.
  • Parameter values are updated in the view without creating the view again.
  • The same code runs no matter if usePushState is enabled or disabled.
  • Mixin with event handlers for simple go-to-route links or buttons.
  • Mixin for adding DI support to your Polymer elements.

see also https://stackoverflow.com/a/25228357/217408

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Thanks. Seems you created your own framework for handling routing. Actually, I was looking for how it is currently done w/o a framework. Is polymer dart designed for single pages only? Was it intended to navigate from page to page using different html files? That sort of things. – javapadawan Aug 12 '14 at 06:17
  • It uses the route_hierarchical package also used by Angular.dart. I just added some helper elements/mixins. For example the `` element, a placeholder where view elements (configured in the route configuration) are inserted automatically. This is mostly a port from how Angular.dart uses route_hierarchical to Polymer. – Günter Zöchbauer Aug 12 '14 at 06:20
  • Got it. Will look into it in detail. But for now, do you know of any articles on how multiple dart pages should be designed. I am interested in the theory first before the actual implementation. – javapadawan Aug 12 '14 at 06:22
  • I guess there isn't much to consider. One thing that comes to my mind is how you bind to the data model. I guess it mostly depends on what kind of application you are building. Should the entire content be replaced or should some menu or scaffold be constant and only some parts of the page be replaced. – Günter Zöchbauer Aug 12 '14 at 06:24
  • Actually, am more into knowing, is Dart like GWT that is ideal for single page web applications such as Docs, Maps etc, or is it more like the jquery of a server side languages (PHP, JSP, ASP). So, I am just trying to know what is the appropriate instance to use dart. – javapadawan Aug 12 '14 at 06:29
  • Anyways, I think my question is wrong. Let me post a new question that clarifies what am trying to fine. – javapadawan Aug 12 '14 at 06:31
  • Dart is definitely for single page applications. It differs to GWT as it doesn't have a specific way how GUI widgets are built. Polymer components and Angular components are two supported ways but there are others (like [DWT](http://dartwebtoolkit.com/). It is definitely not similar to PHP, JSP, ASP (but I guess some packages that allow something along those lines are available). Dart on the server is primarily used to provide a REST like interface to the Dart client for fetching/updating data. – Günter Zöchbauer Aug 12 '14 at 06:33