Enabling Structural Markup and Design

A brief writeup on one of the driving forces behind the Atlas UI framework: enabling structural markup and design... now illustrated via an example.

One of the key goals behind Atlas was to enable designers who know and love HTML and CSS and developers who know about adding behavior and logic to an otherwise static design to turn it into something interactive to work together in a complementary fashion.

This is all very abstract by itself, but if you take a closer look at some of the Atlas controls, such as ListView, you'll see a complete separation of UI and behavior. For example, the HTML markup defines a regular table, and the xml-script markup defines a template whose layout is defined as the table element. The ListView can now repeat rows as it iterates over its associated data. Essentially the designer can now design a fancy table using standard HTML and CSS, and the developer can specify the behavioral aspects of the desired end result. This separation of UI exists down to the level of simple controls like labels, textboxes, buttons etc.

Anyway, I thought I’d highlight this aspect of Atlas now, because I have the perfect example to point at - Bertrand’s accordion control. Check it out (I know Bertrand will delve into more details on implementation in future posts), and then come back here.

Here is what you see in the page:

<div id="accordion1">
  <a href="javascript:;">Pane 1</a>
  <div id="Pane 1">
    This is Pane 1 in the accordion control.
  </div>

  <a href="javascript:;">Pane 2</a>
  <div id="Pane 2">
    This is Pane 2 in the accordion control.
  </div>

  <a href="javascript:;">Pane 3</a>
  <div id="Pane 3">
    This is Pane 3 in the accordion control.
  </div>
</div>

Simple vanilla HTML, that any designer can tweak to hearts content, in any HTML editor. This HTML doesn't indicate any of the behavioral aspects, such as which pane is visible, the animation used when one pane is slided over another, which panes are enabled/disabled etc. This is where xml-script comes into the picture. For instance (in your xml-script):

<accordion id="accordion1" />

This tag binds together an instance of the "Accordion" script object with the "accordion1" <div> element. The script object can now inspect contents to figure out the headers, and the corresponding panes, attach event listeners to add interactivity, attach animation effects to provide the actual sliding behavior and provide an object model that developers can use to programmatically manage panes etc.

Beyond achieving a split between content and behavior, what you also have is structural markup that makes logical sense when you look at the markup, and a mechanism to associate script behavior in an unobtrusive manner using Atlas and xml-script.

One of the reasons behind xml-script is to provide a designable mechanism to specify behavior. So in that sense, you could look at the designer/developer split as one wherein the developer puts together components like the Accordion, and the designer designs the page, and also add a set of these components from a toolbox of objects, and customize them in a declarative manner (for example, what type or how fast of an animation the accordion control should use).

Hopefully this provides more insight into some of the design choices of what you see in today's Atlas bits. What are your thoughts? Clearly this is an area that would benefit immensely with the appropriate tool support that is part of the overall vision.

Posted on Wednesday, 3/29/2006 @ 10:03 AM | #ASP.NET


Comments

11 comments have been posted.

Joel Rumerman

Posted on 3/29/2006 @ 2:58 PM
The separation between content and behavior is a good programming practice and I'm glad that the Atlas framework is providing such a mechanism. Unobtrusive JavaScript has been a topic of discussion for years and I'm glad that Atlas continues this paradigm with the Atlas use of xml-script. Remember the ASP days. If we forget history we're bound to repeat it. As for tools, I'd like to see an ability to graphically assign behaviors I've created to HTML on the page and then have it create the related xml-script in the correct spot. That would be a sweet step in the right direction.

Prasad Patnaik

Posted on 3/29/2006 @ 5:31 PM
The newer version of atlas is really made you hassle free, as the implementation is now much easier, the implementers do not need to know much about the java scripts which is embedded now.

There were some custom implementations of ATLAS JavaScript, now it is now working let me explain the scenario.

In the older framework of ATLAS now with the new framework I am using to call a web service from JavaScript I was using.

“Web.Net.ServiceMethodRequest.callMethod("/Services/Events.asmx", "LogEvents", { startOrEnd : "Start" } );”

Now “callMethod” is not available in ““Sys.Net.ServiceMethodRequest”, I need some clue how I can use that

David Ebbo

Posted on 3/29/2006 @ 6:01 PM
Hi Prasad,

Please try using Sys.Net.ServiceMethod.invoke, which is the replacement for the old Web.Net.ServiceMethodRequest.callMethod.

David

David Taylor

Posted on 3/30/2006 @ 10:40 AM
Hey Nikhil,

You once said you were going to pass on the communities request for a keyword to create properties for C# 3, such as:
public property string MyName;

This would be like the event keyword, and generate a private field and public get/set properties. I never heard back if the team is considering this, not even at the PDC last year.

I just thought, that reusing the get / set keywords might work well as in:
public get string MyName; // Just a getter property
public set string MyName; // Just a setter property
public get set string MyName; // Both a getter and a setter proprety

Anyway...just another idea instead of our earlier idea of public property string MyName;

intrader

