PDA

View Full Version : Ext.Direct for ASP.NET MVC



Pages : 1 [2]

Bucs
6 Nov 2010, 4:12 AM
Any idea why I would be getting the following error?

Stack Trace:


[MissingMethodException]: Method not found: 'Void System.Web.Mvc.ControllerBase.set_ValueProvider(System.Collections.Generic.IDictionary`2<System.String,System.Web.Mvc.ValueProviderResult>)'.
at Ext.Direct.Mvc.DirectMethodInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at Ext.Direct.Mvc.DirectProvider.ExecuteRequest(RequestContext requestContext, DirectRequest request)
at Ext.Direct.Mvc.DirectProvider.Execute(RequestContext requestContext)
at Ext.Direct.Mvc.DirectController.Router()
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Trying to do very simple SayHello() call to controller. Api is generated just fine:


Ext.app.REMOTING_API={
"url": "/Direct/Router",
"type": "remoting",
"actions": {
"Contact": [
{
"name": "SayHello",
"len": 0
},
{
"name": "List",
"len": 0
}
]
}
};


Copied SimpleTestPanel.js into my project and trying to call SayHello action in controller ContactController. Called like so in my SimpleTestPanel.js:


Contact.SayHello(function(result, response) {
this.updateBody(result);
}, this);


MVC assembly name is ContactManager and the following is in the web.config:


<configSections>
<section name="ext.direct" type="Ext.Direct.Mvc.Configuration.DirectSection, Ext.Direct.Mvc"/>
</configSections>

<ext.direct providerName="Ext.app.REMOTING_API" assembly="ContactManager" dateFormat="Iso" debug="true"/>


I have tried other methods etc. and all come back with the same error shown above. I also see "Unable to communicate with server." in client side debug as as the top most error, but could just be because something is failing on the server. When I call the method, it gets into the constructor of the Controller (using Dependency injection) but I get the above error before it ever gets to the action called (SayHello).

This has gotta be a setup issue, but cannot determine what as I thought I followed all instructions to the letter.

Thanks...

Bucs
8 Nov 2010, 5:28 AM
Just a quick thought. Though the Ext.Direct for ASP.NET MVC Wiki documentation does say that it would prudent to mark ALL controllers with [DirectIgnore] whose actions are not needed in the client side API, it might help to mention that the DirectProvider will fail if you don't mark the AccountController with the DirectIgnore or remove the controller altogether. It is created by default on MVC 2 projects so it must be dealt with one way or the other. Not sure if this is new to MVC 2.0 or not....but if not handled one of the two ways mentioned, the addProvider method will fail, and you will get the cryptic Javascript "null events" message.

elishnevsky
8 Nov 2010, 7:46 AM
Just a quick thought. Though the Ext.Direct for ASP.NET MVC Wiki documentation does say that it would prudent to mark ALL controllers with [DirectIgnore] whose actions are not needed in the client side API, it might help to mention that the DirectProvider will fail if you don't mark the AccountController with the DirectIgnore or remove the controller altogether. It is created by default on MVC 2 projects so it must be dealt with one way or the other. Not sure if this is new to MVC 2.0 or not....but if not handled one of the two ways mentioned, the addProvider method will fail, and you will get the cryptic Javascript "null events" message.

Thank you, it's a very good point. I've added a note to the end of Usage section.

Regarding your previous post, I really don't know what can cause this error. I have to see the setup.

Bucs
8 Nov 2010, 8:51 AM
Thanks Eugene. I rebuilt the project and am not getting that error anymore. I am still having one problem...wasn't sure if this was specific enough to this Ext.Direct ASP.NET MVC thread or not...so if not, please feel free to remove.

I am trying to decouple my MVC application as suggested by MS tutorials. I found that it's not really needed (or fun) to try and segregate the Controllers from the UI...unless it is absolutely necessary like for huge multi-team projects. However, I do see a few reasons to have the data layer in a separate projects, but I am having a helluva time getting it to work.

I am able to get Ext.Direct to work as expected against an EntityFramework Model when the EF model is placed in the Models folder of the same MVC project. However, when I created a separate project (Class Library) and copy all the service (business logic interface and concrete implementations) and data access files (repository interface and concrete implementations) into the separate project, create a ref to that project in the MVC project, I get the following error:



An error occurred when trying to create a controller of type 'ContactManager.Controllers.ContactController'. Make sure that the controller has a parameterless public constructor.


I am using a service layer (not web service, just term for business classes) and a repository pattern. So when the application starts, the Ext.Direct.Mvc kicks in to create the API which I'm guessing needs to create the Controllers. So, default.aspx page view is hit and fires the "httpHandler.ProcessRequest(HttpContext.Current);" line which then begins to instantiate the one Controller I have in the project like so:



namespace ContactManager.Controllers
{
public class ContactController : Controller
{
private IContactManagerService _service;

public ContactController()
{
_service = new ContactManagerService(new ModelStateWrapper(this.ModelState));
}

public ContactController(IContactManagerService service)
{
_service = service;
}
.......



The constructor code in the Controller then needs to instantiate the Service layer in the Models namespace so the data can be retrieved from the repository. So, after creating a quick ModelStateWrapper the above call instantiates the ContactManagerService as follows:



public class ContactManagerService : IContactManagerService
{
private IValidationDictionary _validationDictionary;
private IContactManagerRepository _repository;


public ContactManagerService(IValidationDictionary validationDictionary)
: this(validationDictionary, new EntityContactManagerRepository())
{}


public ContactManagerService(IValidationDictionary validationDictionary, IContactManagerRepository repository)
{
_validationDictionary = validationDictionary;
_repository = repository;
}
.......


This in turn needs to spin up a copy of the EntityContactManagerRepository so the actual database CRUD calls can be made. So that call is made:



public class EntityContactManagerRepository : ContactManager.Models.IContactManagerRepository
{
private ContactManagerEntities _entities = new ContactManagerEntities();
.........




This in turn instantiates the EF Model for the repository which point to a SQL Server database. It is in the definition line of the first constructor of the EntityContactManagerRepository class where the process fails with the error mentioned above:



public partial class ContactManagerEntities : ObjectContext
{
#region Constructors

/// <summary>
/// Initializes a new ContactManagerEntities object using the connection string found in the 'ContactManagerEntities' section of the application configuration file.
/// </summary>
public ContactManagerEntities() : base("name=ContactManagerEntities", "ContactManagerEntities") <== errors out here
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
........



Again, I would love to be able to use the EF Model and have this in a separate project for clarity....but not able to get around this error message yet. Again, if I copy all this code back into the MVC Project in the Models directory...and recreated the EF Model...it immediately works again. So, not sure if this is a problem with the Class Project instantiating the DB or an HttpContext passing issue, or what. When I create the EF Model in the separate project, at creates the app.config and the necessary connection string without any problems, so can'r see that as being the issue...hmm.

Any ideas? Thx...

elishnevsky
8 Nov 2010, 9:30 AM
Any ideas? Thx...

Sorry, no ideas here. I've never done anything with Entity Framework :(

Bucs
8 Nov 2010, 12:16 PM
FWIW, it was an EF specific issue with the connection string. I did not create a "Models" folder in the separate class library project where I created the new SQL Server EF Model, but rather generated the model in the root of that project. I had also left the orignal connection string in the web.config of the MVC project which originally had a Models folder when the SQLExpress EF model was created. This old connection string was taking precedence over the app.config connection string in the Model project. After looking at the connection strings, I noticed that there was a "Models." prefix pointer on the web.config conn string so that was making the EF look for the Models in a model specific folder, which didn't exist.

Bottom line, if you're using the EntityFramework and you want to separate out your Models into their own project, generate the model in that project and copy the resulting connection string back into the web.config of the MVC project.

The dreaded "learning curve" strikes again :)

Bucs
10 Nov 2010, 6:03 AM
Loving Ext.Direct.MVC...client-side JS is so clean now!

Question. How can I add multiple result sets to a ActionResult response from the server? Say I have the following server action:


public ActionResult LoadContact()
{
// Get a contact
var contact = _service.GetContact(3);
return this.Direct(new
{
success = true,
data = contact
});
}


If the Contact form that I will be loading this into has a State field, I want to retrieve all the states along with the form data and first load the States into the State field, then use setValues() on the form from the contact data. So if I have another method in the "_service" business class called GetStates(), would the following work and is this the recommended approach?


public ActionResult LoadContact()
{
// Get a contact
object[] formData = new object[2];
formData[0] = _service.ListStates();
formData[1] = _service.GetContact(3);

return this.Direct(new
{
success = true,
data = formData
});
}


Or, is the best practice to fire multiple (batched) requests directly from the client to accomplish this type of task? With that approach, I am worried that the form data may sometimes return before the necessary states data, though I have read that the batched requests will be processed in the order called.

Thanks

UPDATE: This seems to work fine, so I'll use it unless someone else has a better idea or if there is a another way to return multiple results using Ext.Direct.Mvc that I'm missing.

dan_b
10 Nov 2010, 9:01 AM
BUCS, you can do anything you want with the return object eg
return this.Direct(new
{
success = true,
data = formData
foo = foo,
bar = bar,
baz = baz
});

as long as formdata, foo, bar and baz can be serialized to JSON. You probably want to map your entities to simple dtos if they have complex associations/collections however before sending over the wire.

You can do really cool stuff with this.. I have a very complex form with a few grids and some combos on it and I want to load the data for the form and the grids & combos in one hit.. easily done:



<SNIP>
loadAfterRender: function (id) {
this.el.mask('Please wait...', 'x-mask-loading');
this.getForm().load({
params: {
id: id
},
failure: this.onLoadFailure,
success: this.onLoadSuccess,
scope: this
});
},
onLoadFailure: function (form, action) {
this.el.unmask();
var result = action.result;
Ext.MessageBox.alert('Failure', result.message);
this.clearForm();
},
onLoadSuccess: function (form, action) {
this.el.unmask();
var foo = action.result.foo;
if (foo) {
//do stuff with the data
//eg bind grid store to it
}
var bar = action.result.bar;
if (bar){
//do stuff with combos
}
},
</SNIP>

elishnevsky
11 Nov 2010, 9:45 AM
Bucs, sorry I couldn't reply sooner. Was extremely busy.
Now regarding your question. You can return anything you want from the server - simple types, arrays, objects... anything that Json.NET can serialize. However, as you know, when you are loading a form in Ext JS, you must return an object, that contains success and data. If you want to return additional information, just add it as a property to the object on the server. Suppose you have State class:

public class State {
public string Code { get; set; }
public string Name { get; set; }
}
Then your controller action to load contact form could look something like this:

public ActionResult LoadContact() {
Contact contact;
State[] states;

// initialize contact and states...

return this.Direct(new {
success = true,
data = contact,
states = states
});
}
Then on the client when you load the Contact form you can read the value of states and use it to populate the state combo-box. The combo can be configured like this:

{
xtype: 'combo',
itemId: 'state',
name: 'state',
hiddenName: 'state',
fieldLabel: 'State',
mode: 'local',
triggerAction: 'all',
store: new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['Code', 'Name']
})
}),
valueField: 'Code',
displayField: 'Name'
}
But you have to remember, that callback functions are called after the form sets the values of the fields, so you should also call assertValue() method of the combo-box after populating it, so that it will show the name of the state instead of a code.

