PDA

View Full Version : ExtDirect4DotNet started



crp_spaeth
15 May 2009, 1:35 AM
After evant and shibubh already released two Solutions for ExtDirect <-> .net Comunication

I just proud to release mine.

After both Routers have nice Ideas I just took the best stuff from both and combine it into an Opensource Project i just released ExtDirect4DotNet.

http://code.google.com/p/extdirect4dotnet

So Whats the deal with this Router/Proxy?

You will not need to write your own Handler (but you still can).

All you need to get it running is

Include the JSON.NET dll into your Project,
Include the extdirect4dotnet dll and configure two handlers in your web.config


<add verb="*" path="directProxy.rfc" type="ExtDirect4DotNet.DirectProxy,ExtDirect4DotNet"/>
<add verb="*" path="directRouter.rfc" type="ExtDirect4DotNet.DirectRouter,ExtDirect4DotNet"/>


At this Point you are ready to go.

If you want to make a Method Call able from Extjs
just add an Attribute to its class by write the Line infront of your class
[DirectAction]
and add [DirectMethod] before the Method you want to share.

In the Example attached to the release at GoogleCode you will find the CRUDSampleMethods Class:

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ExtDirect4DotNet;
using System.Collections.Generic;
using ExtDirect4DotNet.helper;

namespace ExtDirect4DotNetSample
{

public class Person
{
public string id
{
get;
set;
}
public string email
{
get;
set;
}
public string first
{
get;
set;
}
public string last
{
get;
set;
}
}

/// <summary>
/// A sample Ext.Direct - Action - Class
///
/// Class is markt as DirectAction via the Direct Action attribute [DirectAction]
///
/// The Class extends ActionWithSessionState wich makes the curren SessionState in this Action
/// availible via the Session member.
/// </summary>
[DirectAction]
public class CRUDSampleMethods : ActionWithSessionState
{
/// <summary>
/// Just a small Id generator jusing the Session to store the highest id
/// </summary>
/// <returns>the Id</returns>
private string generateId()
{
Session["lastId"] = ((int)Session["lastId"]) + 1;
return Session["lastId"].ToString();
}

/// <summary>
/// Returns a (cached) List of Persons from the Session
/// </summary>
/// <returns>The List of Persons</returns>
private List<Person> getData()
{
return getData(false);
}

/// <summary>
/// Returns a (cached) List of Persons from the Session
/// </summary>
/// <param name="fresh">true to clear the Cache</param>
/// <returns>The List of Persons</returns>
private List<Person> getData(Boolean fresh)
{

List<Person> personList = (List<Person>)Session["CRUDMethodsData"];
if (personList == null || !fresh)
{
personList = new List<Person>();


Person p1 = new Person() { first = "Martin", last = "Späth", email = "email1@extjs.com", id = "1" };
personList.Add(p1);


Person p2 = new Person() { first = "Heinz", last = "Erhart", email = "email2@extjs.com", id = "2" };
personList.Add(p2);

Person p3 = new Person() { first = "Albert", last = "Einstein", email = "email1@extjs.com", id = "3" };
personList.Add(p3);
Session["CRUDMethodsData"] = personList;
Session["lastId"] = 3;

}

return personList;
}

/// <summary>
/// The C in Crud
/// Represents a properitary Logic for creating a Person Object
/// Adds it to the List in the Session and after that it returns back the Person
///
/// This Methode has bin marked as a DirectMethod via the DirectMethod Attribute [DirectMethod]
/// You can configure Different Options for this Methods by setting Properties in the Attribute.
/// While this Method will get Used in a CRUD Process and some of those Methodes need special Handling
/// the MethodeType is set To Create.
///
/// See the MethodType Doc for more information
/// </summary>
/// <param name="personToCreate">The Person that should get added to the List in the Session (represents a Record in Extjs)</param>
/// <returns>The Person that was created</returns>
[DirectMethod(MethodType = DirectMethodType.Create)]
public Person create(Person personToCreate)
{
personToCreate.id = generateId();

getData().Add(personToCreate);

return personToCreate;
}

/// <summary>
/// The R in cRud
/// Represents a properitary Logic for Reading.
/// Will return a List Of Persons Wrapped by a LoadResponse Class
///
/// This Methode is marked as a DirectMethod via the DirectMethod Attribute [DirectMethod]
/// You can configure Different Options for this Methods by setting Properties in the Attribute.
///
/// Special thing here is the ParameterHandling.
/// Which is set to AutoResolve her. This means that you can call the Function form the Javascript Side
/// like this:
///
/// CRUDSampleMethods.read({sort: 'email', dir:'ASC'})
///
/// and the DirectMethod Class will try to mapp those Parameters to the Parameters of the .Net Function
///
/// So this Function will get call as you would call it in .Net the following way.
///
/// read("email","ASC")
/// </summary>
/// <param name="sort">the property to Sort the List of Persons by</param>
/// <param name="dir">The Direction or "ASC"/"DESC"</param>
/// <returns>A LoadRespone Object that wraps the Persons</returns>
[DirectMethod(MethodType = DirectMethodType.Read, ParameterHandling = ParameterHandling.AutoResolve)]
public LoadResponse read(string sort, string dir)
{

List<Person> rows = getData();

switch (sort)
{
case "email":
rows.Sort(delegate(Person p1, Person p2)
{
return p1.email.CompareTo(p2.email);
});
break;
case "first":
rows.Sort(delegate(Person p1, Person p2)
{
return p1.first.CompareTo(p2.first);
});
break;
case "last":
default:
rows.Sort(delegate(Person p1, Person p2)
{
return p1.last.CompareTo(p2.last);
});
break;


}

if (dir != "ASC")
{
rows.Reverse();
}

return new LoadResponse() { Results = rows.Count, Rows = rows };
}

/// <summary>
/// The U in crUd
/// Represents a properitary Logic for Updating an existing Person in the List.
///
/// This Methode is marked as a DirectMethod via the DirectMethod Attribute [DirectMethod]
/// You can configure Different Options for this Methods by setting Properties in the Attribute.
///
/// The MethodType is Set to Uptdate here.
/// This means a Special Parameterhandling as well.
/// The Method will get Called from Extjs in the following Way:
///
/// update(1,{RECORD});
///
/// DirectMethodType.Update
///
/// Will Pass that into your Function
/// </summary>
/// <param name="sort">the property to Sort the List of Persons by</param>
/// <param name="dir">The Direction or "ASC"/"DESC"</param>
/// <returns>A LoadRespone Object that wraps the Persons</returns>
[DirectMethod(MethodType = DirectMethodType.Update)]
public Person update(string id, Person personWithUpdatedValues)
{
List<Person> persons = getData();
Person person = persons.Find(t => t.id == id);

// update logic
if (personWithUpdatedValues.last != null)
{
person.last = personWithUpdatedValues.last;
}

if (personWithUpdatedValues.first != null)
{
person.first = personWithUpdatedValues.first;
}

if (personWithUpdatedValues.email != null)
{
person.email = personWithUpdatedValues.email;
}

return person;
}

/// <summary>
/// The D in cruD
/// Represents a properitary Logic for Deleting an existing Person in the List.
///
/// This Methode is marked as a DirectMethod via the DirectMethod Attribute [DirectMethod]
/// You can configure Different Options for this Methods by setting Properties in the Attribute.
///
/// The MethodType is Set to Delete here.
///
/// An nother Special thing here is the OutputHandling Parameter
/// This ensures that the Followin Proccess Logic will not rerender the result of this methods
///
/// Make Sure that the ToString Function of this Function returns Clean JSON if you want to use this Method!
/// </summary>
/// <param name="id">Id Of the Person which should get deleted</param>
/// <returns>just retunrs Success to tell the store that the record was deleted on the Server.</returns>
[DirectMethod(MethodType = DirectMethodType.Delete, OutputHandling=OutputHandling.JSON)]
public string destroy(string id)
{
List<Person> persons = getData();
Person person = persons.Find(t => t.id == id);
persons.Remove(person);

return "{\"success\": true}";
}

/// <summary>
/// just a small function that resets the content of the Session Object
/// </summary>
[DirectMethod]
public void reset()
{
getData(true);
}
}
}


