Hi; thanks for your posts.  I've got it working (though haven't
properly explored the options available to me, yet).  What I did:
* Made my web-app Global implement IMonoRailConfigurationEvents and
implemented Gauthier's code snippet:
                        configuration.JSGeneratorConfiguration
                                .AddLibrary("jquery-1.2.6", typeof 
(JQueryGenerator))
                                .AddExtension(typeof (CommonJSExtension))
                                .BrowserValidatorIs(typeof(JQueryValidator))
                                .SetAsDefault();
* Added a folder to my content directory called "js", and added jquery
and jquery.validate to this.  I haven't used minified files yet; I am
using Spark macros from 
http://whereslou.com/2008/10/02/very-cool-use-of-macro-and-_globalspark
to register which scripts are output.  I am intending to extend this
later to create (or perhaps extend JavaScriptComponent, which I wasn't
able to make work) a component that allows me to register scripts into
a set in order, and then write them out either verbatim or minified
+gzipped, as hammett talks about in a post (http://
hammett.castleproject.org/?p=310).  Closer to production, though,
probably.
* Set up validation attributes on my DTOs
* Added a typeof(myDTO) to the PropertyBag (haven't tried to see
whether I can get away with Flash).  It would be rather nice if I
didn't have to do that, but could instead either have Castle figure it
out by itself, or create a type variable in my view?
* Created my forms with the FormHelper's FormTag
* Ended my forms with the FormHelper's EndFormTag

It works very nicely :-)

I have one question, however.  I have an authentication-status shared
partial view that lives in my layout, and contains a form that posts
to my home-controller.  However, it's possible that this sign-in form
could be rendered on a controller other than home.  So how best to
furnish it with a typeof(UserAuthenticationDto) so that validation can
happen for it - in a Filter?  That gets me to thinking it might be a
fun thing to introduce a TypesNeededForValidationFigurerOuterFilter
( ;-)  ) that will look at the action being performed, and figure out
whether it needs to put a DTO-type into the PropertyBag, and which
type it needs to be - I suppose this might be facilitated by an
Attribute on the action that takes a type as argument....?  How does
that sound?

Regards
Pete

On Oct 1, 7:54 pm, Gauthier Segay <[EMAIL PROTECTED]> wrote:
> * Are the javascripts embedded into the Castle DLLs, or are they meant
> to be provided by me in my content/js directory (and if the latter,
> what is the convention for directory layout?)?
>
> Not for jQuery AFAIK
>
> * How do I provoke MonoRail into spitting out a jQuery script include
> inside of the head of the rendered page?
>
> There is some InstallScripts methods in Form and Ajax helpers, but
> seems legacy code that work with prototype only.
>
> Better do that explicitely
>
> * My first objective is to get up and running with jQuery-provided
> client-side validation
>
> here is the steps I've followed to make this work with jQuery:
> - implement IMonoRailConfigurationEvents and register jquery
> validation helper see below
> - Setup your validation attributes on your "dto"
> - Put an empty dto in your property bag
> - build the form with the helper:
>  * FormTag (you may pass jquery validate 
> options:http://docs.jquery.com/Plugins/Validation/validate#options)
>  * Push("propertybag_dto_instance_itemname")
>  * build the form with the helper
>  * Pop
>  * EndFormTag
>
> the client side validation will be generated on the FormHelper.EndForm
>
> Validator configuration
>
> configuration
>         .JSGeneratorConfiguration
>         .AddLibrary("jquery",
> typeof(JQueryValidator.JQueryValidationGenerator))
>         .BrowserValidatorIs(typeof(JQueryValidator))
>         .SetAsDefault();
>
> Tell us if it works for you.
>
> On Oct 1, 12:58 pm, petemounce <[EMAIL PROTECTED]> wrote:
>
> > Hi all
>
> > I'm running on Castle's trunk, and am at the stage where I have some
> > functional controllers, views (using Spark), server-side validation
> > going on.  I'd now like to hook in client-side validation but using
> > jQuery + jQuery's validate plugin, not Prototype/fValidate.  I've had
> > a look around, here, on the dev list, and the internet in general
> > (including hammet's blog where he talks about how this works in donjon
> > a little), but not found a resource that resembles a howto for it
> > this; I realise it's only on the current trunk.  I also haven't
> > gleaned much from reading the test-cases around jQuery that exist in
> > the test projects.
>
> > I've seen a post talking about implementing IMonoRailConfiguration on
> > my HttpApplication then adding code like:
> >                         
> > configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.2.6",
> > typeof (JQueryGenerator))
> >                                 .AddExtension(typeof (CommonJSExtension))
> >                                 .ElementGenerator
> >                                 .AddExtension(typeof 
> > (JQueryElementGenerator))
> >                                 .Done
> >                                 .BrowserValidatorIs(typeof 
> > (JQueryValidator))
> >                                 .SetAsDefault();
> > but to be honest, I don't know what I should expect after that - for
> > example, my Form.InstallScripts() method call in my layout seems to
> > still output prototype's validation script (or, well, one that uses
> > Prototype); Ajax.InstallScripts() outputs prototype.
>
> > So I've got a bunch of questions re: Javascript in MonoRail in
> > general:
> > * Are the javascripts embedded into the Castle DLLs, or are they meant
> > to be provided by me in my content/js directory (and if the latter,
> > what is the convention for directory layout?)?
> > * How do I provoke MonoRail into spitting out a jQuery script include
> > inside of the head of the rendered page?
> > * Can I register other script includes, conditionally - I guess I 
> > wanthttp://using.castleproject.org/display/Contrib/JavascriptComponent?
> > * If I use JavascriptComponent, how do I leverage Ajax/Form/etc helper
> > to generate JS for me rather than write it manually?
>
> > My first objective is to get up and running with jQuery-provided
> > client-side validation, but after that I'll be looking at more general
> > Javascript usage...  Thanks in advance!
>
> > Regards
> > Pete
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to