Posted on 3/30/2006 @ 10:58 PM
And why not XFORMS?

Steve

Posted on 3/31/2006 @ 5:28 AM
Excellent.

The more I learn and dig in the more impressed I am.

I wonder: At what point will a developer approach a page and say "this needs to be traditional server-side page" vs. "we can create this using Atlas client-side" ?

ie. Is it 'better' to put an updatepanel 'wrapper' around a gridview, or instead use a listView.

Rick Strahl

Posted on 3/31/2006 @ 5:33 PM
Nikhil,

After playing around with the XmlScript client side ATLAS stuff I can say that I agree with your assessment that it is a good implementation in that it EXTENDS existing functionality rather than replace it. The way the extension mechanism works is sweet and the decalarative nature also is a step in the right direction.

One thing that I find lacking in XmlScript is better interaction with raw JavaScript code. It should be easier to delegate out to live code in addition to the property and event trigger routing that is done by the controls. While I can see that you guys are consciously trying to get away from raw JavaScript, it's important to retain some level of control so that low level tasks can still be accomplished. XmlScript is still an abstraction and it can't do everything - providing easier hooks into raw script code would help (the same incidentally is true for the server controls like UpdatePanel, which don't have pre and post handlers that make some scenarios difficult).

For me personally though I have to say the the XmlScript is hideously complex to write at this point. There's tons of pointing back and forth between controls and behaviors that makes this very difficult to get started with. Even looking at examples of a moderately complex form it's very easy to get lost in all the back and forth between the controls. Control element on the page, behavior to control, binding to Web Service, binding to control. There are A LOT of moving parts!

I think sometimes it's hard for you guys at Microsoft to see this because you are immersed in just this aspect all day long - most developers have to do more mundane stuff like worry about business logic along side the UI <g>... I'm sure you've heard this a million times before, but it seems to me the Xml script is mostly a non-starter until you have tools that can help create the markup for us in a somewhat interactive fashion.

Nikhil Kothari

Posted on 3/31/2006 @ 11:03 PM
Rick, that is a good and I think objective look at xml-script. I agree, we know too much of this stuff, and perhaps we also have spent enough time dreaming up of the possibilities given the right tool support. I know I have. Obviously that needs to become a reality... however, tooling takes more time, both in terms of development effort, as well as requiring enough learning and establishment of usage patterns in order to serve users right.

In terms of interaction with raw JavaScript - are you talking about inline script within xml-script, or just having more events to code to? We do need more top-level public events you can hook to global JS functions (ala click="doFoo" style) for both client controls and UpdatePanel. We are working on these... we'd love to hear feedback about specific events beyond the pre/post style events.

Steve

Posted on 4/1/2006 @ 7:07 AM
Nikhil - A great first step would be to provide visual design support for the listview and itemview. The sorting and navigation controls with the listview and itemview are quite good, it's just alot of typing to wire these all up.

That would be my first wish-list item for tool support.

If it could work like the gridview/datalist objects for creating templates, etc... I'd be quite happy with it

Thanks

rajiv

Posted on 4/11/2006 @ 5:47 AM
Iam gettin some flickering effect while using that accordion, any solution for that

Prasad Patnaik

Posted on 6/22/2006 @ 9:44 PM
Hi, Nikhil

I am using the gadget control, and a dataservice to papulate a listview it is working fine on the page but when i take it to live.com the data access stops, can u help me on this, have a look the code i have written.

<atlas:Gadget runat="server" ID="test">
<ContentTemplate>
<h5>Hello From Gadget</h5>
<div id="dataContents">
</div>
<div style="visibility: hidden; display: none">
<div id="masterTemplate">
<div id="masterItemTemplate">
<b><span id="masterName"></span></b>
<br />
<span id="masterDescription"></span>
<br />
</div>
<br />
</div>
<div id="masterNoDataTemplate">
No data</div>
</div>

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<dataSource id="dataSource" autoLoad="true" />

<listView id="dataContents"
itemTemplateParentElementId="masterTemplate"
propertyChanged="onChange">
<bindings>
<binding dataContext="dataSource" dataPath="data"
property="data"/>
</bindings>
<layoutTemplate>
<template layoutElement="masterTemplate"/>
</layoutTemplate>
<itemTemplate>
<template layoutElement="masterItemTemplate">
<label id="masterName">
<bindings>
<binding dataPath="Name" property="text"/>
</bindings>
</label>
<hyperLink id="masterDescription">
<bindings>
<binding dataPath="Description"
property="text"/>
</bindings>
</hyperLink>
</template>
</itemTemplate>
<emptyTemplate>
<template layoutElement="masterNoDataTemplate"/>
</emptyTemplate>
</listView>
<application load="LoadData" />
</components>
</page>
</script>

</ContentTemplate>
<Services>
<atlas:ServiceReference Path="Services/DataService.asmx" />
</Services>
<Scripts>
<atlas:ScriptReference Path="JScript.js" />
</Scripts>
</atlas:Gadget>
The discussion on this post has been closed. Please use my contact form to provide comments.