As you can see in the Example you got many Options to configure your methods by setting the properties of the Attributes:

For more Details just take a look at the Attribute Class itself.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExtDirect4DotNet
{
public enum DirectMethodType
{
/// <summary>
/// Contains a single Parameter with the Record to save.
/// If the method has only One Paramter the Parametr gets deserialzed with the typ of that parameter.
/// </summary>
Create,

/// <summary>
/// Since The parameter will come as a Hash e.g.: {sort: 'name', sortDir: 'DESC'}
/// the Hash will get mapted via Autoresolve.
///
/// The Function should have at least those two Parameters: (string sort, string sortDir).
/// </summary>
Read,

/// <summary>
/// Len gets set to 2 since the Update function gets called with two parameters
/// First is the Id of the Record, Second is the record with the updated data.
/// If The DirectMethod it self has two parametrs, the Seconde Parameter in the Request
/// Gets Serialized with the same type than the Function.
/// </summary>
Update,

/// <summary>
/// The Function will have only one Parameter the Id.
/// </summary>
Delete,

/// <summary>
/// Simple Function...
/// </summary>
Normal,

/// <summary>
/// Function with Form Specifix Handling (len gets set to 1 and the parameter will read out of the httpContext.Form)
/// </summary>
Form,

/// <summary>
/// This Method gets Handled as a normal Method but the Proxy will generate another Method with the posfix "_form"
/// where len gets set to 1 and the Parameterhandling for this gets done as a Form Method
/// </summary>
Hybrid
}

public enum ParameterHandling
{
/// <summary>
/// No Special Handling will be done
/// The Parameter mapping been done by parameter Position
/// </summary>
PassThrough,

/// <summary>
/// Set this to true to set len propertie to for normal Methodes (No CRUD Methods special handling) to 1 and try to resolve the parameter.
/// This makse it possible to submit paramers independend from their order same technic as in exct used
/// minimize paramter to one containing all the properties {name: 'Martin', lastname: 'Spaeth'} will execute
/// the following sample method
///
/// [DirectMethod(ResolveParameterNames=true)]
/// public string sample(string name, string lastname){
/// return "{name:"+name+",lastname:"+lastname"}";
/// }
///
/// will return an API definition like that:
///
/// "ActionName":[{"name":"sample","len":1,"formHandler":false}
///
/// And can get called from Ext like that:
///
/// ActionName.sample({lastname:'spaeth',name:'martin'});
///
/// </summary>
AutoResolve



}

public enum OutputHandling
{
/// <summary>
/// Used when the Method returns a Normal Object and this should get Serialized before it gets send to the Browser
/// </summary>
Normal,

/// <summary>
/// Signalize the router logic not do Serialisation after execution the method (Defaults to false )
///
/// If you return a json-string and do not set this to true you may end up with this:
/// "... data[{\"propertiename\":\"propertyValue\"}] ..." instead of
/// "... date[{"propertiename":"propertieValue"}"] ...
/// </summary>
JSON
}

/// <summary>
/// This attribute should be added to methods that will be Ext.direct methods.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class DirectMethodAttribute : Attribute
{
/// <summary>
/// Set this Option for Specific output Handling
/// </summary>
public OutputHandling OutputHandling = OutputHandling.Normal;

/// <summary>
/// Set this Option for specific parameter-mapping handling
/// This may influnce the len propertie of the Function
/// </summary>
public ParameterHandling ParameterHandling = ParameterHandling.PassThrough;

/// <summary>
/// Set this Option to specifie this Method for the CRUD Actions
/// </summary>
public DirectMethodType MethodType = DirectMethodType.Normal;

/// <summary>
/// Set this to true to let ExtDirect4DotNet try to SerializeParameter Types for you.
///
/// This Option makes is Usefull when you want to Call a method with a Date for Example
/// The Router will use the Newtonsofts deserialize Function and trys to deserialize the Json string into
/// The needed parameter
/// </summary>
public bool SerializeParameterTypes = false;



}

}


