Making a proper UI Model

9 views
Skip to first unread message

Peter Kjaer

unread,
Oct 19, 2011, 2:11:31 PM10/19/11
to Tridion PowerTools
Those of you who have checked out the code might have noticed that we
have an empty "Model" project.
In its place, we have a "Services" project containing the server-side
code for our Web Services - with the SVC files being in the Editor
project.
The Editor project also has a bunch of "xxxxServiceProxy.js" files to
call methods on the web services and handle the responses.

Well, all of that is about to change :)


I'm about to check in changes that makes the Model project a proper UI
Model; which means that all of the web services are located in that
project only (nothing in the Editor) and we automatically get
JavaScript proxy classes generated for us by the Tridion UI Core. This
also eliminates the need for the Services project.


That leaves us with 3 projects in the solution: Common, Editor, and
Model - with clear separation between the three.

You will need to add the Model and its configuration file in the same
way that the Editor is currently defined (virtual directory, entry in
System.config). And you will need to copy the Model assembly to your
WebRoot\bin folder, just like you do the other assemblies.


When you make a new tool, you will not need to create any JavaScript
code to talk to the web services: a class will automatically be
created for you. You should add "PowerTools2011.Model.Services" as the
namespace in the ServiceContract attribute (see Example.svc.cs). The
resulting JavaScript class will then be prefixed with this namespace
as well (e.g. PowerTools2011.Model.Services.Example). You add the SVC
file and its accompanying .cs file next to the other services in the
Model project, and add a new entry to services section of the
web.config file as well.


I will update the PowerTools guide. I have updated the existing
Example and ImageUploader tools so you can look at those to get an
idea of what this all means.


If you have any questions about any of this, fire away!

Reply all
Reply to author
Forward
0 new messages