4 Replies Latest reply: Nov 8, 2012 3:56 PM by GavinWoods RSS

    Calendar activity styles


      I am trying to set different colors for different activities on the calendar. I read the Developer's Guide and still not sure how to implement the ActivityStyles.


      My Calendar is VO bind like this:

      +<af:calendar value="#{bindings.ItasResourceCalEntriesUserCalVO3.calendarModel}"+

      I would like the color to based on the EntryTypeCode column in ItasResourceCalEntriesUserCalVO3.

      I understand that we need to create a Map to bind to ActivityStyles attributes of calendar. The map is a <key, ActivityCalendarRamp>. So in my case, the key is EntryTypeCode column. So how does I bind this key to the EntryTypeCode column in in ItasResourceCalEntriesUserCalVO3?

      Any guidance or sample codes are appreciated.

        • 1. Re: Calendar activity styles

          I tried setting the Map for Activity Styles in my bean as follows:

          /* Construct Calendar Color */
          activityStyles = new HashMap<Set<String>, InstanceStyles>(6);

          InstanceStyles styles = CalendarActivityRamp.getActivityRamp(Color.GREEN);
          Set <String> tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          styles = CalendarActivityRamp.getActivityRamp(Color.RED);
          tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          styles = CalendarActivityRamp.getActivityRamp(Color.YELLOW);
          tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          styles = CalendarActivityRamp.getActivityRamp(Color.ORANGE);
          tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          styles = CalendarActivityRamp.getActivityRamp(Color.BLUE);
          tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          styles = CalendarActivityRamp.getActivityRamp(Color.GRAY);
          tags = new CopyOnWriteArraySet<String>();
          activityStyles.put(tags, styles);

          /* End of Construct Calendar Color */

          And the calendar codes in jspx is this:
          <af:calendar value="#{bindings.ItasResourceCalEntriesUserCalVO3.calendarModel}"

          I updated the calendar binding's Provider Id and Tags to "EntryTypeCode".

          But it's still not working.

          Can anyone please help or provide some sample codes on how to change the activity style of VO-binded Calendar?

          • 2. Re: Calendar activity styles
            resending... anyone please help and advise?

            • 3. Re: Calendar activity styles
              Its like there's no clear and comprehensive documentation/tutorials out there for this. I'm working on implementing this for a project of my own, any chance you figured this out? If not, once I find a solution, i''ll let you know :)

              • 4. Re: Calendar activity styles
                Figured it out:

                Basically the Calendar's "Tags" object is used for coloring in my example. So if i have an activity with a tag name of "Star Trek", I can add code so everything with "Star Trek" will be colored blue (because "red" would be bad for Star Trek :) ).

                Below steps assume you've already create a calendar bean.

                Step 1: add to your Calendar Bean

                private HashMap activityStyles = new HashMap<Set<String>, InstanceStyles>();

                step 2: add a void method to your calendar bean to do coloring.

                HashSet calendarTagStr;
                calendarTagStr = new HashSet<String>();
                //Fill in your Tag name here
                calendarTagStr.add("Name of Your Tag");
                //Feeds Tag Name in first argument, second argument is the color (I used orange). Google the enum for more colors:

                step 3: update your Calendar Bean's constructor method to run your coloring method. For example... Only thing is i wouldnt leave it like this, i would add logic so that your void method only runs once.

                public CalendarBean() {

                Step 4: Under Calendar Properties: set ActivityStyles to #{NameOfYourCalendarBean.activityStyles}

                Step 5: In property insepctor, click the edit button. Set Tags to a field by which will serve as your tag. Save.

                Step 6: Test

                Hope this helps!


                Edited by: GavinWoods on Nov 8, 2012 4:55 PM