Just to summarize:

You can set the following Properties

MethodType

Create
Contains a single Parameter with the Record to save.
If the method has only One Paramter the Parametr gets deserialzed with the typ of that parameter.


Read
Since The parameter will come as a Hash e.g.: {sort: 'name', sortDir: 'DESC'}
the Hash will get mapted via Autoresolve.

The Function should have at least those two Parameters: (string sort, string sortDir).

Update
The Function will have only one Parameter the Id.

Delete
len = 1

Normal
Default. ParameterCount will get set to the number of Parameters the Function has

Form
Function with Form Specifix Handling (len gets set to 1 and the parameter will read out of the httpContext.Form)

Hybrid
This Method gets Handled as a normal Method but the Proxy will generate another Method with the posfix "_Form"
where len gets set to 1 and the Parameterhandling for this gets done as a Form Method



ParameterHandling

PassThrough
No Special Handling will be done
The Parameter mapping been done by parameter Position

AutoResolve
Set this to set len propertie to for normal Methodes (No CRUD Methods special handling) to 1 and try to resolve the parameter.
This makse it possible to submit paramers independend from their order same technic as in exct used
minimize paramter to one containing all the properties {name: 'Martin', lastname: 'Spaeth'} will execute
the following sample method


[DirectMethod(ResolveParameterNames=true)]
public string sample(string name, string lastname){
return "{name:"+name+",lastname:"+lastname"}";ParameterHandling
}

