ADF Calendar step-by-step implementation

August 27th, 2010 | Posted by in Oracle ADF | 45 Comments

In what follows we shall provide an implementation for the af:calendar component.

ADFCalendar sample application – implemented using JDeveloper IDE version 11.1.1.3.0 – can be downloaded from here.

The application uses an extended version of the HR database(contains a new table called CALENDAR) which has been packed as a .sql script – AdfCalendarHRscript.sql – and stored within the ADFCalendar application.
The script alone can be downloaded from here.

Database

If you want to use the script to create the database follow the steps below:

1. Download AdfCalendarHRscript.sql

2. Drag & drop it into your JDevelopper IDE

3. Open a new SQL Worksheet

4. Copy the content of the script and paste it into the worksheet

5. Press F5 to run the script.

If you want to extend an existing database use the code below to create the CALENDAR table:

CREATE TABLE CALENDAR
(
  ID VARCHAR2(20 CHAR) NOT NULL
, PROVIDER VARCHAR2(100 CHAR) NOT NULL
, START_DATE DATE NOT NULL
, END_DATE DATE NOT NULL
, DESCRIPTION VARCHAR2(200 CHAR) NOT NULL
, CONSTRAINT CALENDAR_PK PRIMARY KEY
  (
    ID
  )
  ENABLE
)

You can also choose to extend an existing table. In this case you need to add 5 new attributes: 3 strings – for the Activity Id, Activity Provider and Activity Title and 2 dates – for the Start Time and End Time of the activity; the names are not important, only the data types are.

Next, create a new FMW application or use an existing one and follow the steps below:

Model implementation

Create a connection with the database and use it to create the CALENDAR Entity and View Object:

New -> Business Tier -> ADF Business Components -> Business Components from Tables -> CALENDAR – > Entity and Updatable VO

Open the Calendar entity and set the default value for StartDate attribute, as an expression, to adf.currentDateTime and for EndDate to adf.currentDate+1.

Also, the EndDate should allways be greater than the StartDate; this is done by adding a new validator for the EndDate attribute:

Open the Calendar VO and add 3 new bind variables as in the image below(only the data types are important):

View Controller implementation

Business

Create a new java class, name it Business– contains the calendar business. Each method implemented within this bean will be presented with respect to the visual component for which it provides service.

Now, open adfc-config.xml -> Overview -> Managed Beans and set Business bean scope to request as presented in the below image:

User Interface

Create a new .jspx web page, name it ”calendar” and follow the steps below:

Open Data Controls -> AppModuleDataControl and drag&drop the CalendarView as a Calendar onto the newly created .jspx page:

The Calendar option will be available only if the view object is configured correctly: contains the correct data types and the necessary bind variables; otherwise the Calendar option will not be provided.

Configure it:

After Finish is pressed you will notice that the calendar binding and an ExecuteWithParams operation have been added to the Bindings area of the .jspx page definition:

af:calendar is customized to show the list view by default, start day of the week will be Monday, start hour is 9 AM and the list view will present activities for the last 356 days:

<af:calendar value="#{bindings.CalendarView1.calendarModel}" id="c1"
                         partialTriggers="cb3 ctb1" availableViews="all"
                         view="list" startDayOfWeek="mon" startHour="9"
                         listCount="356"
                         calendarActivityListener="#{Business.activityListener}">