Hope this helps.

Bucs
11 Nov 2010, 10:05 AM
Thanks Eugene, agree on using a separate property for other data sources rather than commingle in data property as that will not allow the auto population of form values with a standard getform().submit() call. So, I was not using the api{ load: Contact.LoadContact} property but rather using a standard button handler like so:



Contact.LoadContact(function(result, response) {
Ext.getCmp('State').getStore().loadData(result.data[0])
this.getForm().setValues(result.data[1]);
}, this);


I wasn't quite clear where to handle the response if I used the direct api config syntax for the load. I knew I could put a listener on the form load but was worried about the combo values not being available. I never knew about the assertValue() method :) So, then I should just put a listener on the form load, load the combo, then use the assertValue()? Will this cause a flash between the form value and display value though?

Thanks...

elishnevsky
11 Nov 2010, 10:39 AM
assertValue() method is private (i.e. not documented), but it doesn't mean you can't call it ;)

Using api config you can load you form like this:

contactForm.load({
success: function(form, action) {
var states = action.result.states;
var stateCombo = form.findField('state');
stateCombo.getStore().loadData(states);
stateCombo.assertValue();
}
});

dan_b
12 Nov 2010, 1:38 AM
But you have to remember, that callback functions are called after the form sets the values of the fields, so you should also call assertValue() method of the combo-box after populating it, so that it will show the name of the state instead of a code.

Hope this helps.

Ah, fantastic! I didn't know about that method. Nice one.

I posted a reply but it got swallowed by the forum's spam trap.

Bucs
16 Nov 2010, 10:09 AM
Is there any reason why I should not be able to use Ext.Direct.Mvc with Sencha Touch? I have configured everything properly as far as I know, and the Api file is create and viewable in Chrome debugger, but default page is failing with the message "Cannot call method 'addProvider' of undefined"...which really means this could be failing anywhere. I have added the call to "Ext.Direct.addProvider(Ext.app.REMOTING_API); " in the launch method of my main app page.

I just want to make sure that it's possible to use Ext.Direct.Mvc with Touch and that there is not something obvious that I am missing here.

Also, not sure if this is an Mvc question or Touch question so starting here.

Thanks

elishnevsky
16 Nov 2010, 10:34 AM
There is no support for Ext.Direct in Sencha Touch yet.

Bucs
16 Nov 2010, 10:37 AM
Well that would explain that :) Thanks for quick reply Eugene. And of course my next annoying question for you is...."are you planning to build in support for this in the future, and any idea when?" :)

Thanks again!

elishnevsky
16 Nov 2010, 12:41 PM
Perhaps I wasn't clear. It's not that my library doesn't support Sencha Touch. What I meant is Sencha Touch framework doesn't have a codebase for Ext.Direct yet. AFAIK they will add in one of the next major releases.

Bucs
16 Nov 2010, 12:45 PM
Yes, I understand that now as I sort of cross posted and found that out :) No worries, sounds like it's coming in 4.0, and Touch will have it then. Then I guess it depends on when you will update your implementation to support 4.0...due out 1st Q 2011.

elishnevsky
16 Nov 2010, 12:49 PM
I am at the conference right now and haven't heard anything about any changes in Ext.Direct package in version 4.0. So Direct API will probably remain the same as in 3.0 which will make my implementation work as it is.

Bucs
16 Nov 2010, 12:51 PM
That would be sweet. I'm jealous regarding the conference :(

elishnevsky
16 Nov 2010, 12:56 PM
That would be sweet. I'm jealous regarding the conference :(
The conference is really great!

bwaters
17 Nov 2010, 12:23 PM
Eugene,

About six months ago, I was working on a project that used this component. Specifically, I was using 0.8.2. At the beginning of June, the project was mothballed (and so was the machine). Well, we have a need to bring it back to life. When I fired up the machine, the app would not run (but did load without a problem) because apparently, I had used an evaluation copy of Sql Server 2008 that had expired, so I loaded up Sql Server 2008 R2. I tried loading the project to change the connection string in the web.config and realized that I was also using an evaluation copy of Visual Studio 2010. So, I installed a current version. I modified the web.config copied it to the web site (i did not re-deploy the whole project). I restarted the web site and attempted to access the app and only got a blank page. Ultimately, what I found was that Ext.app.REMOTING_API was undefined (it was failing in the addProvider call). All I can assume is the installing the new components must have changed something.

I really don't want to have to plug in the current version if I don't have to.

Any ideas?

Thanks, Brian.

Bucs
17 Nov 2010, 12:30 PM
Brian,

I would suggest you load the ASP.NET MVC source code as a project in your current app, remove the static Ext.Direct.Mvc DLL and point to the one form the source code bin dir. Then you can step into the source of the addProvider call and probably get more info as to why it's failing.

Also, make sure that you have marked the AccountController with the [DirectIgnore] attribute if you have one, or remove it altogether. MS started adding that controller to 2010 projects at some point and the addProvider call blows up when trying to create an Api for it.

HTH

dan_b
18 Nov 2010, 2:30 AM
Also, make sure that you have marked the AccountController with the [DirectIgnore] attribute if you have one, or remove it altogether.


I say just remove the damn thing altogether.

Bucs
18 Nov 2010, 5:56 AM
Agreed, the membership provider is kinda narly anyway, I wouldn't use it.

bwaters
18 Nov 2010, 6:28 AM
Well, I bit the bullet and decided to try just upgrade to the current version of Ext.Direct.MVC and without upgrading extjs (using version 3.1.1). Had to update all of the controllers because of the change to Direct() and the removal of DirectForm(). I was quite pleased that the app came up and worked without any additional changes.

I am actually using the AccountController and the methods were generated just fine.

Thanks for the suggestions.