will return an API definition like that:


"ActionName":[{"name":"sample","len":1,"formHandler":false}

And can get called from Ext like that:

ActionName.sample({lastname:'spaeth',name:'martin'});



OutputHandling

Normal
Used when the Method returns a Normal Object and this should get Serialized before it gets send to the Browser

Signalize the router logic not do Serialisation after execution the method (Defaults to false )

JSON
If you return a json-string and do not set this to true you may end up with this:
"... data[{\"propertiename\":\"propertyValue\"}] ..." instead of
"... date[{"propertiename":"propertieValue"}"] ...


Another great Feature of ExtDirect4DotNet is:
Automatic Parameter Deserialization

This makes it Possible to have every Kind of Class as a Parameter for your .net Classes
as long as they are deserializable by JSON.NET:

Example

You can define Class named Person


public class Person
{
public string id
{
get;
set;
}
public string email
{
get;
set;
}
public string first
{
get;
set;
}
public string last
{
get;
set;
}
}

now you can use this class as Parameter for a Function.



// function within an DirectAction marked Class called DirectAction:

[DirectMethod]
public string getName(Person person)
{
return person.first + " " + person.last;
}


you can now call this class by



DirectAction.getName({last: 'spaeth', first:'martin'}, function(res){alert(res)});



If the Deserilization fails it will return an Exception.


Use Session State in your Methods

As you can see in the CRUD-Sample

You can implement IActionWithSessionState or just extend from ActionWithSessionState

to Have Access to the current Session via the now available Session property.



If you like to give this a try just download:
http://extdirect4dotnet.googlecode.com/files/extdirect4dotnet.zip

This Zip includes two Full documented Samples and Testscenarios

Btw. If someone would like to join the Project feel free to send me an PM.

crp_spaeth
18 May 2009, 2:45 AM
I have just added Paging to the CRUD Example


http://extdirect4dotnet.googlecode.com/files/extdirect4dotnet.zip

loihai
21 May 2009, 8:41 AM
I downloaded your sample code, built, and placed it on localhost... Couldn't get the samples to work..
I get a "File not found" on hxxp://localhost/ExtDirect4DotNetSample/directProxy.rfc
Any ideas :-/
Thanks.

