|
View:
New views
13 Messages
—
Rating Filter:
Alert me
|
|
|
AjaxActionHi,
Starting from Hammett's post http://hammett.castleproject.org/?p=55 and thanking Fabio, do you think we could extend this to generate also Ajax.Updater functions. For example have something like: [AjaxAction()] public void ShowTime(int anId) { RenderText(DateTime.Now.ToLongTimeString()); } which generates: <script type="text/javascript">var myproxy = { showTime: function(anId, callback) { var r=new Ajax.Request('/DNNAjax/account/ShowTime.aspx', {parameters: '_=\x26anId='+anId+'', asynchronous: !!callback, onComplete: callback}); if(!callback) return r.transport.responseText;} } </script> could we have something like: [AjaxAction(Update="maindiv")] public void ShowTime(int anId) { RenderText(DateTime.Now.ToLongTimeString()); } which generates: <script type="text/javascript">var myproxy = { showTime: function(anId) { var r=new Ajax.Updater('maindiv','/DNNAjax/account/ShowTime.aspx', {parameters:'_=\x26anId='+anId+'',asynchronous: true, onComplete: callback}); } </script> Is there something like that possible already, not to try an implementation that already exists? Thanks, Dan -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionI think he has added this idea to jira, but so far nothing has been
implemented regarding this support. Go for it. On 11/28/06, Dan Bunea <dan.bunea@...> wrote: > Hi, > > Starting from Hammett's post http://hammett.castleproject.org/?p=55 and > thanking Fabio, do you think we could extend this to generate also > Ajax.Updater functions. For example have something like: -- Cheers, hammett http://hammett.castleproject.org/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxAction> [AjaxAction(Update="maindiv")]
> public void ShowTime(int anId) > { > RenderText(DateTime.Now.ToLongTimeString()); > } This is very similar to the RJS discussion we had a month or so ago - the only problem with this suggestion is that as soon as you want to update a div - you want to be able to specify a "transisiton" (effect) - and then things get hard - which is why RJS is such a cool idea. If the "basic" version works for you - then go for it! ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionI was thinking on something that can be specified as a parameter to
the generated function. I don't think it's a good idea to tie the presentation to the controller that way. We could extend the generated proxy to accept an "options" object, just like Prototype and scriptaculous. -- Fábio David Batista fabio.david.batista@... http://nerd-o-matic.blogspot.com On 11/28/06, josh robb <josh_robb@...> wrote: > > [AjaxAction(Update="maindiv")] > > public void ShowTime(int anId) > > { > > RenderText(DateTime.Now.ToLongTimeString()); > > } > > This is very similar to the RJS discussion we had a month or so ago - > the only problem with this suggestion is that as soon as you want to > update a div - you want to be able to specify a "transisiton" (effect) > - and then things get hard - which is why RJS is such a cool idea. > > If the "basic" version works for you - then go for it! > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > CastleProject-users mailing list > CastleProject-users@... > https://lists.sourceforge.net/lists/listinfo/castleproject-users > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxAction> I was thinking on something that can be specified as a parameter to
> the generated function. I don't think it's a good idea to tie the > presentation to the controller that way. Thanks for clarifying my bad vibe Fabio. Thats exactly the problem. > We could extend the generated proxy to accept an "options" object, > just like Prototype and scriptaculous. Yep - except I think you'll need more flexibility than a hash - more like the full power of JS - which is why RJS rocks so hard. (That and it's a template language). j. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionYes, looking trough the code, I think it could be much better to have the name of the div for the updater in the generated function rather then in the controller.
Also, it could be great if the methods (and fields) would be virtual and protected (where applyable) in AjaxHelper class, so in order to extend we shouldn't need to recompile the project.
Thanks,
Dan
On 11/28/06, josh robb <josh_robb@...> wrote:
> I was thinking on something that can be specified as a parameter to -- Dan Bunea http://danbunea.blogspot.com ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionPatch?
On 11/28/06, Dan Bunea <dan.bunea@...> wrote: > Also, it could be great if the methods (and fields) would be virtual and > protected (where applyable) in AjaxHelper class, so in order to extend we > shouldn't need to recompile the project. -- Cheers, hammett http://hammett.castleproject.org/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionSo, this is what I did (from TestNVelocity):
public void JsProxies() { } [AjaxAction] public void InvocableMethod1() { RenderText("Success"); } [AjaxAction("friendlyName")] public void InvocableMethod2(String value) { RenderText("Success " + value); } and in view: $AjaxHelper.GetJavascriptFunctions() $AjaxHelper.GenerateJSProxy("myproxy") <input type="button" id="invocableMethodButton" value="invocableMethod1" onclick="javascript:$('result').innerHTML = myproxy.invocableMethod1(null);" /> <input type="button" id="anotherMethodButton" value="friendlyName" onclick="javascript:$('result').innerHTML = myproxy.friendlyName('something');" /> <input type="button" id="Button1" value="invocableMethod1,u" onclick="javascript:myproxy.invocableMethod1('result');" > <input type="button" id="Button2" value="friendlyName,u" onclick="javascript:myproxy.friendlyName('something','result');" /> <div id="result"> </div> results in: <script type="text/javascript">var myproxy = { invocableMethod1: function(update,callback) { if(!update) { var r=new Ajax.Request('/TestNVelocity/ajax/InvocableMethod1.aspx', {parameters: '_=', asynchronous: !!callback, onComplete: callback}); if(!callback) return r.transport.responseText; } else { var r=new Ajax.Updater(update,'/TestNVelocity/ajax/InvocableMethod1.aspx', {parameters: '_=', asynchronous: !!callback, onComplete: callback}); } } , friendlyName: function(value, update,callback) { if(!update) { var r=new Ajax.Request('/TestNVelocity/ajax/InvocableMethod2.aspx', {parameters: '_=\x26value='+value+'', asynchronous: !!callback, onComplete: callback}); if(!callback) return r.transport.responseText; } else { var r=new Ajax.Updater(update,'/TestNVelocity/ajax/InvocableMethod2.aspx', {parameters: '_=\x26value='+value+'', asynchronous: !!callback, onComplete: callback}); } } } </script> </head> <body> <input type="button" id="invocableMethodButton" value="invocableMethod1" onclick="javascript:$('result').innerHTML = myproxy.invocableMethod1(null);" /> <input type="button" id="anotherMethodButton" value="friendlyName" onclick="javascript:$('result').innerHTML = myproxy.friendlyName('result','something');" /> <input type="button" id="Button1" value="invocableMethod1,u" onclick="javascript:myproxy.invocableMethod1('result');" /> <input type="button" id="Button2" value="friendlyName,u" onclick="javascript:myproxy.friendlyName('something','result');" /> <div id="result"> </div> and it works. The only code modified is in Ajaxhelper: /// <summary> /// Generates an AJAX JavaScript proxy for a given controller. /// </summary> /// <param name="proxyName">Name of the javascript proxy object</param> /// <param name="controller">Controller which will be target of the proxy</param> /// <param name="area">area which the controller belongs to</param> public String GenerateJSProxy(string proxyName, string area, string controller) { String cacheKey = (area + "|" + controller).ToLower(); String result = (String) ajaxProxyCache[cacheKey]; if (result == null) { Controller controllerInstance = controllerFactory.CreateController(new UrlInfo("/", area, controller, "", "")); if (controllerInstance == null) { throw new RailsException("Controller not found with Area: '{0}', Name: '{1}'", area, controller); } String baseUrl = Controller.Context.ApplicationPath + "/"; if (area != null && area != String.Empty) { baseUrl += area + "/"; } baseUrl += controller + "/"; // TODO: develop a smarter function generation, inspecting the return // value of the action and generating a proxy that does the same. // also, think on a proxy pattern for the Ajax.Updater. StringBuilder functions = new StringBuilder(1024); functions.Append("{ " + Environment.NewLine); ControllerMetaDescriptor metaDescriptor = controllerDescriptorBuilder.BuildDescriptor(controllerInstance); bool commaNeeded = false; foreach(MethodInfo ajaxActionMethod in metaDescriptor.AjaxActions) { if (!commaNeeded) commaNeeded = true; else functions.Append(','); String methodName = ajaxActionMethod.Name; object[] attributes = ajaxActionMethod.GetCustomAttributes(typeof(AjaxActionAttribute), true); AjaxActionAttribute ajaxActionAtt = (AjaxActionAttribute) attributes[0]; StringBuilder parameters = new StringBuilder("_="); String url = baseUrl + methodName + "." + Controller.Context.UrlInfo.Extension; String functionName = ajaxActionAtt.Name != null ? ajaxActionAtt.Name : methodName; functionName = Char.ToLower(functionName[0]) + (functionName.Length > 0 ? functionName.Substring(1) : null); functions.AppendFormat(Environment.NewLine + "\t{0}: " + Environment.NewLine + "\tfunction(", functionName); //parameters foreach(ParameterInfo pi in ajaxActionMethod.GetParameters()) { String paramName = pi.Name; paramName = Char.ToLower(paramName[0]) + (paramName.Length > 0 ? paramName.Substring(1) : null); functions.AppendFormat("{0}, ", paramName); parameters.AppendFormat("\\x26{0}='+{0}+'", paramName); } functions.Append("update,callback)").Append(Environment.NewLine).Append("\t{"); functions.Append(Environment.NewLine).Append("\t\tif(!update)").Append(Environment.NewLine); functions.Append("\t\t{").Append(Environment.NewLine); functions.Append(Environment.NewLine).AppendFormat("\t\t\tvar r=new Ajax.Request('{0}', " + "{{parameters: '{1}', asynchronous: !!callback, onComplete: callback}}); " + Environment.NewLine + "\t\t\tif(!callback) return r.transport.responseText;", url, parameters.ToString()).Append(Environment.NewLine); functions.Append("\t\t}").Append(Environment.NewLine); //else //it uses Ajax.Updater functions.Append("\t\telse").Append(Environment.NewLine).Append("\t\t{"); ; functions.Append(Environment.NewLine).AppendFormat("\t\t\tvar r=new Ajax.Updater(update,'{0}', " + "{{parameters: '{1}', asynchronous: !!callback, onComplete: callback}}); ", url, parameters.ToString()).Append(Environment.NewLine); functions.Append("\t\t}").Append(Environment.NewLine); functions.Append("}").Append(Environment.NewLine); } functions.Length -= 1; functions.Append("}").Append(Environment.NewLine); ajaxProxyCache[cacheKey] = result = functions.ToString(); } That's it. I am not very good at patching, so if someone can help me make the patch, that would be great. Thanks, Dan On Tue, 28 Nov 2006 22:16:16 +0200, hammett <hammett@...> wrote: > Patch? > > On 11/28/06, Dan Bunea <dan.bunea@...> wrote: >> Also, it could be great if the methods (and fields) would be virtual and >> protected (where applyable) in AjaxHelper class, so in order to extend >> we >> shouldn't need to recompile the project. > -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionSee http://www.castleproject.org/community/patch.html
On 11/29/06, Dan Bunea <dan.bunea@...> wrote: > That's it. I am not very good at patching, so if someone can help me make > the patch, that would be great. -- Cheers, hammett http://hammett.castleproject.org/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionOk - here's a cleaned up version of Dan's patch. (Dan - you need to
use tabs - not spaces). The patch adds an optional parameter to the javascript functions allowing you to use Ajax.Updater (to update an element with the results of the call automatically) rather than Ajax.Request. Dan - did you want to make the various methods/fields virtual protected? j. On 11/29/06, hammett <hammett@...> wrote: > See http://www.castleproject.org/community/patch.html > > On 11/29/06, Dan Bunea <dan.bunea@...> wrote: > > That's it. I am not very good at patching, so if someone can help me make > > the patch, that would be great. > > -- > Cheers, > hammett > http://hammett.castleproject.org/ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > CastleProject-users mailing list > CastleProject-users@... > https://lists.sourceforge.net/lists/listinfo/castleproject-users > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionHi Josh,
Thanks for your help with the patch and with the explanation (sorry about the spaces:) ). I think especially in helpers, methods and fields should be virtual/protected so users can extend them easily. This would allow experiments for ideas to be made very fast, and then the ideas could come back into the core of Castle, from the community. Cheers, Dan On Wed, 29 Nov 2006 14:55:15 +0200, josh robb <josh_robb@...> wrote: > Ok - here's a cleaned up version of Dan's patch. (Dan - you need to > use tabs - not spaces). > > The patch adds an optional parameter to the javascript functions > allowing you to use Ajax.Updater (to update an element with the > results of the call automatically) rather than Ajax.Request. > > Dan - did you want to make the various methods/fields virtual protected? > > j. > > On 11/29/06, hammett <hammett@...> wrote: >> See http://www.castleproject.org/community/patch.html >> >> On 11/29/06, Dan Bunea <dan.bunea@...> wrote: >> > That's it. I am not very good at patching, so if someone can help me >> make >> > the patch, that would be great. >> >> -- >> Cheers, >> hammett >> http://hammett.castleproject.org/ >> >> ------------------------------------------------------------------------- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to share >> your >> opinions on IT & business topics through brief surveys - and earn cash >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >> _______________________________________________ >> CastleProject-users mailing list >> CastleProject-users@... >> https://lists.sourceforge.net/lists/listinfo/castleproject-users >> -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionOn 11/29/06, josh robb <josh_robb@...> wrote:
> The patch adds an optional parameter to the javascript functions > allowing you to use Ajax.Updater (to update an element with the > results of the call automatically) rather than Ajax.Request. Please, attach patches to the original issue: http://support.castleproject.org/browse/MR-144 . But I still haven't liked the proposed solution. I'll look for a better solution during this weekend: I don't want to call asyncrhonous, non-updating actions this way: proxy.someAction(param1, param2, null, function(t) { ... }); I was thinking on something like: // calls Ajax.Updater proxy.someAction(param1, param2, { update: $('div'), async: false, onComplete: ... }); // calls Ajax.Request proxy.someAction(param1, param2, function(t) { ... }); // asyncronous val = proxy.someAction(param1, param2); // synchronous -- Fábio David Batista fabio.david.batista@... http://nerd-o-matic.blogspot.com ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
|
|
Re: AjaxActionHi Fabio,
Your solution seems better: proxy.someAction(param1, param2, { update: $('div'), async: false, onComplete: ... }); Especially since in very many occasions I had to add onError, on... so it should be extendable. Thanks, Dan On Thu, 30 Nov 2006 03:16:24 +0200, Fábio Batista <fabio.david.batista@...> wrote: > On 11/29/06, josh robb <josh_robb@...> wrote: >> The patch adds an optional parameter to the javascript functions >> allowing you to use Ajax.Updater (to update an element with the >> results of the call automatically) rather than Ajax.Request. > > Please, attach patches to the original issue: > http://support.castleproject.org/browse/MR-144 . > > But I still haven't liked the proposed solution. I'll look for a > better solution during this weekend: I don't want to call > asyncrhonous, non-updating actions this way: > > proxy.someAction(param1, param2, null, function(t) { ... }); > > I was thinking on something like: > > // calls Ajax.Updater > proxy.someAction(param1, param2, { update: $('div'), async: false, > onComplete: ... }); > > // calls Ajax.Request > proxy.someAction(param1, param2, function(t) { ... }); // asyncronous > val = proxy.someAction(param1, param2); // synchronous > -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ CastleProject-users mailing list CastleProject-users@... https://lists.sourceforge.net/lists/listinfo/castleproject-users |
| Free Forum Powered by Nabble | Forum Help |