PDA

View Full Version : Need way to RaisePostBack DirectMethod for multiple Controls



michaeld
Jan 08, 2014, 4:52 AM
The present RaisePostBack model only allows the calling of a single DirectMethod event. I have need to raise multiple DirectMethods in different UserControls. I'd like to be able to do something like, App.direct.multiple( [ Function1, Function2 ]); on the client, and have Function1 DirectMethod defined in one UserControl and Function2 DirectMethod defined in another UserControl. Internally, on the server-side, Function 1 would be invoked, then Function 2.

Alternatively, it would be also nice to be able to do something like: App.direct.all( Function ); on the client and have all Controls that contain the named Function invoke in their control load order. That is, each UserControl that contains the DirectMethod with the same Function Name would invoke. I especially like this model for the following reason...

This has to do with my new UserControl refresh model defined 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

The goal is to have each of the UserControl be able to handle their own container refreshes without having to do casting after FindControl to each UserControl's type, just to call it's public Method. For instance, right now my UserControl1 has to know about UserControl2 just to be able to refresh 2 separate containers in each one after a single DirectMethod call. If they instead both had a public DirectMethod with the same public function name (or attributes that define their multiple call relationship), they could manage themselves.

At present, this is more of a feature request, but for now I'm happy to have you offer a solution in between.

Ext.Net seems not to warn if I attempt to create the same named public DirectMethod in 2 different UserControls. However, only one gets invoked. If there is an easy way to overcome this limitation, let me know.

geoffrey.mcgill
Jan 08, 2014, 4:55 AM
How about configuring [DirectMethods] in each UserControl, then calling multiple DirectMethods from the client shouldn't be a problem?

michaeld
Jan 08, 2014, 5:15 AM
How about configuring [DirectMethods] in each UserControl, then calling multiple DirectMethods from the client shouldn't be a problem?

I think you're posing multiple round-trips which is far from ideal. I'm considering a generic server-side event subscription model in the meantime unless you have a better idea.

Daniil
Jan 08, 2014, 11:00 AM
At present, this is more of a feature request, but for now I'm happy to have you offer a solution in between.


Yes, we have no such the functionality built-in and you are the first one who has requested it:) I think it is very unlike we will implement it ever.

The best we can suggest is to call some DirectMethod, say DirectMethodCombined, which calls on server side all the logic that you need to be called.



Ext.Net seems not to warn if I attempt to create the same named public DirectMethod in 2 different UserControls. However, only one gets invoked. If there is an easy way to overcome this limitation, let me know.

It appears to be working here:
http://examples2.ext.net/#/Events/DirectMethods/UserControls/

Probably, in your scenario the DirectMethods are rendered with the same proxy name, and a DirectMethod from the second user control overrides the first one.

Do you use

[DirectMethod(IDMode=...)]
or
[DirectMethodProxyID(IDMode = ...)]
anywhere?

If you can provide a sample to reproduce, we can investigate.

michaeld
Jan 08, 2014, 11:22 AM
Yes, we have no such the functionality built-in and you are the first one who has requested it:) I think it is very unlike we will implement it ever.

I think you'll find a general use-case when you guys get to implementing: https://github.com/extnet/Ext.NET/issues/410
But as you guys aren't considering the hows as much as the whys yet, I didn't imagine you'd be fast to respond to this request; though, honestly, it seems pretty easy to implement but would require a client and server side implementation that allows the RaisePostBack eventarguments that are passed to support a new type that accepts a list instead of just the single 3-part split arguments.



The best we can suggest is to call some DirectMethod, say DirectMethodCombined, which calls on server side all the logic that you need to be called.
I don't entirely understand what you're posing, but I have already begun to create code to allow general wiring of events to subscribed controls based on type and name.

So yeah, the DirectMethod can call GlobalNamedEvents.Trigger("RefreshSomePanel") which will invoke each subscribing control EventHandler to that eventname that was registered/wired-up in the Page_Init for that UserControl.



Probably, in your scenario the DirectMethods are rendered with the same proxy name, and a DirectMethod from the second user control overrides the first one.


I used the following DirectMethod attribute (which if I understand correctly makes it public).


[DirectMethod( IDMode = DirectMethodProxyIDMode.None, ShowMask = true )]

And yeah, in that case there is no warning or exception. In your example, you aren't setting them to public so the named control will be part of the eventargument and will not override the previous instance. If not that, then it may be because I'm not attaching _dc. I have ResourceManager.CleanResourceUrl=true

Daniil
Jan 08, 2014, 11:48 AM
I will put it into Agenda of our next team meeting.



I used the following DirectMethod attribute (which if I understand correctly makes it public).


[DirectMethod( IDMode = DirectMethodProxyIDMode.None, ShowMask = true )]

And yeah, in that case there is no warning or exception. In your example, you aren't setting them to public so the named control will be part of the eventargument and will not override the previous instance. If not that, then it may be because I'm not attaching _dc. I have ResourceManager.CleanResourceUrl=true

Please start a new thread for that.

michaeld
Jan 08, 2014, 1:24 PM
http://forums.ext.net/showthread.php?27751-Same-named-Public-DirectMethods-in-multiple-UserControls-does-not-exception-or-warn&p=123452 (http://forums.ext.net/showthread.php?27751-Same-named-Public-DirectMethods-in-multiple-UserControls-does-not-exception-or-warn&p=123452#post123452)