crp_spaeth
21 May 2009, 1:46 PM
this is kind of wired since the project runs out of the box on a view machines now.

did you change anything in the web.config?

Are the following lines included in the web.config?

<add verb="*" path="directProxy.rfc" type="ExtDirect4DotNet.DirectProxy,ExtDirect4DotNet"/>
<add verb="*" path="directRouter.rfc" type="ExtDirect4DotNet.DirectRouter,ExtDirect4DotNet"/>

Did you start the project from VS2008 ?

loihai
22 May 2009, 8:13 AM
I'm using VS2008 Pro SP1 on WindowsXP

These are in the web.config file under httpHandlers


<add verb="*" path="directProxy.rfc" type="ExtDirect4DotNet.DirectProxy,ExtDirect4DotNet"/>
<add verb="*" path="directRouter.rfc"type="ExtDirect4DotNet.DirectRouter,ExtDirect4DotNet"/>

crp_spaeth
22 May 2009, 8:27 AM
Is it working if you just start the broject in debuggmode from vs2008?

wojan
23 May 2009, 7:06 AM
You shouldn't use session as it doesn't scale well. It also promotes the use of magic strings to look stuff up.

crp_spaeth
24 May 2009, 4:39 AM
There are several cases where you will need to have access to the current session from an direct method thats why i implemented the ActionWithSession.

In the Example I just use Session cause its a easy way to store Data.

jeffypop13
19 Jun 2009, 12:24 PM
There are several cases where you will need to have access to the current session from an direct method thats why i implemented the ActionWithSession.

In the Example I just use Session cause its a easy way to store Data.

Can you elaborate on what requires session state? I've looked into the three Ext.Direct options for .NET, and I selected your implementation as the best fit for our software. However, it is a requirement that session state is turned off in our production environments. What impact will this have to your project?

Also, this is a little nit-picky, I'm sorry, but would you please consider dropping the "4DotNet" from your project name / namespaces? Of course it's for .NET!

crp_spaeth
20 Jun 2009, 12:22 AM
Hey jeffypop13,

nice to hear you decide to use my implementation.

About your Questions:
The only reason why the DirectRouter-Class implements IRequiresSessionState is that you can create a Class that implements IActionWithSession in which you have access to the Session.
I don't do any operations on the Session in my Project nor do I store any information in the Session in the Project. I dont think turning of the session will have any kind of impact to ExtDirect4DotNet.

About the Project Name and its namespace. I decide to Call the Project ExtDirect4DotNet to make it easier to find in google. I see your point that 4DotNet in the NS is kind of redundant... I'll consider this and will see what I can do.

jeffypop13
20 Jun 2009, 6:31 AM
Great! Thanks for your reply.

arilisto
28 Jul 2009, 6:50 AM
Hi I´m using your solution, but i´m having a problem loading a tree, the directFn is never called, have you got any idea??





Ext.onReady(function(){
Ext.Direct.addProvider(Ext.app.REMOTING_API);

var tree = new Ext.tree.TreePanel({
width: 400,
height: 400,
autoScroll: true,
renderTo: document.body,
root: {
id: 'root',
text: 'Root'
},
loader: new Ext.tree.TreeLoader({
directFn: NavigationManager.GetTreeData
}),
fbar: [{
text: 'Reload root',
handler: function(){
tree.getRootNode().reload();
}
}]
});
});



- the NavigationManager class inherits from ActionWithSessionState and has the DirectAction tag
- the GetTreeData Method has the DirectMethod tag with DirectMethodType Read.

crp_spaeth
28 Jul 2009, 9:34 AM
Hey arilisto,

One Reason the Function never gets called is the wrong version of the Extjs libary. The js file I added to the Example was a version around rc1 which doesn't support directFn.

By the way Take a look into the SVN Log and update your ExtDirect4DotNet from time to time!
The Svn-Log can befound here:
http://code.google.com/p/extdirect4dotnet/source/detail?r=20

I just added a Tree Example to the SVN a few seconds ago!!!