The activityListener method is used in order to syncronize the CalendarViewIterator with the af:calendar component. When an activity event occurs the CalendarViewIterator current row is updated to match the selected activity in the UI:

    public void activityListener(CalendarActivityEvent calendarActivityEvent) {
        CalendarActivity activity =
            calendarActivityEvent.getCalendarActivity();

        if (activity != null) {
            DCBindingContainer dcbindings =
                (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding iterator =
                dcbindings.findIteratorBinding("CalendarView1Iterator");
            Key key = new Key(new Object[] { activity.getId() });
            RowSetIterator rsi = iterator.getRowSetIterator();
            Row row = rsi.findByKey(key, 1)[0];
            rsi.setCurrentRow(row);
        }
    }

The calendar component that we have just added to the page contains a set of facets that can be customized to fulfill our needs.

Below, we have provided an implementation for each facet that the af:calendar component provides:

activityContextMenu facet – displays its child popup when right-click event is fired over an activity:

<f:facet name="activityContextMenu">
                <af:popup id="p1">
                  <af:menu text="menu 1" id="m2">
                    <af:commandMenuItem text="Update activity" id="cmi1">
                      <af:showPopupBehavior popupId="p3" triggerType="click"/>
                    </af:commandMenuItem>
                    <af:commandMenuItem text="Delete activity" id="cmi2">
                      <af:showPopupBehavior popupId="p4" triggerType="click"/>
                    </af:commandMenuItem>
                  </af:menu>
                </af:popup>
              </f:facet>

The above showPopupBehaviour operation registers a click listener with the commandMenuItem component for which is declared.  As a result, when the click event occurs on a commandMenuItem the popup pointed by the popupId attribute is displayed.

contextMenu facet – displays its child popup when right-click event is fired over an empty space within the calendar:

<f:facet name="contextMenu">
                <af:popup id="p2">
                  <af:menu text="menu 2" id="m3">
                    <af:commandMenuItem text="Create new activity" id="cmi3">
                      <af:showPopupBehavior popupId="p5" triggerType="click"/>
                    </af:commandMenuItem>
                  </af:menu>
                </af:popup>
              </f:facet>

activityDelete facet – for delete purposes:

<f:facet name="activityDelete">
                <af:popup id="p4">
                  <af:dialog closeIconVisible="false" modal="true"
                             id="pw_deleteAction" styleClass="allertBox"
                             type="none" title="Delete Activity">
                      ...
                    <f:facet name="buttonBar">
                      ...
                          <af:commandButton text="Yes"
                                            actionListener="#{Business.onDelete}"
                                            id="cb1"/>
                          <af:commandButton text="Cancel" id="cb2">
                            <af:resetActionListener/>
                          </af:commandButton>
                       ...
                    </f:facet>
                  </af:dialog>
                </af:popup>
              </f:facet>

When Yes commandButton is pressed the selected activity is deleted by calling onDelete method from Business bean:

    public void onDelete(ActionEvent actionEvent) {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
            bindings.getOperationBinding("Delete");
        operationBinding.execute();
        if (operationBinding.getErrors().isEmpty()) {
            operationBinding = bindings.getOperationBinding("Commit");
            operationBinding.execute();
        }
    }

activityDetail facet – displays its child popup when left-click event is fired over an activity:

<f:facet name="activityDetail">
                <af:popup id="p3" contentDelivery="lazyUncached"
                          binding="#{Business.updatePopup}">
                  <af:dialog closeIconVisible="false" modal="true"
                             id="pw_editAction" type="none" styleClass="cruBox"
                             title="Update Activity">
                    <f:facet name="buttonBar">
                      ...
                          <af:commandButton text="Save" id="cb3"
                                            partialSubmit="true"
                                            actionListener="#{Business.onSave}"/>
                          <af:commandButton text="Undo" partialSubmit="true"
                                            immediate="true"
                                            actionListener="#{Business.onUndo}"
                                            id="cb4">
                            <af:resetActionListener/>
                          </af:commandButton>
                          <af:commandButton text="Cancel" immediate="true"
                                            actionListener="#{Business.onCancel}"
                                            id="cb6" partialSubmit="true">
                            <af:resetActionListener/>
                          </af:commandButton>
                        ...
                    </f:facet>
                    <af:panelFormLayout id="pfl1">
                      ...
                    </af:panelFormLayout>
                  </af:dialog>
                </af:popup>
              </f:facet>

When Save commandButton is pressed onSave method is called:

    public void onSave(ActionEvent actionEvent) {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
            bindings.getOperationBinding("Commit");
        operationBinding.execute();
        if (operationBinding.getErrors().isEmpty()) {
            if (actionEvent.getComponent().getId().equals("cb3")) {
                hidePopup(getUpdatePopup());
            } else {
                hidePopup(getCreatePopup());
            }

        }
    }

When Undo commandButton is pressed onUndo method is called:

    public void onUndo(ActionEvent actionEvent) {
        DCBindingContainer dcbindings =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding iterator =
            dcbindings.findIteratorBinding("CalendarView1Iterator");
        Row currentRow = iterator.getCurrentRow();

        if (currentRow != null) {
            currentRow.refresh(Row.REFRESH_UNDO_CHANGES);
        }
    }

When Cancel commandButton is pressed onCancel method is called:

    public void onCancel(ActionEvent actionEvent) {
        DCBindingContainer dcbindings =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding iterator =
            dcbindings.findIteratorBinding("CalendarView1Iterator");
        Row currentRow = iterator.getCurrentRow();

        if (actionEvent.getComponent().getId().equals("cb6")) {
            if (currentRow != null) {
                currentRow.refresh(Row.REFRESH_UNDO_CHANGES);
            }
            hidePopup(getUpdatePopup());
        }

        else {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding =
                bindings.getOperationBinding("Delete");
            operationBinding.execute();

            hidePopup(getCreatePopup());
        }
    }

Cancel button has its immediate attribute set to “true” in order to avoid the validation process.

The partialSubmit attribute is set to “true” for all the above buttons because we use our hidePopup custom method to close the popup(otherwise the button press event would close the popup):

    public void hidePopup(RichPopup popup) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service =
            Service.getRenderKitService(facesContext,
                                        ExtendedRenderKitService.class);
        service.addScript(facesContext,
                          "AdfPage.PAGE.findComponent('" + popup.getClientId(facesContext) +
                          "').hide();");
    }