veenvliet.morion
18 Nov 2010, 7:29 AM
You don't use membership at all? How do you do authentication, and working with [Authorize] Attribute?
Because of the [Authorize] attribute I work with the membership provider, or do you have another way to accomplish this?

bwaters
18 Nov 2010, 3:43 PM
I created a CustomAuthorize attribute that I use through out the controllers instead of the Authorize attribute. First it calls base.AuthorizeCore() and then it adds a custom header to the response that tells the client the result of the base.AuthorizeCore() call. The override of AuthorizeCore() then returns true.



public class CustomAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
bool result = base.AuthorizeCore(httpContext);
httpContext.Response.AddHeader("authorizationTimeout", result ? "false" : "true");
return true;
}
}


Always returning true from this method prevent being redirected to a different page and then allows the user to log back in an pick up where they left off.

Then in the client, I added the following:



Ext.data.Connection.on('requestcomplete', function (con, response, options) {
if (Ext.isFunction(response.getResponseHeader)) {
var authTimeout = response.getResponseHeader('authorizationTimeout');

if (authTimeout === 'true' && !Ext.isDefined(Ext.ComponentMgr.get('login-box'))) {
app.startLogin();
}
}
});


I am using Forms authentication and have set the timeout to a long period (2880). Then, on the client side, I have a local timeout such that if there is no activity for a certain amount of time, 20 minutes, the client will be prompted to log in again (while retaining their work). The user should be prompted to log in because of the client timeout long before the authentication times out on the server.

I am sure that there are other ways of handling this, but this is how I did it....

veenvliet.morion
19 Nov 2010, 6:50 AM
Interesting method. But does your controller still give back all the requested data? That would be a security hole, I think?

ttbgwt
19 Nov 2010, 2:28 PM
Congratulations Eugene. The work you have done is very impressive. Thanks!

Your example ran fine but I did get this build warning...

Warning 3 'System.Web.Mvc.ValueProviderDictionary' is obsolete: 'The recommended alternative is to use one of the specific ValueProvider types, such as FormValueProvider.' C:\Users\ttb\Downloads\Ext.Direct.Mvc-2.1.0\Source\Ext.Direct.Mvc\DirectMethodInvoker.cs 44 41 Ext.Direct.Mvc

ttbgwt
21 Nov 2010, 6:05 PM
Hi,

When direct batches calls, do they run in a specific order on the server? In the example below will onSayHello run on the server before onEchoDate runs?



onBatch: function() {
this.onSayHello();
this.onEchoDate();
this.onAddNumbers();
this.onEchoPerson();
},

elishnevsky
21 Nov 2010, 6:59 PM
Congratulations Eugene. The work you have done is very impressive. Thanks!

Your example ran fine but I did get this build warning...

Warning 3 'System.Web.Mvc.ValueProviderDictionary' is obsolete: 'The recommended alternative is to use one of the specific ValueProvider types, such as FormValueProvider.' C:\Users\ttb\Downloads\Ext.Direct.Mvc-2.1.0\Source\Ext.Direct.Mvc\DirectMethodInvoker.cs 44 41 Ext.Direct.Mvc

Thank you, I'm glad you like it.
I am well aware about this warning. It is fixed in the trunk so you are free to get it and compile it yourself. The reason I didn't officially deploy it yet is because it breaks support for ASP.NET MVC 1.0. I haven't decided yet whether to stop supporting it or not. Some day I'll make up my mind :)

elishnevsky
21 Nov 2010, 7:07 PM
Hi,

When direct batches calls, do they run in a specific order on the server? In the example below will onSayHello run on the server before onEchoDate runs?



onBatch: function() {
this.onSayHello();
this.onEchoDate();
this.onAddNumbers();
this.onEchoPerson();
},


Yes, the requests to the server are made in the same order the functions are called.

dan_b
22 Nov 2010, 7:58 AM
Here's how I handle session timeout/unauthenticated ajax requests:



public class CustomAuthorizeAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (filterContext.Result is HttpUnauthorizedResult && filterContext.HttpContext.Request.IsAjaxRequest())
{
filterContext.Result = new DirectEventResult(){Name="sessionExpired"};
}
}
}


and then client side:


Ext.Direct.on('sessionExpired', function (e) {
Ext.WindowMgr.each(function (item) {
item.close();
});
EBPC.GRACe.workspace.destroy();
EBPC.GRACe.workspace.init();
Ext.Msg.alert("Session Expired", "Your session has expired. Please log in again.");
});


Ext Direct makes this nice and easy!

ttbgwt
23 Nov 2010, 4:57 AM
Nice! Would it be possible to include this in the demo app, showing a demo login window and how to tie security/login all together?

olegtaranenko
23 Nov 2010, 2:16 PM
Hi,
current policy of the enterprise I'm working on forbids using VS 2010. There I'm interesting in support of the VS2008 to build Ext.Direct.Mvc project from the current trunk. Looking at the svn history I found the last 2008 solution and project files and adopted it to the last trunk version. I've renamed the .sln and .csproj files by adding .2008 suffix.
Eugene, could you please check and add the attached rar archive (just added extension .txt, Sencha upload facility!) to your project? Please support the 2008 version further.

Thanks, Oleg

elishnevsky
24 Nov 2010, 7:57 PM
Hi Oleg. Sorry, but I'm not going to add your files to the project simply because I don't have VS 2008 installed and of course I'm not going to edit these project files by hand :) But you shouldn't need to build it from the trunk really. When I make a series of changes, I usually deploy the dll's right away. And I do plan to keep supporting ASP.NET MVC 1.0.

olegtaranenko
1 Dec 2010, 11:06 AM
NOTE I've found solution. I've skipped the line

<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>

Sorry for bothering, this is really lame question :">
Not understand though, why MVC 1.0 does work?




I'm starting working with a Ext.Direct project based on the Ext.Direct.Mvc.Demo example. Specifically, I'd like to Integrate Jesus Garsia's app.extjsinaction.com with Ext.Direct.Mvc machinery.
If using System.Web.Mvc and Ext.Direct.Mvc 1.0 it does work

If switch to the Version 2.0 (for both) i'm getting an error below




Serverfehler in der Anwendung /.

Kompilierungsfehler

Beschreibung: Fehler bei der Kompilierung einer Ressource, die zur Verarbeitung dieser Anforderung erforderlich ist. Überprüfen Sie die folgenden spezifischen Fehlerdetails, und ändern Sie den Quellcode entsprechend.

Compilerfehlermeldung: CS0234: Der Typ- oder Namespacename "Mvc" ist im Namespace "System.Web" nicht vorhanden. (Fehlt ein Assemblyverweis?)

Quellfehler:


Zeile 31: <namespaces>
Zeile 32: <add namespace="System.Web.Mvc"/>
Zeile 33: <add namespace="System.Web.Mvc.Html"/>
Zeile 34: <add namespace="System.Web.Routing"/>
Zeile 35: </namespaces>

Quelldatei: c:\dev\reckitt\Pep\pep\Sources\Web.config Zeile: 33


Detaillierte Compilerausgabe anzeigen:

Vollständige Kompilierungsquelle anzeigen:


Versionsinformationen: Microsoft .NET Framework-Version:2.0.50727.3053; ASP.NET-Version:2.0.50727.3053


sorry for german, I have no english-based instllation. Goggle translate it to english =>



Server Error in '/' Application.

Compilation

Description: Error compiling a resource that is required to process this request. Check the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name "Mvc" is in the namespace "System.Web" does not exist. (Are you missing an assembly reference?)

Source Error:


Line 31: <namespaces>
Line 32: <add namespace="System.Web.Mvc"/>
Line 33: <add namespace="System.Web.Mvc.Html"/>
Line 34: <add namespace="System.Web.Routing"/>
Line 35: </ namespaces>

Source File: c: \ dev \ reckitt \ Pep \ pep \ Sources \ web.config Line: 33


Show Detailed Compiler Output:

View Full Kompilierungsquelle:


. Version Information: Microsoft NET Framework Version: 2.0.50727.3053; ASP.NET Version: 2.0.50727.3053


What I have missed?

Update: My web.config

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="ext.direct" type="Ext.Direct.Mvc.Configuration.DirectSection, Ext.Direct.Mvc" />
</configSections>
<ext.direct
namespace="PEP.Exec"
providerName="Ext.app.REMOTING_API"
assembly="Reckitt.Pep"
dateFormat="Iso"
debug="true"
/>
<connectionStrings>
<add name="SampleConnectionString" connectionString="Data Source=.\SSDE2005;Initial Catalog=PepMvc;Integrated Security=true;"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<!--
<authentication mode="None" />
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="None">
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
</namespaces>
</pages>
<httpModules>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="MvcHttpHandler" />
<remove name="UrlRoutingHandler" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
</configuration>