This Commit also contains a fix for the issue descripted by loihai (http://extjs.com/forum/member.php?u=10198). (IIS seems to ignore the web.config entries for the router.)


regards Martin

arilisto
28 Jul 2009, 11:51 AM
Thanks Martin!!!!


Hey arilisto,

One Reason the Function never gets called is the wrong version of the Extjs libary. The js file I added to the Example was a version around rc1 which doesn't support directFn.

By the way Take a look into the SVN Log and update your ExtDirect4DotNet from time to time!
The Svn-Log can befound here:
http://code.google.com/p/extdirect4dotnet/source/detail?r=20

I just added a Tree Example to the SVN a few seconds ago!!!

This Commit also contains a fix for the issue descripted by loihai (http://extjs.com/forum/member.php?u=10198). (IIS seems to ignore the web.config entries for the router.)


regards Martin

arilisto
29 Jul 2009, 9:16 AM
In your last update when you migrate to EXT 3.0, there is an error in api Proxy from store, AdamDawes post a solution to solve it.

http://extjs.com/forum/showthread.php?t=75235

crp_spaeth
30 Jul 2009, 10:29 PM
Fixed in reversion 30 in the SVN. (New Zip added to the Download area)!

antb
17 Aug 2009, 1:54 AM
Hello,
Just in case it helps anyone... you can get rid of the ashx files (or at least it works on my machine...) if you replace the <handlers> section in the web.config with the following + replace all the <script> sections which point to the ashx files with ones which point at the .rfc handlers i.e. replace '<script type="text/javascript" src="../directProxy.ashx"></script>' with '<script type="text/javascript" src="../directProxy.rfc"></script>' in the examples html files.



<handlers accessPolicy="Read, Execute, Script">
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="DirectRouter" path="directRouter.rfc" verb="*" type="ExtDirect4DotNet.DirectRouter" resourceType="Unspecified" requireAccess="Execute" preCondition="integratedMode" />
<add name="DirectProxy" path="directProxy.rfc" verb="*" type="ExtDirect4DotNet.DirectProxy" resourceType="Unspecified" requireAccess="Execute" preCondition="integratedMode" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>

crp_spaeth
17 Aug 2009, 8:24 PM
Hey antb,
I did not find the time to get the rfc thing running under IIS but I will give your one a try! Thank you for figuring out! By the way you will not need to write ../ before directProxy.rfc since the proxy should be available from every path.

regards Martin

crp_spaeth
26 Oct 2009, 11:20 PM
Hey there,

Since this thread haven't been replied for a while now I just would reaktivate it and ask you Ext-Direct users out there who actually uses this Implementation of the Serverstack.

Did you find any bug or usecase you may want me to think about?

Would be nice to get some feedback again...

Best regards Martin

TonySteele
1 Feb 2010, 2:39 PM
Just moving to V3 EXTjs and your DotNet implementation appears to be the best fit for my requirements, so giving it a try and let you know how I'm getting on.

crp_spaeth
1 Feb 2010, 3:50 PM
Hey Tony,

nice to have another bump :)

you may want to check out the current branch as well, (Version 2) so you may get an idea whats gonna Change.

There will be a bunch of new possibilities with future implementations like pre/post invocation handling, a new MetaData Logic that makes it really easy to deal with DataSets and DataTables and many more.

TonySteele
15 Mar 2010, 2:23 PM
Just about to start using it, was looking at version 2, was branched in 11th Nov but no work on that branch since. All work seems to be in the SpketDirectDoc branch ?

Tony

crp_spaeth
15 Mar 2010, 2:27 PM
Jeah... kind of bussy atm :( Would like to clean up things but i am currently working on a big project using extjs in the frontend Ext-direct in the middelware and a soap Server in the backend... War on all fronts :P It seems to me that i didn't realize i was on the wrong branche for a long time... :((:((:(( all work done in this SPKET branch will become 2.0 one day...

crp_spaeth
15 Mar 2010, 2:30 PM
BTW I been using the head version of that spket branch and it just works fine.. If you come up with any question just let me know! I will try to take the time to dive into it!

TonySteele
15 Mar 2010, 4:00 PM
Thanks I'll give it a try

Mjollnir26
18 Mar 2010, 8:17 AM
FYI and FWIW, this Lib doesn't work[as in compile] with the latest Newtonsoft.NET release
http://json.codeplex.com/releases/view/37810 ( - for .NET 3.5, Release 6 )

- Is there a specific reason for this?
- Is the "SpektBranch" the latest and best Version of the Lib?

I fixed the Newtonsoft Issue already but for the trunk branch IIRC... seemed to work perfectly afterwards.

I'll try and fix this version too... If u want and send u a zip / patchfile / whatever.

We can communicate via PM, email or Skype in German too if u want.

crp_spaeth
31 Mar 2010, 3:40 PM
Hey Mjollnir26, sorry about the delay...

Thanks for your reply maybe you could send me your skype user and I will contact you as soon as possible!

best regards Martin

kayowas
25 Oct 2010, 12:02 PM
Hi there,

I'm trying your examples and I have the impression that they run slow. By slow I mean images to build the ext UI take some time to load. I tried with others ext.direct implementations, running as well on my localhost, and they seem to work just fine, so I cannot blame either ext library or my test environment. Am I missing something?

Thank you so much!

Mjollnir26
26 Oct 2010, 12:52 AM
Maybe the Images are loaded from the extjs.com Site?
Did you set the following before the Ext.onReady Code?

Ext.BLANK_IMAGE_URL = 'images/s.gif';

crp_spaeth
26 Oct 2010, 1:01 AM
You may forget to set caching for images in your iis settings. this may leads to an seperate request for every usage of a picture...

kayowas
26 Oct 2010, 7:58 AM
Hey guys,

Thanks a lot for your answers!

But by replacing ext calls to cachefly, which worked just fine, I realized that my problem indeed had something to do with my localhost (well, not quite! ;-)). After that, by diggin' a bit through the web, I was able to fix the problem. I quote from the web site I attach below:

"It turns out that the slowness is caused by an IPv6 issue with DNS and can easily be resolved by turning IPv6 support off in Firefox while doing localhost testing. To make the change, type about:config in the address bar, locate the network.dns.disableIPv6 setting and double-click on it to set it to true. This does the trick for the Firefox localhost issue on Vista and everything is running fast again."

Now, I use Windows7, but nonetheless, I Changed this setting and things are smooth as they are supposed to!

here's the URL: http://weblogs.asp.net/dwahlin/archive/2007/06/17/fixing-firefox-slowness-with-localhost-on-vista.aspx

Thanks again and best regards!

BharatRathi
5 May 2011, 5:08 AM
Hi,

Are there any plans to update ExtDirect4DotNet to support Ext JS / Direct 4.x?

sreeser
13 Oct 2011, 8:28 AM
I'm using ExtJS 4 with the MVC model for an app and am running into a javascript error when I try to create a new record. My app is very similar to the MVC example from the docs.

I'm creating a new record (instance of the model) and after setting its values I call the save method on it.I get an error at line 26607 of ext-all-debug.js which is the callback for the save function. It is looking for the record attached to the response and it sees that 'resultSet' is defined and looks for the first element in it. but 'resultSet' is an empty array. The data from the request is stored in the 'records' property

Here is my model code with the proxy defined:


Ext.define('AM.model.User', {
extend: 'Ext.data.Model',
requires: ['Ext.direct'],
fields: [{name:'id',type:'int'},'name', 'email'],
proxy: {
type: 'direct',
api: {
create: AccountManagerExchange.Create,
read: AccountManagerExchange.Read,
update: AccountManagerExchange.Update,
destroy: AccountManagerExchange.Delete
},
reader: {
root: 'data'
}
}
});

Here is my store:


Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
autoLoad: true
});

