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

    Calendar activity styles

    User501417-Oracle
      Hi,

      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.

      http://docs.oracle.com/cd/E24382_01/web.1112/e16181/af_calendar.htm#CHDCBAIH
      http://docs.oracle.com/cd/E24382_01/web.1112/e16182/complex_components.htm#ADFFD22645

      My Calendar is VO bind like this:

      +<af:calendar value="#{bindings.ItasResourceCalEntriesUserCalVO3.calendarModel}"+
      id="c2"/>

      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.

      Thanks
      -Mina
        • 1. Re: Calendar activity styles
          User501417-Oracle
          Hi,

          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>();
          tags.add("ON_LEAVE");
          activityStyles.put(tags, styles);

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

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

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

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

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

          /* End of Construct Calendar Color */


          And the calendar codes in jspx is this:
          <af:calendar value="#{bindings.ItasResourceCalEntriesUserCalVO3.calendarModel}"
          id="c2"
          activityStyles="#{viewScope.itasHomeBean.activityStyles}"/>

          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?

          Thanks
          • 2. Re: Calendar activity styles
            User501417-Oracle
            resending... anyone please help and advise?

            Thanks
            -Mina
            • 3. Re: Calendar activity styles
              GavinWoods
              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 :)

              -Gavin
              • 4. Re: Calendar activity styles
                GavinWoods
                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:
                activityStyles.put(calendarTagStr,CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.ORANGE));


                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() {
                setCalColors();
                }


                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!

                -Gavin

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