Disclaimer: I'm pretty new to whole of the .NET and ExtJS development, but have background in the Java/pure JavaScript dev.

elishnevsky
2 Dec 2010, 12:37 PM
Uploaded version 2.2.0.


* Returned support for ASP.NET MVC 1.0
* Added support for descriptor generation method (see Wiki)
* Allow regular content response when action is executed directly, i.e. not by Ext Direct

Download from the project homepage (http://code.google.com/p/ext-direct-mvc/).

ttbgwt
7 Dec 2010, 5:08 AM
Hi,

Do you have an example with security and authentication for logging into an extjs website?

elishnevsky
7 Dec 2010, 7:38 AM
Hi,

Do you have an example with security and authentication for logging into an extjs website?

No, I don't have this example, but it should be similar to form post.

daemon110282
29 Dec 2010, 5:42 AM
hi

do you have an example usign asp.net mvc model data validation in extjs?

ttbgwt
29 Dec 2010, 12:09 PM
In your EmployeesController code you return a list of Employees:



public class EmployeesController : Controller {

readonly SampleDataContext _db = new SampleDataContext();

public ActionResult Get(int start, int limit, string sort, string dir) {
var employeeList = _db.Employees
.OrderBy(sort + " " + dir)
.Skip(start)
.Take(limit);

var result = new {
total = _db.Employees.Count(),
data = employeeList
};

return this.Direct(result);
}
}


How can I get this to GroupBy the employee's Gender and to return data so it can be used by a TreePanel? It needs to return tree node data such as:

id = <gender id>,
text = <gender name>,
leaf = <true if Gender, false if person>,
@checked = false,
children = <persons grouped by gender

ttbgwt
29 Dec 2010, 1:57 PM
I figured it out.


public ActionResult GetPumpsTree()
{
var pumpList = _db.Pump_Datas
.GroupBy(pump => pump.Pump_Series, pump => pump.Pump_Description)
.Select(g => new
{
Series = g.Key,
Descriptions = g.ToList()
})
.OrderByDescending(t => t.Series)
//.Take(25)
.ToList();

var seriesArray = new ArrayList();
foreach (var pumpSeries in pumpList)
{
var descriptionArray = new ArrayList();
foreach (var pumpDescription in pumpSeries.Descriptions)
{
descriptionArray.Add(new
{
id = pumpDescription,
text = pumpDescription,
leaf = true,
uiProvider = "tristate",
@checked = true
});
}

seriesArray.Add(new
{
id = pumpSeries.Series,
text = pumpSeries.Series,
leaf = false,
uiProvider = "tristate",
@checked = true,
children = descriptionArray.ToArray()
});
}

var allPumpsArray = new ArrayList();
allPumpsArray.Add(new
{
id = "root",
text = "All Pumps",
leaf = false,
uiProvider = "tristate",
@checked = true,
children = seriesArray.ToArray()
});

return this.Direct(allPumpsArray.ToArray());
}

ttbgwt
31 Dec 2010, 12:57 PM
How can I get the result portion of the direct call to update the tree node? I think think the tree is only expecting the "result" portion?



{
"type": "rpc",
"tid": 2,
"action": "Test",
"method": "GetPumpsTree",
"result": [
{
"id": "12D",
"text": "12D",
"leaf": false,
"iconCls": "pump-series",
"uiProvider": "tristate",
"checked": true,
"expanded": false,




loader: new Ext.tree.TreeLoader({
preloadChildren: false,
directFn: Test.GetPumpsTree,
uiProviders: { tristate: Ext.tree.TreeNodeTriStateUI }
}),

nikolawannabe
11 Jan 2011, 2:48 PM
Is there any reason I should assume that Ext.Direct for MVC won't currently work with MVC3 RC2?

My application was originally built using Ext.Direct and MVC1. I'm prototyping and planning for next release, and am upgrading MVC to get the Razor templating language, but I'm having issues, and don't see any documentation stating whether or not it is expected to work with MVC3.

I've downloaded the most recent binaries that state they were compiled with VS2010 and included them in my project. It compiles fine but it is trying to access the api as a web page (:3151/Direct/ApiFailed to load resource: the server responded with a status of 404 (Not Found)).

Thanks!

elishnevsky
12 Jan 2011, 6:45 PM
I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.

nikolawannabe
12 Jan 2011, 9:04 PM
I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.

I just compiled your source against the MVC3 RC2 dll and the Newtonsoft library that ships with it. After upgrading the demo to MVC3, it seems to work fine.

When I try execute requests against the newly recompiled library on mine though, I get an error:

Method 'ReadJson' in type 'Ext.Direct.Mvc.RequestDataConverter' from assembly 'Ext.Direct.Mvc, Version=3.0.0.35856, Culture=neutral, PublicKeyToken=2ec707a789ea209b' does not have an implementation.

I figure this ought to be something simple since yours works fine but I've been digging for a while and haven't figured it out. Let me know if you have any ideas. Thanks again.

nikolawannabe
18 Jan 2011, 10:53 AM
I just compiled your source against the MVC3 RC2 dll and the Newtonsoft library that ships with it. After upgrading the demo to MVC3, it seems to work fine.

When I try execute requests against the newly recompiled library on mine though, I get an error.

Nevermind, I got it. I was using the wrong Newtonsoft dll. Using the one that ships with Ext.Direct works fine.

ttbgwt
7 Feb 2011, 12:44 PM
I want to pass back data and populate my class object, but it's erroring on converting into double[] DriveSpeed. What I actually want to do is pass back driveSpeed0, driveSpeed1, driveSpeed2, driveSpeed3 and have it populate the double[] DriveSpeed.



handler: function ()
{
//build the json to send
var pumpInputs = {
DriveSpeed: Ext.getCmp('driveSpeed0').getValue()
}

//send the json
Test.EchoGuiInputs(guiInputs, function (result, response) {
var guiInputs = result.data;
}
}




public class GuiInputs
{
public double[] DriveSpeed { get; set; }
}




public ActionResult EchoGuiInputs(GuiInputs guiInputs)
{
return this.Direct(new
{
success = true,
data = guiInputs
}, new StringEnumConverter());
}

dan_b
8 Feb 2011, 7:15 AM
I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.

Runs fine against MVC3 here.

ttbgwt
11 Feb 2011, 5:42 AM
Everything was going fine with development on my project and then I started getting a null reference exception error on the first line of my index.aspx. My computer did reboot with some windows updates. Has anyone seen this?


24670

Cloetn
16 Feb 2011, 7:18 AM
Hi , I'm currently trying your dll and going through your example you posted but I have some questions.

For the 'EmployeeGridView' example.
Is there any reason why you extend your GridPanel?

It is possible to just make a new GridPanel & render it into a div and get the same results?
I'm currently trying this but directFn doesn't go in my method in my controller.

elishnevsky
16 Feb 2011, 7:24 AM
I see you're new here, so welcome to the community. No, there's no particular reason in this case to extent GridPanel, this is just a standard practice when writing big applications, so I'm used to it. However, since this has nothing to do with my implementation of Ext.Direct for MVC, if you have more general questions about Ext JS, I would appreciate if you post them in corresponding forums. Here's also a good place to start with Ext JS: http://www.sencha.com/learn/
Good luck.

elishnevsky
16 Feb 2011, 7:26 AM
Everything was going fine with development on my project and then I started getting a null reference exception error on the first line of my index.aspx. My computer did reboot with some windows updates. Has anyone seen this?


24670

Never seen this before.

Cloetn
16 Feb 2011, 7:37 AM
I see you're new here, so welcome to the community. No, there's no particular reason in this case to extent GridPanel, this is just a standard practice when writing big applications, so I'm used to it. However, since this has nothing to do with my implementation of Ext.Direct for MVC, if you have more general questions about Ext JS, I would appreciate if you post them in corresponding forums. Here's also a good place to start with Ext JS: http://www.sencha.com/learn/
Good luck.

Thanks for the quick answer. I was a bit confused why you did it and thought it was meant to be that way but clearly not, so thanks for clearing that. I got my own example without the extent working now !




Everything was going fine with development on my project and then I started getting a null reference exception error on the first line of my index.aspx. My computer did reboot with some windows updates. Has anyone seen this?


24670

NullReference, check if your files are still in the right place or try rebuilding. Just a wild quess :)

novascape
17 Feb 2011, 12:29 AM
Hi all,

I'm new to ExtJS and want to use it with a .NET back-end. Ext.Direct for ASP.NET MVC seems really interesting and perfect for what I want to do. Obviously with ExtJS 4.0 now in preview release I would want to start with version 4.0.

My question is does the current release of Ext.Direct for ASP.NET MVC work with version 4.0?

Thanks in advance
Xander

Cloetn
21 Feb 2011, 6:13 AM
Hi again ,
I'm looking at your form example and I see you are using the 'CRUD' thingy.

Your Example:

api: {
load: Test.LoadPerson,
submit: Test.SavePerson
},

handler: function () {
this.getForm().load();
},


I'm trying to use it myself but I want to pass a param with the load function.

I have tried this but it doesnt seem to work.

api: {
load: Ticket.GetTicketById
},


afterRender:function(){
this.getForm().load({params:{id:'1'}});
Ext.ux.TicketDetail.superclass.afterRender.apply(this,arguments);
}

Any feedback?

Edit Post:

I can simply do this:


api: {
load: Ticket.GetTicketById(1)
},


and it will pass me the params but it gives me the

this.form.api.load is undefined

Line 45126

error. If I look into firebug I see he passes the param and I receive the data but the form doesn't get filled.

Edit 2:

Ok I feel dumb ;)
Just pass the params like you would pass them with a Store:



baseParams:{
id:'1'
},
paramOrder:'id'


Still need 2 learn quite a lot.

swarm
23 Feb 2011, 10:56 AM
Hi Eugene,

Just wanted to say nice work! Integrated this the other day with an MVC 1.0 app and it works perfectly and didn't take much effort.

Your documentation wiki page on Google Code was invaluable.


Thanks again.

wizkid
25 Feb 2011, 6:19 AM
I am also very interested in what would change for 4.0 of EXT JS... I am new to the MVC Ext.Direct but I assume it has no support for EXT JS 4.0's new models with data validation?

Has anybody started playing with the beta of EXT JS and the MVC Ext.Direct?

I would be very interested in what people have done with both as I am starting a new project and would like to start with EXTjs 4.0 from the start.

Cloetn
1 Mar 2011, 8:20 AM
I'm getting a bit frustrated about the speed my JSON requests are handled.
I'm getting an average of 1 sec per request to the server. This is too much in my opinion.

Is this because of Ext.Direct ASP.net or is this a common problem with every Ext.Direct?

I'm going to deploy my application tonight on my server and see if the speed changes , maybe it's because I'm working with the development server.

swarm
1 Mar 2011, 11:16 AM
I'm getting a bit frustrated about the speed my JSON requests are handled.
I'm getting an average of 1 sec per request to the server. This is too much in my opinion.

Is this because of Ext.Direct ASP.net or is this a common problem with every Ext.Direct?

It's happening because all the calls you were making individually might have been averaging say 200ms and each item would display data as it was loaded. By combining your requests you need to wait until the slowest one is complete before getting anything back.

Try altering the enableBuffer config option in your remoting api. You can set it to send more calls with fewer items in it. This will split up the slower requests (because of a slow stored procedure or whatever).

You could also consider sending the slowest requests individually so that the perceived performance isn't lowered. Because data is loading a user will still think everything is running smoothly...


I'm going to deploy my application tonight on my server and see if the speed changes , maybe it's because I'm working with the development server.

You should see a performance enhancement. I personally always find deployed apps are much quicker - they're not in debug mode and running on an server designed for the job etc...

Cloetn
1 Mar 2011, 12:40 PM
Thanks for the fast reply ,


It's happening because all the calls you were making individually might have been averaging say 200ms and each item would display data as it was loaded. By combining your requests you need to wait until the slowest one is complete before getting anything back.

It's not that. Even with 1 single call , nothing else it takes atleast 1 second.


Try altering the enableBuffer config option in your remoting api. You can set it to send more calls with fewer items in it. This will split up the slower requests (because of a slow stored procedure or whatever).

How do I do this exactly?

swarm
1 Mar 2011, 1:05 PM
Thanks for the fast reply ,
It's not that. Even with 1 single call , nothing else it takes atleast 1 second.


Does this include images? It could be something to do with your pc's configuration. I actually wrote an article about it here: http://www.swarmonline.com/2011/01/slow-asp-net-development-server-windows-7/




How do I do this exactly?


Add this provider instead of the one provided in the example:



Ext.Direct.addProvider({
type: Ext.app.REMOTING_API.type,
url: Ext.app.REMOTING_API.url,
actions: Ext.app.REMOTING_API.actions,
enableBuffer: 7 //or whatever value you want.
});

Cloetn
1 Mar 2011, 2:49 PM
Does this include images? It could be something to do with your pc's configuration. I actually wrote an article about it here: http://www.swarmonline.com/2011/01/slow-asp-net-development-server-windows-7/


Oh my god!
You are so awesome! Thanks for this solution. This is a HUGE difference.
Check it out !:

http://i.imgur.com/Qq6kc.png

swarm
1 Mar 2011, 2:51 PM
That's much more like the thing! Happy to help :)

dan_b
4 Mar 2011, 9:31 AM
Latest version: v2.2.0

New in this version:


Returned support for ASP.NET MVC 1.0
Added support for descriptor generation method (see Wiki)
Allow regular content response when action is executed directly, i.e. not by Ext Direct



Just seen this. Great work Eugene, thanks!

elishnevsky
4 Mar 2011, 12:26 PM
Thank you.

BharatRathi
5 May 2011, 5:16 AM
Hi Eugene,

Are there any plans to update ASP.NET MVC solution to support the latest from Sencha?


Bharat

elishnevsky
5 May 2011, 5:42 AM
As soon as I have free time. I've been extremely busy lately.

scancubus
12 May 2011, 9:52 AM
Hi, I am trying to implement this with EXT JS 4. Is this possible?

elishnevsky
12 May 2011, 9:53 AM
I don't know. I haven't tried yet. No time.

halcwb
17 May 2011, 4:11 AM
I have a working copy of my project using ExtJs 4.0 and Mvc3.0 using Ext.Direct. Seems to work very well, although I have not yet completed this project. But it is worthwhile to give it a try. You have to check out the Mvc3Demo project on the svn server of Ext.Direct.

johnsonkid
19 May 2011, 9:26 PM
For me it means that Ext.Direct passes method arguments in an array and not in object literal - that's perfectly OK, I don't want to pass arguments by name. I just want to pass more complex object structures as method arguments, and there's nothing in spec that would suggest it's not possible (actually, handling just simple value types would defeat the whole purpose of Json-RPC).
And it actually does handle complex Json on client side - see my posts above and the Json string - it is delivered to the server, but the server-side code does not deserialize it properly. I think it could be greatly improved if your code used the type information from method parameters to deserialize Json to proper data types, not just System.Object which is useless.

ttbgwt
7 Jun 2011, 8:38 AM
Looking forward to your findings.

zam6ak
5 Aug 2011, 8:40 AM
Eugene

I know you probably busy, but if you could comment on when (or if) will the project be ready for use with Sencha latest (Ext JS 4) and ASP.NET MVC3?

Also, if there are any plans to support Areas and sample with Pooling Provider (wiki briefly mentions to use controller extension???)

much appreciated

z..

elishnevsky
5 Aug 2011, 9:30 AM
zam6ak, you can get the source from the trunk and compile it against MVC3 yourself. It should be fine.

In Ext 4 Ext Direct specs haven't changed much since Ext 3, except maybe named arguments, but then again, my implementation allows a developer to pass object literals that are mapped to objects on the server. In my opinion it is better.

Regarding Areas, I never really bothered to learn them :) so I can't really comment on why my implementation doesn't work with Areas. I'll look into it when I have time.

mousedoc@msn.com
10 Oct 2011, 3:23 PM
I'm just beginning to evaluate ExtJS/Ext.Direct. Why would I use Ext.Direct for ASP.NET MVC (http://code.google.com/p/ext-direct-mvc/) instead of just returning a JsonResult from my ASP.NET MVC controller action?

DavidSSL
29 Oct 2011, 12:10 PM
I have downloaded the demo app from http://code.google.com/p/ext-direct-mvc/downloads/detail?name=Ext.Direct.Mvc-2.2.0.zip&can=2&q=

Then in the TestController, I've changed the code to



public ActionResult SaveForm(Person p)
{

if (ModelState.IsValid)
{
return this.Direct(new { success = true, data = p }, new StringEnumConverter());
}

return null;

}

If you run the code, Model State is not valid. My question is how is the "Required" validation on properties such as Gender, Birthday being implemented in this demo application? I've tried to look for evidence of DataAnnotation, xval, Fluent Validation but I was unable to find that out. So, I'm stumped here.

Regards,

David

dhana
8 Dec 2011, 3:04 AM
HI,
Intresting post.. This project can not be opend in VS 201 webdeveloper Express edition, It is opening a migration. It also gives migration wizard and It still unable to open the project.
Appreciate your updated version for VS 2010


Thank & Regards
Dhana

ttbgwt
28 Feb 2012, 9:27 AM
Any updates with this excellent library?

elishnevsky
28 Feb 2012, 9:33 AM
I've been slowly working on updating it for Ext JS 4.x and ASP.NET MVC 3. I made a lot of changes to how you configure and use the library. For example, by default no configuration is required at all, unless you want to customize something.

I've been pretty busy at my real work lately, but I will try to release something soon. Maybe within a week or two. Stand by :)

fordprefect
28 Feb 2012, 2:56 PM
Just came across this today - looks amazing! Definitely looking forward to the update!

gilcachaca
4 Mar 2012, 3:25 AM
Great news. Can not wait for this update.

elishnevsky
19 Mar 2012, 10:16 AM
Alright, guys. Just uploaded the new version of the library. It has been rewritten to make it easy to start a new project with it or to convert existing one from using regular AJAX requests to Ext Direct.

No backward compatibility with earlier versions!

Go to the first post for more info and all the links.

Make sure to read the documentation (http://code.google.com/p/ext-direct-mvc/wiki/Documentation)! Especially the Quick Start section if you're just starting.

Let me know what you think. Questions are welcome.

ovidiu
27 Mar 2012, 2:52 AM
Hi all!
I know that by default Direct use Newtonsoft library for JSON serialization. I wonder if there is any posibility to replace the serialization implementation with a custom one? (e.g. with DataContractJsonSerializer from Microsft)

Thanks,
Ovidiu

elishnevsky
27 Mar 2012, 6:11 AM
Hi all!
I know that by default Direct use Newtonsoft library for JSON serialization. I wonder if there is any posibility to replace the serialization implementation with a custom one? (e.g. with DataContractJsonSerializer from Microsft)

Thanks,
Ovidiu

No, and there's currently no plan to add this feature either.

rajaJs
9 Apr 2012, 4:46 PM
Thank you for this well written Ext.Direct. The demo is a great too. I am able to return DataTable as a "data" for Json result to bind it to a ExtJs Grid Panel.
However, I had to use some generic object (in my case a DataRow) to bind to Ext JS Form Panel. When I send the JsonResult with the DataRow as data, the form panel is not binding. Here is the code snippet for the LoadData,


[ActionName("GetData")] // Action alias
public ActionResult LoadData(int rowId)
{
DataRow dr = GridData.GetDataRow("Employee", rowId);
return Json(new
{
success = true,
data = dr
});
}


I tried sending the data as Json string (by converting DataRow to Json string), no luck either, see the code below,


[ActionName("GetData")] // Action alias
public ActionResult LoadData(int rowId)
{
DataRow dr = GridData.GetDataRow("Employee", rowId);
return Json(new
{
success = true,
data = GetJson(dr)
});
}

public string GetJson(DataRow r)
{
int index = 0;
StringBuilder json = new StringBuilder();
foreach (DataColumn item in r.Table.Columns)
{
json.Append(String.Format("\"{0}\" : \"{1}\"", item.ColumnName, r[item.ColumnName].ToString().Replace("\"", "\\\"")));
if (index < r.Table.Columns.Count - 1)
{
json.Append(", ");
}
index++;
}
return "{" + json.ToString() + "}";
}





Note: If I send data as any concrete POCO object to a ExtJs Form Panel it binds and shows data as expected. It is just the generic dynamic object that I am sending is not binding to ExtJs Form. I am sure I am missing something here to make it to work.

I really appreciate any help to achieve this. THANKS!!!

JavascriptParrot
18 Apr 2012, 11:48 PM
I'm give a try to implement Ext.Direct but I'm stuck at:



GET http://localhost:54323/directapi 404 (not found)


The example works fine, compare the configs but everything is the same.
Do I forget something or what I'm doing wrong?

Thanks!

veenvliet.morion
18 Apr 2012, 11:51 PM
Does this work?
GET http://localhost:54323/Direct/Api

Ext.Direct for ASP.Net MVC uses the Router mechanism MVC uses. (kinda ;) ).
Just check the example with Firebug or Webkit Dev tools to see what url is used to get the direct api.
Good luck!

JavascriptParrot
18 Apr 2012, 11:56 PM
Nope doesn't work, the example uses


<scripttype="text/javascript"src="/directapi (http://localhost:53874/directapi)"></script>


I think a need some ~o)

veenvliet.morion
19 Apr 2012, 12:12 AM
Your web.config is like it should be?
You have Ext.Direct... namespace included in your controller class files?

JavascriptParrot
19 Apr 2012, 5:23 AM
The web.config is nearly the same as the example config. No important differences, I have "using Ext.Direct.Mvc " add to the controller class... :-?

elishnevsky
20 Apr 2012, 6:03 AM
rajaJs, you're supposed to be returning raw data, that can be serialized to JSON object where members' names match field names of the form. And what you're doing is returning full DataRow object, it's not going to work. Just return an anonymous type, it's the easiest thing to do.

elishnevsky
20 Apr 2012, 6:08 AM
The web.config is nearly the same as the example config. No important differences, I have "using Ext.Direct.Mvc " add to the controller class... :-?

By default no configuration is required in Web.config. Are you using the built-in web server to run your app? Anyways, without seeing what you're doing it's hard to say.

JavascriptParrot
24 Apr 2012, 6:39 AM
I'm using the build in webserver to run the app.There are no config items in the web.config related to Ext.Direct.MVC.

Thanks

ttbgwt
30 Jul 2012, 9:27 AM
You should submit this to: https://market.sencha.com/addons

elishnevsky
30 Jul 2012, 11:12 AM
You should submit this to: https://market.sencha.com/addons

Thanks. Submitted. It should appear there under Connectors once it is approved.

allanace852
30 Jul 2012, 11:58 PM
Downloaded the latest demo (Mvc3Demo) and its working correctly, but after implementing the same exact way in my local project i got an error :

The resource cannot be found.Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /directapi



Then i created a blank MVC3 web project and apply the same way as what have on the demo and i've only got :


Ext.ns("Ext.app");Ext.app.REMOTING_API={"type":"remoting","url":"/DirectRouter/Index","actions":{}}; for the its directapi. i've this on my controller :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Direct.Mvc;


namespace MvcApplication4.Controllers
{
public class TestingController : DirectController
{
public ActionResult Details(int id)
{
return Json("asdfasdfasdf");
}
}

its been 4 days and i have not accomplish anything. tnx

allanace852
31 Jul 2012, 1:05 AM
Another one is, the created a separate project for my controller, how will i setup it?i have already tried :


<ext.direct
namespace="MyAssembly"
buffer="10"
maxRetries="1"
timeout="5000"
dateFormat="js"
debug="true"
/>is this correct?

elishnevsky
31 Jul 2012, 7:24 AM
allanace852

I honestly don't know how I can help you. To veryfy that everything is working I just created an empty MVC3 project, referenced the Ext.Direct.Mvc and Json.NET libraries and got it working right away. Then I created a Class Library project in the same solution, moved the TestingController there, referenced it from the MVC3 project and got it working without changing anything in the web project. I didn't even have to change the web.config.

My only advice to you is read the documentation and make sure you follow all the steps, there aren't that many. I don't know what else I can do for you.

ashkan
31 Aug 2012, 7:39 AM
hi all

i am new on extjs . i have a problem on ext.direct for asp.net mvc 3

here is my codes:

thos is my model:


Ext.define('Crm.model.Storage', {
extend: 'Ext.data.Model',
idProperty: 'Id',
fields: [
{ name: 'Id', type: 'int' },
{ name: 'CustomCode', type: 'string' },
{ name: 'Name', type: 'string' },
{ name: 'IsDefault', type: 'boolean' }
]
});


this is my store :



Ext.define('Crm.store.Storages', {
extend: 'Ext.data.Store',
model: 'Crm.model.Storage',
pageSize: 10,
autoLoad: true,
autoSync: false,
autoDestroy: true,
proxy: {
type: 'direct',
//directFn: Storage.List,
paramOrder: 'start|limit',
api: {
create: Storage.New,
read: Storage.List,
update: Storage.Update,
destroy: Storage.DeleteStorage
},
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
root: 'data',
encode: true,
writeAllFields: true
}
}
});


this is my app :


Ext.Loader.setConfig({
enabled: true,
paths: { 'Crm': '/app' }
});


Ext.require([
'Crm.model.Storage',
'Crm.store.Storages',
'Crm.view.StorageGrid',
'Crm.view.StorageForm',
'Ext.ux.plugins.FitToParent'
]);


Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);


