Re: Overriding stylesheet and images used by AjaxDatePicker
Re: Overriding stylesheet and images used by AjaxDatePicker
- Subject: Re: Overriding stylesheet and images used by AjaxDatePicker
- From: "Ricardo J. Parada" <email@hidden>
- Date: Tue, 09 Nov 2010 16:33:04 -0500
On Nov 9, 2010, at 1:52 PM, Chuck Hill wrote:
>
> On Nov 9, 2010, at 10:35 AM, Ricardo J. Parada wrote:
>
>> Hi,
>>
>> I thought I knew the answer to this one but maybe not quite. I'm using an AjaxDatePicker and I managed to override its stylesheet by defining this property in my MPVWebComponents framework:
>>
>> er.extensions.ERXResponseRewriter.resource.Ajax.calendar.css=MPVWebComponents.css/calendar.css
>
> Bindings?
> * @binding calendarCSS name of CSS resource with classed for calendar, defaults to "calendar.css"
> * @binding calendarCSSFramework name of framework (null for application) containing calendarCSS resource, defaults to "Ajax"
I wanted to override globally every where AjaxDatePicker is used. But since this is the first time we start using it, I decided to create MPVAjaxDatePicker which simply wraps AjaxDatePicker and always passes the right stuff in the calendarCSS and calendarCSSFramework.
And then I used similar code to what AjaxDatePicker uses to compute defaultImagesDir except that I use the images in my framework and pass the directory to AjaxDatePicker via the imagesDir binding.
And that seems to be working.
Thanks Chuck.
>> Then I tried these to override the prev/next icons used by the date picker:
>>
>> er.extensions.ERXResponseRewriter.resource.Ajax.calendar_next.png=MPVWebComponents.images/calendar_next.gif
>> er.extensions.ERXResponseRewriter.resource.Ajax.calendar_prev.png=MPVWebComponents.images/calendar_prev.gif
>>
>> The first one seems to work fine because it's using the our calendar.css. However, the icons for next/prev month/year are still using the ones from the Ajax framework. Can they be overriden?
>>
>> Is this the correct way to do this?
>
> public AjaxDatePicker(WOContext context) {
> super(context);
>
> // I am not expecting the images to get localized, so this can be set once
> // This is hacky, but I wanted to avoid changing the JS to take the path for each image in options
> // and WO does not expose this path any other way. Still half thinking I should have changed the JS...
> if (defaultImagesDir == null) {
> defaultImagesDir = application().resourceManager().urlForResourceNamed("calendar_prev.png", "Ajax", null, context().request()).toString();
> int lastSeperator = defaultImagesDir.lastIndexOf("/");
> if (lastSeperator == -1) {
> lastSeperator = defaultImagesDir.lastIndexOf('/');
> }
> defaultImagesDir = defaultImagesDir.substring(0, lastSeperator);
>
> // Need to pre-populate the cache for WOResourceManager
> application().resourceManager().urlForResourceNamed("calendar_next.png", "Ajax", null, context().request()).toString();
> }
> }
>
> Have fun!
>
> Chuck
>
>
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden