cancel
Showing results for 
Search instead for 
Did you mean: 

Calendars

indsev
Champ in-the-making
Champ in-the-making
Hi!
I'd like to know if it's possible to change the way that dates in Alfresco are shown, I mean, is it possible to show a calendar? What classes do I have to change to make it possible?
It's really urgent.
Thank you very much!
13 REPLIES 13

dhalupa
Champ on-the-rise
Champ on-the-rise
Yes, it is possible.. Default alfresco DatePicker component is generated by org.alfresco.web.bean.generator.DatePickerGenerator and DateTimePickerGenerator depending on the type of property. You have two options, you wil either edit above two classes in order to instantiate your calendar component or you can write new Component Generator and register it under the same bean name as default component generators.

The second thing (or maybe it should be first) is to decide which calendar component to use for date input.
There are quite a few jsf open source component libraries which provide nice calendar components, I have tried Tomahawk and RichFaces and both of them perform nicely. Finally I have opted for RichFaces.

But there is a catch, both Tomahawk and RichFaces are using Prototype as javascript library which is not compatible with mootools used by alfresco, therefore to use these calendar components you have to turn mootools off. There are couple of threads about this topic on this forum, just search for mootools

kind regards,

Denis

indsev
Champ in-the-making
Champ in-the-making
Thank you very much for your answer!
I still have some doubts, how do I have to modify DatePickerGenerator to be able to show a Calendar? I mean, what methods do I have to change and how? If you could give me an example about this I would be really really grateful.
Thank you!

dhalupa
Champ on-the-rise
Champ on-the-rise
You have to change method generate(FacesContext context, String id). By default, this method instantiates UIInput component, sets DatePicker renderer, and performs some initialization. You will have to replace this code with instantiation and initialization of your custom date component.

indsev
Champ in-the-making
Champ in-the-making
Thanks again.
Could you please tell me where can I get the components to use the calendar? Richfaces seems a good option, but in fact I don't really know where to find it and how to use it.
Thank you Smiley Wink

dhalupa
Champ on-the-rise
Champ on-the-rise
google "richfaces" 😉

indsev
Champ in-the-making
Champ in-the-making
I've redefined the method "generate" as you said:

    public UIComponent generate(FacesContext context, String id)
    {
       
       HtmlCalendar component = new HtmlCalendar();
        component.setRendererType("org.richfaces.CalendarRenderer");
        FacesHelper.setupComponentId(context, component, id);
     
        component.getAttributes().put("startYear", Integer.valueOf(startYear));
        component.getAttributes().put("yearCount", Integer.valueOf(yearCount));
        component.getAttributes().put("initialiseIfNull", new Boolean(initialiseIfNull));
        component.getAttributes().put("style", "margin-right: 7px;");
  
       
        if(noneLabel != null)
        {
            component.getAttributes().put("noneLabel", noneLabel);
        }
        return component;
    }


Then, I've disabled mootools. However, calendars don't appear. Dates are still shown in the same way. What am I missing?

Thanks.

indsev
Champ in-the-making
Champ in-the-making
Hi again,
I've realised that in fact it was working, except in the advanced-search, and that's where I need it. Does anybody knows why?
Thank you.

dhalupa
Champ on-the-rise
Champ on-the-rise
Advanced search screen does not use ComponentGenerators to generate components but components are rather hardcoded within jsp. Check Web-Client/source/web/jsp/search/advanced-search.jsp

Kind regards,

Denis

indsev
Champ in-the-making
Champ in-the-making
Yes, the problem is that my Advanced-search works like that:
When you select a content type (or a folder type), its attributes are shown, so that you can search by them (I had to modify some classes to make it worked). So, they are dinamically loaded, not included in the jsp.
Is there any way to make them work?
Thank you again.