Ext.application({
name: 'Crm',


models: ['Storage'],
stores: ['Storages'],


launch: function () {


var newAction = Ext.create('Ext.Action', {
text: 'انبار جدید',
disabled: false,
handler: function (widget, event) {
var record = Ext.create('Crm.model.Storage');
gridStorages.store.insert(0, record);
}
});


var deleteAction = Ext.create('Ext.Action', {
text: 'حذف انبار',
disabled: true,
handler: function (widget, event) {


var sm = gridStorages.getSelectionModel();


gridStorages.store.remove(sm.getSelection()[0]);


gridStorages.store.sync();


}
});


var formStorage = Ext.create('Crm.view.StorageForm', {
columnWidth: 0.30,
width: 350,
height: 550
});


var gridStorages = Ext.create('Crm.view.StorageGrid', {
columnWidth: 0.70,
autoHeight: true,
height: 550,
tbar: ['->', newAction, deleteAction],
listeners: {
selectionchange: function (model, records) {
if (records[0]) {
formStorage.loadRecord(records[0]);
deleteAction.enable(true);
}
}
}
});


var panelStorages = Ext.create('Ext.panel.Panel', {
title: 'مدیریت انبارها',
plugins: ['fittoparent'],
layout: {
type: 'column'
},
items: [gridStorages, formStorage],
renderTo: 'gridCt'
});
}
});