Here are the functions that create the record and attempt to save it after the user fills a form:


// Updates account when user presses save in editor
updateAccount: function(button) {
var win = button.up('window'), // Get the editor window
form = win.down('form'), // Get the editor form
record = form.getRecord(), // Get the record that was loaded into the form
values = form.getValues(); // Get the values from the form
// Set the record's values to the updated
record.set(values);
// Save the record to the server
record.save();
// Get rid of the dirty markers on fields after saving
record.commit();
win.close();
},
// Creates a new account and opens editor when user presses Create from the grid
createAccount: function(button) {
// Create the new user record
var newUser = Ext.create('AM.model.User');
// Open a new edit window for the new user
var view = Ext.widget('useredit', {isNewAccount: true});
// Find the form and load the new user record
view.down('form').loadRecord(newUser);
}

Up to this point everything works fine, the model sends the correct action to the server which adds the user just fine. The request and response looks like this:


Request:
{
"action":"AccountManagerExchange",
"method":"Create",
"data":[{
"id":0,
"name":"testUser",
"email":"test@example.com"
}],
"type":"rpc",
"tid":2
}

Response:
[{
"type": "rpc",
"name": null,
"tid": 2,
"action": "AccountManagerExchange",
"method": "Create",
"result": {
"id": 3,
"name": "testUser",
"email": "test@example.com"
},
"message": null,
"where": null,
"errorcode": 0
}]