create facet – displays its child popup when left-click event is fired over an empty space within the calendar:

<f:facet name="create">
                <af:popup contentDelivery="lazyUncached" id="p5"
                          popupFetchListener="#{Business.onPopupFetch}"
                          binding="#{Business.createPopup}">
                  <af:dialog id="d2" type="none" title="Create Activity"
                             closeIconVisible="false">
                    <f:facet name="buttonBar">
                      ...
                          <af:commandToolbarButton text="Save" id="ctb1"
                                                   actionListener="#{Business.onSave}"/>
                          <af:commandToolbarButton text="Cancel" id="ctb2"
                                                   immediate="true"
                                                   actionListener="#{Business.onCancel}"/>
                      ...
                    </f:facet>
                    <af:panelFormLayout id="pfl3">
                      ...
                    </af:panelFormLayout>
                  </af:dialog>
                </af:popup>
              </f:facet>

The popupFetchListener attribute points to the onPoupFetch method, which is called when the popup open event occurs. CreateInsert operation is executed upon the CalendarViewIterator to host the new activity that is to be created(Create operation is not enough because the iterator doesn’t get updated with the newly created row):

    public void onPopupFetch(PopupFetchEvent popupFetchEvent) {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
            bindings.getOperationBinding("CreateInsert");
        operationBinding.execute();
    }

When Save and Cancel buttons are pressed the same methods are called as in the case of activityDetail facet(the context is resolved in the if statement).

The partialSubmit attribute is set to true by default in the case of commandToolbarButton component and this can be seen by using the Property Inspector(default values are not shown in the code).

activityHover facet – displays its child popup when mouse-over event is fired over an activity:

<f:facet name="activityHover">
                <af:popup id="p6" contentDelivery="lazyUncached">
                  <af:noteWindow id="nw1">
                    <af:panelFormLayout id="pfl2">
                      ...
                    </af:panelFormLayout>
                  </af:noteWindow>
                </af:popup>
              </f:facet>

The contentDelivery attribute value of the popup component must be set as presented above for each popup.

For a complete description of all the customizations that the af:calendar component supports and the business that comes embedded within the component check the link below:

http://download.oracle.com/docs/cd/E12839_01/web.1111/b31973/af_calendar.htm#CHDICFDG

Running the application

Open ADFCalendar OFM sample application in your JDevelopper IDE, navigate to calendar.jspx page and run it.

After the application has been successfully deployed the following page will be loaded into your browser:

We have customized af:calendar to display, by default, the list view (you can also choose day, week and month) and to show the activities for the last 365 days.

Mouse over an activity displays a window with more details about that activity:

Right-click over an activity displays a menu:

Left-click onto an activity opens the update activity panel:

Right-click over an empty space within the calendar displays the create new activity option:

Left-click onto an empty space opens the create new activity panel:

The delete activity panel is displayed when Delete activity menu item is pressed:

Tags: ,

45 Responses to “ADF Calendar step-by-step implementation”

  1. Hi Bogdan,

    Thanks much for your post on step-by-step implementation. It really helped.

    Though, can I request you to upload your Application here or send it to me on chintan.zatakia@gmail.com as I am running into some issues and need to refer to your application.

    Thanks in advance,
    Chintan Zatakia

    • Bogdan Petridean says:

      Hi Chintan,
      At the beginning of the post there is a link: “…can be downloaded from HERE.” from where you can download the sample application.

      Regards,
      bogdan.

  2. Malik Shah Jahan says:

    1. I ran the sample project posted by you, worked perfectly alright.
    2. I followed your steps in the tutorial above and created my own app. On any click inside the calendar, it throws java.lang.NullPointerException: Server Exception during PPR # 1. Server log is as follows:

    Server Exception during PPR, #1
    javax.el.ELException: java.lang.NullPointerException
    at com.sun.el.parser.AstValue.invoke(AstValue.java:161)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1303)
    at oracle.adf.view.rich.component.rich.RichPopup.broadcast(RichPopup.java:693)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:812)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:336)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.NullPointerException
    at calendar.Business.onPopupFetch(Business.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
    … 42 more

  3. Malik Shah Jahan says:

    Oh. Got it working now. Surely I was wrong somewhere.
    Actually, in the managed bean “Business”, I copied your code into mine. So the CalendarViewIterator mentioned thrice in your bean had to be CalendarVO1Iterator in mine as my AppDataControl name was CalendatVO1Iterator.
    By correcting the iterator name, there is no more PPR errors.
    Hats of to Gebs.

  4. Mark says:

    Hi,
    i read your article related to adf calendar implementation.
    I should use it in an application wich run on jdev 10.1.3.4. For a series or reason I cannot update to newest version.
    Do you think I could use your implementation in my jdev version? thanks a lot.

    • Bogdan Petridean says:

      Hi Mark,
      The adf calendar sample application has been implemented with JDev IDE 11.1.1.3.0 and I also tested it in JDev IDE 11.1.1.2.0, but I don’t know if it runs in JDev 10.x.x versions because I have not done any tests.
      To be sure, just download the sample application and try it in your JDev IDE.
      Regards,
      bogdan.

    • Mark says:

      my doubts are related to lack of component into my adf version. Do you know it it’s possibile decompile latest adf version, take oracle.adf.view.rich.component.UIXCalendar and re-compile it in my solution?
      I’m new to adf so I’m not sure if it could work…anyway I’ll try as soon eas possibile.

      thanks
      Mark

  5. Herman says:

    where is the methods code of: getBindings(), getUpdatePopup(), getCreatePopup()????

    • Herman says:

      Then, the Bean Type is BackingBean, not Request, Because BackingBean implementing getters and setters of components on the GUI (ADF Faces)

    • Bogdan Petridean says:

      Hi Herman,

      The backing bean scope is the scope with the shortest life span and it is a best practice to configure all managed beans used in reusable components to backingBean scope.
      Another best practice states that you should configure your managed bean to the scope with the shortest life span that meets your requirements.
      The backingBean scope has the life span shorter than the request scope, but in our case the Business bean doesn’t contain only getters and setters and request scope is the one that does the job.

      Thank you for your feedback,
      Bogdan.

  6. Herman says:

    Hi, I have this problem

    Server Exception during PPR, #1
    javax.el.ELException: java.lang.ArrayIndexOutOfBoundsException: 0

    • Bogdan Petridean says:

      Hi Herman,

      Did you downloaded and run the AdfCalendarSample application uploaded here or you have created your own app?

      If you created a new application than check if you have defined all the necessary bindings and iterators.
      Be aware that Business managed bean uses the names defined in the bindings.

      My advice is to first download, study and run the sample application and then create your own.

      Regards,
      Bogdan.

  7. Mike says:

    I am new to jdeveloper / ADF.
    I downloaded the below calender sample in my jdeveloper and it runs fine.
    http://www.oracle.com/technetwork/developer-tools/jdev/calendar-091799.html

    I want to pass a parameter like “location” from another page to this calendar application and show
    only details in the calendar for that location.

    I created another ADF page which listed the locations like
    LOCATION1
    LOCATION2
    LOCATION3

    These were links which called the earlier index.jspx page which has the calendar in the region for that location.
    I added another bind variable :param_loc to VO and made it work ok.

    I followed this http://blogs.oracle.com/shay/2009/11/passing_value_between_pages_to.html

    I was able to pass parameters between pages (the first LIST page to the calendar page).
    It pulls up the events correctly corresponding to that location.

    When I create a new event in the calendar it gets created ok.
    But when I click to edit an event it gives the below error
    java.lang.ArrayIndexOutOfBoundsException: 0
    Server Exception during PPR, #1
    javax.el.ELException: java.lang.ArrayIndexOutOfBoundsException: 0
    at com.sun.el.parser.AstValue.invoke(AstValue.java:161)
    ….

    Can you think of any reason why?

    Thanks for all your help.

    • Bogdan Petridean says:

      Hi Mike,

      The activityDetail calendar facet is the one that listens (by default) for the click event and here is where you should start looking.
      Also, check for missing bindings.
      If you cannot fix it you could send me a light version to try it myself.

      Sorry for the very long time it took me to answer (I was in vacation).

      Regards,
      bogdan.

  8. Ram says:

    Hi Herman,

    The bolg really helped us to get and idea and work on calendar component.

    In you calendar applciation can you please clarify the binding that is declared in th calendar.jspx page
    #{bindings.Calendar1.startDate}
    Is the above binding is refering the transient variables in the calendarView or is it refering the attribute of the calendarview.

    I am not able to find the above mentioned binding under bbindings.

    Can you please help me out in clarifying this?

    Thanks for all the help in advance.

    Thanks,
    Ram

    • Bogdan Petridean says:

      Hi Ram,

      Open calendar.jspx page -> Go to Bindings -> select calendar -> Press the Edit Pencil -> new window (Calendar View) will be displayed containing all the calendar attributes, including startDate.
      As I explained in the post startDate is one of the three user defined bind variables of CalendarView view object. Please refer to the post for more information.

      Thank you for your feedback and sorry for the long time it took me to answer (I was in vacation).

      Regards,
      bogdan.

  9. Ram says:

    Hi Bogdan,

    sorry i was actually refering to Mr.Borgan instead of Mr. Herman.

    Thanks,
    Ram

  10. Ahmed Fatthy says:

    Thanks a lot
    1. I ran the sample project posted by you, worked perfectly alright.
    2. I followed your steps in the tutorial above and created my own app. On any click inside the calendar, it throws java.lang.NullPointerException: Server Exception during PPR #

    I found the solution for this problem it is that i didnot add the fields on the page defintion . and now it works fine

  11. Eduardo says:

    Nice job!

    Everything works fine. Even my customizations became easy to do.

    May I ask you for a tip?

    The first time I’ve ran the project the activities that occurs at the same moment were side-by-side. Suddenly, in another execution, those activities were overlapped. Do you know how do I configure this behavior?

    Thanks a lot!

    • Bogdan Petridean says:

      Hi Eduardo,

      When using the Month or List calendar views the activities are listed per rows and when using the Day or Week views the activities are listed per columns – in which case they can overlap only if there isn’t enough space(this is the default behavior in my case).

      Regards,
      Bogdan.

  12. Ahmed says:

    what about Calendar drop target ?

  13. David L says:

    Hi Bodgan,
    I have the following behaviour with the calendar component, and when initially i thought that it was because of my own view object, I have been able to reproduce it with your schema and application, and it is bugging me out.
    The use case is simple: Two persons navigating at the same time, going week forward and back, at the same time, and youll receive the following exception:

    Server Exception during PPR, #2
    java.lang.NullPointerException
    at oracle.adfinternal.view.faces.renderkit.rich.AbstractCalendarRenderer._getDayViewActivitiesState(AbstractCalendarRenderer.java:2458)
    at oracle.adfinternal.view.faces.renderkit.rich.AbstractCalendarRenderer._renderDayViewNonAllDayActivitiesForDay(AbstractCalendarRenderer.java:1863)
    at oracle.adfinternal.view.faces.renderkit.rich.AbstractCalendarRenderer.renderNonAllDayActivitiesForViewDuration(AbstractCalendarRenderer.java:716)
    at oracle.adfinternal.view.faces.renderkit.rich.AbstractCalendarRenderer.renderNonAllDayActivityGridAndActivitiesForDuration(AbstractCalendarRenderer.java:615)
    at oracle.adfinternal.view.faces.renderkit.rich.CalendarWeekRenderer._renderWeekView(CalendarWeekRenderer.java:279)
    at oracle.adfinternal.view.faces.renderkit.rich.CalendarWeekRenderer.encodeAll(CalendarWeekRenderer.java:108)
    at oracle.adf.view.rich.render.RichRenderer.delegateRenderer(RichRenderer.java:1631)
    at oracle.adfinternal.view.faces.renderkit.rich.CalendarRenderer.encodeAll(CalendarRenderer.java:432)
    at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1369)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:765)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:415)
    at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2567)
    at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeCenterFacet(PanelStretchLayoutRenderer.java:297)
    at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer._encodeCenterPane(PanelStretchLayoutRenderer.java:574)
    at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeAll(PanelStretchLayoutRenderer.java:241)
    at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1369)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:765)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:415)
    at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2567)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:432)
    at oracle.adfinternal.view.faces.renderkit.rich.FormRenderer.encodeAll(FormRenderer.java:220)
    at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1369)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:765)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:415)
    at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2567)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:432)
    at oracle.adfinternal.view.faces.renderkit.rich.DocumentRenderer.encodeAll(DocumentRenderer.java:1071)
    at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1369)
    at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:765)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.__encodeRecursive(UIXComponentBase.java:1515)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeAll(UIXComponentBase.java:785)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
    at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:202)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)
    at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:710)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:273)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:205)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Any ideas why?

  14. Bogdan Petridean says:

    Hi David,

    I run the ADFCalendar sample, set the view on Week and start navigating ; in the same time from another pc a colleague of mine did the same thing and it all seem to work just fine (did not catch the above error).

    Regards,
    Bogdan.

  15. David L says:

    Hi Bogdan,

    the case is not easy to reproduce with few appointments in the week view, but if you have 40-50 appointments, it takes at least 2 seconds to load the view. It is in this case when you can reproduce the error.
    If you dont mind, set a week with 40-50 events, and the with two navigators, gor forward and backwards on that week at the same time. Then you will see the error.
    In a normal case of use of a calendar, you can easily have +50 events in a week, that si why we have found the error.
    If you could try this out, I would really appreciate it so you could see the error :D
    Tahnks, and thank you for responding so promptly.
    kind regards, David L

  16. Pete Town says:

    Bogdan,
    I would like to commend you on a great article! Really very good indeed. I wondered if you have looked into the “Recurring” functions of the calendar. I’ve implemented them on mine, however it only seems to give me a little image next to each activity flagging it is recurring. However it will not populate the rest of the calendar with the activity? Any view of how to achieve this for Public holidays etc?
    Best regards,
    Pete

  17. Radhika says:

    I dont get the toolbar on top with the views (monthly, weekly or daily)
    What could be the problem

  18. Oana says:

    Hi Bogdan,

    How can I change the colors of calendar tasks according some conditions (eq.a column of binding object). I’ve read that ActivityStyles should help but I don’t know how.

    Thank you,
    Oana.

    • Oana says:

      I’ve solved. I created a method in a managed bean like this:
      public Map<Set, InstanceStyles> getStyle()

      {
      System.out.println(“intra map”);

      BindingContainer bindings =
      BindingContext.getCurrent().getCurrentBindingsEntry();
      Map<Set, InstanceStyles> style =
      new HashMap<Set, InstanceStyles>();

      String tipTr_lcl = “”;

      AttributeBinding tipTranzactieBinding =
      (AttributeBinding)bindings.getControlBinding(“TipTranzactie”);
      if (tipTranzactieBinding.getInputValue() != null) {
      tipTr_lcl =
      tipTranzactieBinding.getInputValue().toString();

      System.out.println(“tip”+ tipTranzactie_lcl);
      if (tipTranzactie_lcl.equals(“D”)) {
      Set mySet = new HashSet();
      mySet.add(“D”);
      style.put(mySet,
      (InstanceStyles)CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.RED));
      } else {
      Set mySet = new HashSet();
      mySet.add(“C”);
      style.put(mySet,
      (InstanceStyles)CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.GREEN));

      }

      }
      return style;
      }

    • baxhuli says:

      Hello Oana,
      I came across this tutorial and I have the same problem as you had one year ago, I want to customize the colors of my Calendar. I am finding difficult how to implement your method in my application. Can you please provide me with some more details, maybe a sample code if it is possible would be awesome.
      Thank you anyway, at least you are the only till now that has published something concrete about calendar styling.

  19. Mahmoud Abdelhafez says:

    Hello David,
    Can I add directly your calendar to my application? if so, please help me

    Thanks

  20. Hal says:

    Hi,
    Can I customize the calendar to display the time in 24hr format? How do I go about doing that?

    Thanks in advance.

  21. Madhu says:

    Hi Bogdan,
    This is very useful article. Thanks for this.
    The activities are listing in my calendar perfectly. a. How can we navigate to another page when we click on aactivity? I used Mouse Hove and it is working fine. But I need to navigate t another page from this calendar.

    Thanks in Advance

  22. tarun says:

    Hi , thanks for the useful and wonderful article.
    Do you have any idea how can we supply resource bundle to the days and month labels that are shown in the calendar. I want to display them in dutch.

  23. Diego says:

    If I want to refresh the popup, once an activity has been made, how I could make that?, because it shows the information already introduced.

    Thanks, Diego

  24. Carlos says:

    Hi, very useful post. I need the Create New Activity window to display as a start date the current date on calendar. I mean, if I navigate to another day, and click for a new activity, the selected date should be used and not adf.currentDateTime. How can I accomplish this? Thanks in advance

  25. Aladin says:

    Hello
    Thanks a lot for this tutorial
    Actually this application run it but i got an error message saying that:
    “Attempt to set a parameter name that does not occur in SQL: Start Date”
    i think that there is a mistake with the binding parameter

    Thanks

  26. cp says:

    Hi,
    Thank you for wonderful and useful post. I want to create business calendar with holidays and weekends(grayed out)for 3 years( previous year, current year, and next year).
    No acitivities and data from database. Getting holidays from a file. How can I set the years in adf calendar and colors for non working days?

    Thanks

  27. wes says:

    very comprehensive adf calendar tutorial! thank you.

  28. Ahmed says:

    this tutorial is not working at jdev 12.1.3 version
    i tried it many times and i dont know why !

Leave a Reply