and finally it is my controller in asp.net mvc :



using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using CrmMvc.Models;
using DataAccess;
using Ext.Direct.Mvc;
using Model;
using Newtonsoft.Json;
using Service;
using StructureMap;


namespace CrmMvc.Controllers
{
public class StorageController : DirectController
{
private readonly Context _db = new Context();


public ActionResult List(int start, int limit)
{
var total = _db.Storages.Count();


var storages = _db.Storages.OrderBy(s => s.Id).ThenBy(s => s.CustomCode).Skip(start).Take(limit).ToList();


return Json(new
{
total = total,
data = storages
}, "json", Encoding.UTF8, JsonRequestBehavior.AllowGet, new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}




[FormHandler]
[ActionName("SaveStorage")] // Action alias
public ActionResult SaveStorage(Storage storage)
{


string msg = String.Empty;


if (storage.Id == 0)
{
_db.Entry(storage).State = EntityState.Added;
msg = "Saved.";
}
else
{
_db.Entry(storage).State = EntityState.Modified;
msg = "Updated.";
}
_db.SaveChanges();


return Json(new
{
success = true,
data = storage,
message = msg
});
}


[ActionName("DeleteStorage")]
public DirectResult DeleteStorage(int id)
{
string msg = String.Empty;


Storage storage = _db.Storages.Find(id);
_db.Storages.Remove(storage);
_db.SaveChanges();


msg = "Deleted.";


return Json(new
{
success = true,
data = id,
message = msg
});
}


protected override void Dispose(bool disposing)
{
_db.Dispose();
base.Dispose(disposing);
}


}
}


the grid is loading all storages but when the user selects one row on grid then press delete button on grid toolbar this exception raised :



The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'Ext.Direct.Mvc.DirectResult DeleteStorage(Int32)' in 'CrmMvc.Controllers.StorageController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters.


what can i do?

thnaks for your helps.

JavascriptParrot
3 Oct 2012, 1:47 AM
Hello,

Anybody know how to silence the unhandled exception popup in Visual Studio?

Thanks

WillFM
11 Oct 2012, 8:33 PM
I searched through the thread a bit and didn't see anything posted about this.

When I make a controller actions, with overloads, "directapi", won't make references to that controller.

Why is that?

ttbgwt
6 Nov 2012, 5:24 PM
Does this work with Visual Studio 2012?

elishnevsky
6 Nov 2012, 5:27 PM
Does this work with Visual Studio 2012?

I don't see why it shouldn't.

ttbgwt
6 Nov 2012, 6:19 PM
Have you tested with MVC 4 yet?

elishnevsky
6 Nov 2012, 6:22 PM
Have you tested with MVC 4 yet?

Yes. It works fine.

ttbgwt
6 Nov 2012, 6:31 PM
I just downloaded Visual Studio 2012, and was able to run your test project no problems. It migrated with minor warnings :)