As you can see the result has had the id updated. When the callback for the save action is executed the Ext.data.Operation has a resultSet property (an Ext.data.ResultSet) which has no records in it. The operation's response property has a result defined as the object that was expected. It is not wrapped in an array.

I tried to include all helpful information, if there is any information that would be useful please let me know. Thank you for your response,
Sean

Edit: I solved my problem, I just had to wrap the return value in an array.

crp_spaeth
13 Oct 2011, 4:07 PM
Was just about to dive into your problem good to know you solved it by yourself!

brownmonk
9 Feb 2012, 4:16 PM
How would I need to set up my direct method to

ResourcePresenter.SaveResources(resourceArray, callback);


Right now I have it like this and it works when store.sync magically does everything for me. I want to start calling these things myself.

[DirectMethod]
public ResourceDto[] SaveResources(Dictionary<string, object> callParams)
{
var resourceClient = new ResourceClient();


List<ResourceDto> list = new List<ResourceDto>();


foreach (var kvp in callParams)
{
if (kvp.Value is JObject)
list.Add(JsonConvert.DeserializeObject<ResourceDto>(kvp.Value.ToString()));
else if (kvp.Value is JArray)
foreach (var obj in kvp.Value as JArray)
list.Add(JsonConvert.DeserializeObject<ResourceDto>(obj.ToString()));
}


ResourceDto[] resourceDtos = list.ToArray();
return resourceClient.SaveResources(resourceDtos);
}

crp_spaeth
10 Feb 2012, 4:03 AM
I am not sure if I got the point here...

what about


ResourcePresenter.SaveResources({
rows : [
{ name : 'test' } // in this case the structure of your ResourceDto
]
}, function() {
console.log(arguments); // or your logic after comit on the server
}, this /* the scope the function should get called with */);

But usually you shouldn't need to call this method by hand because your store should take care of the communication with the server....

regards Martin

brownmonk
10 Feb 2012, 9:44 AM
Thanks, this ended up working. Do you happen to know how to get ahold of the request tid so I can link it up to the response tid?


handleSaveResources: function (button) {
var store = Ext.data.StoreManager.lookup('Resources');
var updatedRecords = store.getUpdatedRecords();
var updatedRecordsData = new Array();


for (var i = 0; i < updatedRecords.length; i++) {
updatedRecordsData[i] = updatedRecords[i].data;
}

ResourcePresenter.SaveResources({
records: updatedRecordsData


}, function (data, metaData) {
console.log(arguments);
}, this /* the scope the function should get called with */);
}

crp_spaeth
12 Feb 2012, 1:01 PM
I don't get it.
If you bypass the Store that way you end up with only one Transaction. The one used to call the Direct Function.

What do you actually want to do here? And what ended up working?

regards Martin