пятница, января 11
I am building a real world web app with Castle Project right now. So, the debugging is done for IE. And I encountered two different things of interest:
1. Javascript-based form validation as it's implemented for Castle Project does not work in Opera. Even more, pressing submit button in Opera causes a big stack trace of errors. Correct me, if I'm wrong, that's because IE's lack of standarts. I really
dont know what's the problem is, because I'm not a tough javascript programmer.
2. IE automagically handles OPTION tag insertions into select lists. I have complex form, with a lot of selects, most of them have other selects as parents. E.g. City has District and Street as children. So I want to populate District and Street using ajax call invoked using onchange event hook of City select. I have two invocations for each one of the two. I pass District Select Id to the Ajax.Request object. And what I wanted to do was to simply get a lot of lines like
by parsing my NVelocity template. And actually the code did return right list of options. But when it tried to insert them into District Select (with javascript using innerHTML property, I think. read about Prototype js library here) in IE 6 that resulted in messed tags (i use IE Developer Toolbar to see changes):
In Opera however, that didn't happen and it worked just as it was expected to. So after 2 hours of trying to understand what's going on, I found explanation to this. The thing is, MS does not allow option tag insertions without corresponding select tags. So, be concerned about this.
1. Javascript-based form validation as it's implemented for Castle Project does not work in Opera. Even more, pressing submit button in Opera causes a big stack trace of errors. Correct me, if I'm wrong, that's because IE's lack of standarts. I really
dont know what's the problem is, because I'm not a tough javascript programmer.
2. IE automagically handles OPTION tag insertions into select lists. I have complex form, with a lot of selects, most of them have other selects as parents. E.g. City has District and Street as children. So I want to populate District and Street using ajax call invoked using onchange event hook of City select. I have two invocations for each one of the two. I pass District Select Id to the Ajax.Request object. And what I wanted to do was to simply get a lot of lines like
...
< value="district_id">district_name
...
by parsing my NVelocity template. And actually the code did return right list of options. But when it tried to insert them into District Select (with javascript using innerHTML property, I think. read about Prototype js library here) in IE 6 that resulted in messed tags (i use IE Developer Toolbar to see changes):
...
district_name<>< /option>< /option>< //option>
...
In Opera however, that didn't happen and it worked just as it was expected to. So after 2 hours of trying to understand what's going on, I found explanation to this. The thing is, MS does not allow option tag insertions without corresponding select tags. So, be concerned about this.
понедельник, января 7
Creating URL's in Mono Rail
They got a very simple URLHelper for Castle Project, it is used like:
And it DOES NOT take additional parameters, like some "id" or sth in a form, that would not make you specify all special symbols, '=', '?' and '&' .. I should mention lack of up-to-date documentation. After googling for some time I realized, it would be better to write my own one. (I hope, I did not reinvent the will) I called it MyUrlHelper, extending it from AbstractHelper. To use it with NVelocity, supply it with action (yes, it does not takes controller as a parameter now) and a dictionary as the second parameter:
and it will output a correctly formed URL. Place it in "Helpers" directory under your VS project and name it MyUrlHelper (by default). Then in corresponding controller, the one that passes data to your views, write something like this:
and it's gonna work. Be sure, you explicilty mention MyUrlHelper in HelperAttribute attached to the controller, otherwise it won't work!
It can be used without any restrictions, download it from depositfiles.com
UPD: Well, it seems, I reinvented the will ;) I had I version of MonoRail v 1 RC3, that had non-virtual methods of UrlHelper, but accordingly to this forum thread http://forum.castleproject.org/viewtopic.php?p=11283 they made them virtual on about Dec 27, 2007.
$UrlHelper.For("%{action='YourAction'}")
And it DOES NOT take additional parameters, like some "id" or sth in a form, that would not make you specify all special symbols, '=', '?' and '&' .. I should mention lack of up-to-date documentation. After googling for some time I realized, it would be better to write my own one. (I hope, I did not reinvent the will) I called it MyUrlHelper, extending it from AbstractHelper. To use it with NVelocity, supply it with action (yes, it does not takes controller as a parameter now) and a dictionary as the second parameter:
$MyUrlHelper.For("YourAction", "%{id=$item.id}")
and it will output a correctly formed URL. Place it in "Helpers" directory under your VS project and name it MyUrlHelper (by default). Then in corresponding controller, the one that passes data to your views, write something like this:
[Helper(typeof(YourProjectNamespace.Helpers.MyUrlHelper))]
public class YourController : BaseController
{
}
and it's gonna work. Be sure, you explicilty mention MyUrlHelper in HelperAttribute attached to the controller, otherwise it won't work!
It can be used without any restrictions, download it from depositfiles.com
UPD: Well, it seems, I reinvented the will ;) I had I version of MonoRail v 1 RC3, that had non-virtual methods of UrlHelper, but accordingly to this forum thread http://forum.castleproject.org/viewtopic.php?p=11283 they made them virtual on about Dec 27, 2007.
Подписаться на:
Сообщения (Atom)