I don't see why it shouldn't.

ttbgwt
6 Nov 2012, 6:44 PM
Can you please compile a version with MVC 4 and post on your site?

http://code.google.com/p/ext-direct-mvc/downloads/list


Yes. It works fine.

elishnevsky
6 Nov 2012, 7:38 PM
Can you please compile a version with MVC 4 and post on your site?

http://code.google.com/p/ext-direct-mvc/downloads/list

Here you are, try it:
http://ext-direct-mvc.googlecode.com/files/ext-direct-mvc4-bin.zip

Reference the Json.NET from the archive as well.

ttbgwt
7 Nov 2012, 4:35 PM
Thanks Eugene.... Can you please create a full package, binaries, source code, and test application for MVC 4 like you have for MVC 3?

elishnevsky
12 Nov 2012, 12:26 PM
The project has moved to GitHub. Head post has been updated, you may want to read it. Please update your bookmarks.

Ext Direct for ASP.NET MVC on GitHub (https://github.com/elishnevsky/ext-direct-mvc)

ttbgwt
6 Dec 2012, 7:10 AM
You may want to add the category "Ext Direct" to your library listing in the sencha market.

https://market.sencha.com/users/48/extensions/101

canxss
27 Dec 2012, 4:27 AM
Hi,

We've been using this implementation since Ext JS 3.x and now we are trying to upgrade our app to Ext JS 4.x but we are having some problems with the initialization of DirectProvider.

The problem is actions list is returning empty to the client. But this is't happening all the time. Sometimes it brings the correct, full list and sometimes it returns an empty list.

We didn't understand why this was happening do we had to debug the source code and found that inside the configure method while looping assemblies and finding appropriate types we were getting an exception:

A first chance exception of type 'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll

The assembly that was causing the error is "Microsoft.Practices.EnterpriseLibrary.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null". But we still don't know why we don't get this error every time.

There should be a way to exclude unnecessary assemblies or include the necessary ones. Especially in this case we just want our ASP.NET MVC project assembly to be checked for controllers\actions and not the others.

Hope that you detect the problem and it is fixed soon.

Thanks in advance

Ipek

Michael H
29 Dec 2012, 4:59 AM
In technology sector this forum is simply awesome that provided me amazing experience in using tech based products.

JavascriptParrot
2 Jan 2013, 4:45 AM
Hi all,

I got a problem, after publishing my project to the webserver Ext.Direct works any more.
The actions in the directapi file is empty:



Ext.ns("Ext.app");
Ext.app.REMOTING_API={
"type": "remoting",
"url": "/DirectRouter/Index",
"enableBuffer": 10,
"maxRetries": 1,
"timeout": 5000,
"actions": {}
};

It has to work tomorrow because we have a meeting with the customer.
Anybody knows what I'm doing wrong?

Thanks!

JavascriptParrot
15 Jan 2013, 11:46 PM
I fix it!

I download the source and add logging to the direct provider in the Config void, there was a problem with some Devexpress assemblies, I add a try catch and some logging, now it works fine!

Maybe the try catch and logging can be add in the official source?

elishnevsky
22 Jan 2013, 11:40 AM
Hi all,

Although I haven't been able to actively participate in the thread lately, I listened to your complains and requests and made a few changes around assemblies.

+ Added the ability to specify the name of the assembly that contains your Direct methods. This can be done via the new "assembly" config option in the web.config file of your MVC project. Multiple assembly names can be specified if separated by comma. This setting is optional and if omitted then all the referenced assemblies will be scanned for Direct methods. For example right now in the test project it looks like this:

<configuration>
<configSections>
...
<section name="ext.direct" type="Ext.Direct.Mvc.ProviderConfiguration, Ext.Direct.Mvc"/>
</configSections>
<ext.direct
assembly="Ext.Direct.Mvc4Test"
/>
....

+ Implemented a better way to extract types from each assembly. The new method should solve the issue when System.Reflection.ReflectionTypeLoadException is thrown.

Get the latest source from the GitHub and let me know if these changes solve your problems.

elishnevsky
1 Feb 2013, 9:43 PM
Ext.Direct.Mvc is now on NuGet

I published two packages - one for MVC 3 and one for MVC 4. Search for Ext.Direct and install the one that corresponds to the version of ASP.NET MVC that you're using.

Enjoy.

anmol
11 Mar 2013, 2:56 AM
hi jcsarda (http://www.sencha.com/forum/member.php?93115-jcsarda),
As your Get() function gets different parameters like start, limit, sort, dir.
Can i make a class say 'TestClass' having four different parameters 'start, limit, sort,dir'.
and can i send this class object from ExtJs to your serverside get function.
If yes how to do that, how the serialization will happen ?

ttbgwt
9 Apr 2013, 5:34 AM
Does this work with 4.2?

JNickVA
13 Apr 2013, 10:25 AM
My ASP.NET MVC3/ExtJS application requires multiple Views that need to be maintained as C# code. What would be the best way to use these Views from the client-side ExtJS? Can a Ext.Direct call to a Controller Action, which returns a View, be used? What would the syntax be in the ExtJS code? If this isn't the best way to accomplish the task, what is? The way I see this working is for each C# View to have a <script> tag to load the ExtJS .js file for the client-side code.

NicoExtForum
15 Apr 2013, 5:49 AM
Hi,
it seems we found an issue using the lastest version in a non "en-Us" environnement : when used to call a method with a Date parameter, Ext.Direct.Mvc return an invalid date or an exception when parsing the String : this problem occurs with the basic sample included with the source.

After looking at the source code, it seems the issue occurs in ReadJson method of the RequestDataConverter class where each JValue sent from the client are converted to string : if the JValue contains a DateTime the toString must specify the InvariantCulture to avoid parsing issue in the DirectValueProvider. To resolve the problem we've only add a check if the value is an IFormattable. Hence the following modification in the ReadJson method resolves the problem :


if (value is IFormattable)
{
data.Add(value == null ? null : ((IFormattable)value).ToString(null,CultureInfo.InvariantCulture));
}
else
{
data.Add(value == null ? null : value.ToString());
}

franklt69
24 May 2013, 8:31 AM
HI, I need some help to use [ValidateAntiForgeryToken] in some methods inside controller

I was trying something like that but i get error:



[ValidateAntiForgeryToken]
public ActionResult GetList(int start, int limit)
{

if (ModelState.IsValid){
var total = db.Contacts.Count();
var contacts = db.Contacts.OrderBy(c => c.FirstName).ThenBy(c => c.LastName).Skip(start).Take(limit).ToList();
return Json(new {
total = total,
data = contacts
});
}
else
{
return Json(new
{
message = "invalidrequest",

});
}

}



and from extjs I am doing it



onDirectstoreBeforeLoad: function(store, operation, eOpts){
var token = document.getElementsByName('__RequestVerificationToken').item(0).value;

Ext.apply(Ext.getStore('MyDirectStore').getProxy().extraParams, {
__RequestVerificationToken : token

});
}



error:



The required anti-forgery form field "__RequestVerificationToken" is not present.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Mvc.HttpAntiForgeryException: The required anti-forgery form field "__RequestVerificationToken" is not present.

Source Error:

Line 268: try {Line 269: controller.ActionInvoker = new DirectMethodInvoker();Line 270



any advice please

regards
Frank

franklt69
24 May 2013, 1:14 PM
I get this solution


in the client side:



onDirectstoreBeforeLoad: function(store, operation, eOpts){
var afth = document.getElementsByName('__RequestVerificationToken').item(0).value;

Ext.Ajax.defaultHeaders = {
'__RequestVerificationToken': afth
};
}



in the server side:

I create this class: (thanks to http://richiban.wordpress.com/2013/02/06/validating-net-mvc-4-anti-forgery-tokens-in-ajax-requests/ )




[AttributeUsage(AttributeTargets.Class)]
public class ValidateAntiForgeryTokenOnAllPosts : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
var request = filterContext.HttpContext.Request;

// Only validate POSTs
if (request.HttpMethod == WebRequestMethods.Http.Post)
{
// Ajax POSTs and normal form posts have to be treated differently when it comes
// to validating the AntiForgeryToken
if (request.IsAjaxRequest())
{
var antiForgeryCookie = request.Cookies[AntiForgeryConfig.CookieName];

var cookieValue = antiForgeryCookie != null
? antiForgeryCookie.Value
: null;

AntiForgery.Validate(cookieValue, request.Headers["__RequestVerificationToken"]);
}
else
{
new ValidateAntiForgeryTokenAttribute()
.OnAuthorization(filterContext);
}
}

}
}



and then in the controller I add it:




[ValidateAntiForgeryTokenOnAllPosts]
public class ContactsController : DirectController {




regards
Frank

DavidThi808
18 Jun 2013, 8:19 AM
What/where is Basic.Echo?

In main.js it calls Basic.Echo(). But I cannot find it documented anywhere. (Granted, a Google search on Basic.Echo finds a million other things first.) Where it is documented?

thanks - dave

DavidThi808
18 Jun 2013, 8:58 AM
Hi;

I'm trying to figure out how MvcTest works. I think I understand about half of it (maybe). If anyone could explain the following, it would be very appreciated:
ContactForm.js has load: Contacts.Get. That maps to ContactsController.Get. How? Does it use reflection on all DirectController child classes and on the name strip the Controller part off the name? (That's my best guess.)
Contact.js and Contact.cs are the same class. Is either auto-generated (and if so how) or do I have to create both sides and make sure I match?
The sample has <script type="text/javascript" src="@Url.Content("~/directapi?assembly=Test")"></script> - is there documentation of what params can be passed to directapi?
What are WebApiConfig, FilterConfig, & RouteConfig doing? Is that part of the plumbing between the server & client side? And do I need to understand it or do I just copy what is there for any app using this? (Even if I can just copy it blindly, is it explained anywhere? I'd like to understand it.)
Can I put the client side in a separate project from the server side? I want to create the client side in Sencha Architect.
thanks - dave

JavascriptParrot
17 Sep 2013, 11:48 PM
Hello,

I'm have some troubles with parsing dates, we build a application with is used in different time zones. While using the ISO datetime parser Ext JS see it as a string, so you have to parse it manually. When using the JS parser the client time zone is added what result in different time between the client and server.

How do you handle datetime fields?

Thanks

wayne.rudd
18 Sep 2013, 1:54 PM
I get around the timezone problem by putting in a convert function on the model fields that are dates to explicitly convert the string representation to a date


//2012-11-12T00:00:00
var thedate=new Date(v.substr(0, 4), v.substr(5, 2) - 1, v.substr(8, 2), v.substr(11, 2), v.substr(14, 2));

return thedate;

JavascriptParrot
19 Sep 2013, 6:31 AM
Nice!
Do you use the IsoDateConvert or the JavascriptConvert for serializing?

Thanks

wayne.rudd
25 Sep 2013, 7:59 PM
iso - which gives a nice readable string representation e.g. "2012-11-12T00:00:00"

The function on the model converts the string to a date without any js 'smarts' trying to do a timezone conversion

sudo rm -rf /
5 Nov 2013, 1:35 PM
On a form submit, I have some dynamic fields and can't have model on the back-end as is seen in the example submit. I would like to have the fields all put into an object dynamically though. Is there a way to handle this with this direct implementation? With Web API I could just drop it in a JObject.

ttbgwt
5 Nov 2014, 1:20 PM
Will you be updating the project to support extjs5 and the latest .NET mvc?

elishnevsky
6 Nov 2014, 3:50 AM
Will you be updating the project to support extjs5 and the latest .NET mvc?

Almost certainly not.

halcwb
6 Nov 2014, 8:25 AM
Will you be updating the project to support extjs5 and the latest .NET mvc?

I think this should be quite trivial. I have forked the excellent solution and just recompiled it against the latest libraries. I did not yet tried it with MVC5, but I can't imagine that there would be major problems. Using the solution with ExtJs 4 did not pose any problems.

wayne.rudd
16 Nov 2014, 11:12 PM
The original package has survives many ASP.NET MVC updates without problems or changes required. Currently on MVC 5.2.2 here without issue.

I don't think ExtJS 5.x changed the Direct spec in any way from ExtJS 4.x

I did some upgrade tests with ExtJS 5.0 and didn't encounter any Direct issues with the Ext.Direct library (although back on 4.2.2 for other reasons...)

Thanks to @elishnevsky for your excellent work on this library