PDA

View Full Version : [CLOSED] Extending DirectMethod for cross-posting



michaeld
Feb 06, 2014, 12:02 PM
So, first thing I'd like to do is extend DirectMethods with different default parameters for shorthand. To do that, DirectMethod must not be internal.

The second thing may be an issue or a request. The issue is that when I make a DirectMethod public via IDMode = DirectMethodProxyIDMode.None, I expect the Control that the DirectMethod originates not to matter as long as it finds it in the global list. The problem is I'm cross-posting between pages now and I originate in a DirectMethod that appears in a UserControl, but on post to the next page, it's in the Page Level. The RaisePostBack eventArgument is cp_ctl05|public|EventPageRefresh but it need to be -|public|EventPageRefresh to find it.

So either I need a way to override the ControlID in the DirectMethod, or I need the RaisePostBackEvent for requestType==public to disregard the controlid it originated. I prefer the latter but either option would be fine.

Vladimir
Feb 06, 2014, 2:03 PM
Sorry, I am not sure how direct method proxy is generated for direct method on one page is related with direct method on another page
How do you call direct method using proxy method from different page?

In any way, you can direct method without any proxy (it is not desired way but it is possible, just see which proxy methods are generated by Ext.Net for your direct method)


Ext.net.DirectMethod.request("MethodName", {/*arguments here*/});

michaeld
Feb 07, 2014, 3:08 AM
What about my first request to make DirectMethod a public class so it can be extended?


Sorry, I am not sure how direct method proxy is generated for direct method on one page is related with direct method on another page
How do you call direct method using proxy method from different page?

My personal implementation is found in the javascript section here:
http://forums.ext.net/showthread.php?27618-Add-UserControls-in-DirectEvents-Methods-and-have-them-automatically-Reload-on-Post-back-through-messaging-in-Hidden-Fields/page2

But to break it down, it's simply done this way:


document.forms[0].action=url

I believe I saw somewhere where DirectEvents allow a different post url as well.


In any way, you can direct method without any proxy (it is not desired way but it is possible, just see which proxy methods are generated by Ext.Net for your direct method)


Ext.net.DirectMethod.request("MethodName", {/*arguments here*/});

I prefer to continue to use the proxy because eventually I'll need to be able to turn this code over to other developers who won't be as savvy about dealing with some of the subtleties, and it's easier to show by example if there's an attribute I can specify.

Is there any technical reason why another property (say MakeGlobal) for DirectMethod cannot be specified as bool to identify a global reference that when true will be substituted to DirectMethodBuilder instead of the controlid for constructing the proxy for the client? Say example, "-global". Then id is "-global" instead, RaisePostBackEvent will look up "-global" instead as the key instead of the clientid of the control?

Vladimir
Feb 07, 2014, 1:11 PM
DirectMethod proxy is designed to call own direct method handler on the server side, I am not sure why direct method is declared inside one control should generates proxy to call another direct method. It is very strange case (and not good, imho). I guess we will no add such functionality. If you need such strange behaviour then use 'Ext.net.DirectMethod.request' calling, you can prevent proxy generation for particular direct mewthod (ClientProxy property of DirectMethodAttribute) and create that proxy manually:


Ext.ns("App.direct");
Ext.apply(App.direct, {
LogCompanyInfo: function (name, count, config) {
return Ext.net.DirectMethod.request("LogCompanyInfo", {
params: {
name: name,
count: count
}
});
}
});




Is there any technical reason why another property (say MakeGlobal) for DirectMethod cannot be specified as bool to identify a global reference

Why do you declare direct method inside a control instead page in this case?

michaeld
Feb 11, 2014, 11:48 AM
DirectMethod proxy is designed to call own direct method handler on the server side, I am not sure why direct method is declared inside one control should generates proxy to call another direct method. It is very strange case (and not good, imho). I guess we will no add such functionality. If you need such strange behaviour then use 'Ext.net.DirectMethod.request' calling, you can prevent proxy generation for particular direct mewthod (ClientProxy property of DirectMethodAttribute) and create that proxy manually:


Ext.ns("App.direct");
Ext.apply(App.direct, {
LogCompanyInfo: function (name, count, config) {
return Ext.net.DirectMethod.request("LogCompanyInfo", {
params: {
name: name,
count: count
}
});
}
});


Why do you declare direct method inside a control instead page in this case?

Simply a scoping issue. I have a page that loads a user control based upon the currently selected view. The usercontrol has the scope of the container that needs to rerendered. Sometimes I replace it with the same DirectMethod in the different usercontrol (unrelated to cross-posting scenario). I'm pretty sure at one time, this used to work. I don't know if it's related to changes made in Ext.Net.Utilities.FindControls. When the DirectMethod Attribute was set to IDMode=DirectMethodProxyIDMode.None, it used to not matter which control the DirectMethod was apart. It would find the DirectMethod regardless of the UserControl or page it was in.

Vladimir
Feb 12, 2014, 12:28 PM
When the DirectMethod Attribute was set to IDMode=DirectMethodProxyIDMode.None, it used to not matter which control the DirectMethod was apart. It would find the DirectMethod regardless of the UserControl or page it was in.

That property affects on proxy name only (generate proxy method name without ClientID in the name). It doesn't affect on searching direct method in the server side. Proxy method is designed to call own method only, it should not call anything else. If you need to call another method then use 'Ext.net.DirectMethod.request'