Integration with icefaces

Hello ,
We have an old project (icefaces1.8, spring 2.5). For CRUD operations we use JPA, not hibernate(we have made the JavaPlanner “jsp” demo working with JPA). But we have no luck at now to integrate planner in icefaces1.8 project. Our project is not a GPL project and of course we have to buy a license, but we want to be sure is there a possibility to make JavaPlanner work inside icefaces1.8 project. Can you provide some guidelines?

Hi,
actually we don’t have a demo for Icefaces, but here are common tips how to integrate JavaPlanner into project:

  1. locate codebase directory and make it available to load on web-page
  2. Execute JavaPlanner code which prepares html/css/javascript code to show calendar on page
  3. Provide ability to locate generated text on page (it may be direct writing for JSP-pages, using templates for frameworks)
  4. Provide ability to get events via Ajax: it must be just a link which is requested by calendar to load/save data.

By the way, we provide 30 day money back guarantee if you aren’t satisfied with JavaPlanner:
javaplanner.com/money.html

Hi radyno,
thanks a lot for your tips. 1) and 2) are clear and there were no problems to realize in icefaces.
I had some troubles with 3). In icefaces templates seems possible only with facelets. For some reasons i don’t want to use facelets. I have tried to implement our custom template tag for direct writing , but with no luck in icefaces . At last i have found a simple and working at first glance solution:
In my backing bean i have a string property called planner. Getter is

public String getPlanner() throws Exception{
    return getScheduler();
}  

Then in jsp i have this:

                        <h:outputText  value="#{BackingBean.planner}" escape="false"/>

and planner renders on page as expected.
I have one more question - for some cases in our business logic we don’t need to write events immediately in database. For example user may ad two or more events, change or remove other saved events and after that confirm all changes using button. Is it possible?

Hi,
unfortunately there is no way to configure it using server side, but you may add it on client side after planner tag:

<h:outputText value="#{BackingBean.planner}" escape="false"/>
<script>
dp.setUpdateMode("off");
</script>
<button onclick="dp.sendData();">Click me to save changes</button>

Method dp.setUpdateMode just turn off automatic saving changes and dp.sendData sends all made changes to the server.

Hi,
I am facing next problem. For loading data i have made a simple CustomEventsManager for test:

... public Iterable<DHXEv> getEvents() { ArrayList events = new ArrayList(); DHXEvent ev1 = new DHXEvent(); ev1.setId(1); ev1.setStart_date("01/23/2014 05:00"); ev1.setEnd_date("01/23/2014 09:00"); ev1.setText("Demo event #1"); events.add(ev1); return events; } ... Following the example i have made events.jsp:

<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.1" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="application/json" import="com.dhtmlx.planner.*,eisuwar.*"/>
    <jsp:expression>getEvents(request)</jsp:expression>
    <jsp:declaration>
        String getEvents(HttpServletRequest request) throws Exception {
        CustomEventsManager evs = new CustomEventsManager(request);
        return evs.run();
        }
    </jsp:declaration>
</jsp:root>

using load method:

String getScheduler(HttpServletRequest request) throws Exception {
    DHXPlanner s = new DHXPlanner("../codebase/");
    ....
    s.load("events.jsp", DHXDataFormat.JSON);
    ....
}

i get this exception:

I can load event using

   s.data.pull.add(ev1);

and it works as well. But if i want to use dataProcessor to edit/save event

s.data.dataprocessor.setURL("events.jsp");

the same exception above is thrown.
Is there a way to get events from planner in my backing bean (as iterable ArrayList maybe) without using dataProcessor? Sure i have to write my create/edit/remove methods, but i can’t find how to resolve exception when using dataProcessor.

Hi,
i guess that dataScroller error is an icefaces bug and there is nothing with javaPlanner. For test i have made two absolutely identical simple applications - one using standard JSF and other using icefaces framework. The only difference between two applications is web.xml file (and of course icefaces libraries ). This is in backing bean (Page1.java, same for two apps):

    protected String otpuskPlanner = "";

    public String getOtpuskPlanner() throws Exception {
        return getScheduler((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
    }

    String getScheduler(HttpServletRequest req) throws Exception {
        com.dhtmlx.planner.controls.DHXYearView view = new com.dhtmlx.planner.controls.DHXYearView();
        DHXPlanner s = new DHXPlanner("./codebase/");
        s.views.add(view);
        s.localizations.set("bg");
        s.setInitialDate(new Date());
        s.config.setScrollHour(8);
        s.setWidth(748);
        s.setHeight(650);
        s.setInitialView("year");
        s.load("gr_events.jsp", DHXDataFormat.JSON);
        s.data.dataprocessor().setURL("gr_events.jsp");
        return s.render();
    }

This is in jsp (Page1.jsp, same for two apps):

                    <div class="scheduler" id="scheduler" style="border: 1px solid #cecece;">
                        <h:outputText escape="false" value="#{Page1.otpuskPlanner}"/>
                    </div>

gr_events.jsp (same for two apps):

<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.1" xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:directive.page contentType="application/json" import="com.dhtmlx.planner.*,calendarwar.*"/>
    <jsp:expression>getEvents(request)</jsp:expression>
    <jsp:declaration>
        String getEvents(HttpServletRequest request) throws Exception {
		GrafikEventsManager evs = new GrafikEventsManager(request);
		return evs.run();
	}
    </jsp:declaration>
</jsp:root>

GrafikEventsManager class is also same for two applications.

The result is:
Pure JSF application - loading, saving, editing events works great;
Icefaces application - loading, saving, editing events does not work.

For JSF application FacesServlet manages the request-processing JSF lifecycle.
For Icefaces application - PersistentFacesServlet (custom icefaces JSF servlet that should does the same request processing JSF lifecycle).

I think i am missing something with PersistentFacesServlet.
And if there is other way to getEvents on server side will be helpfull.

Any suggestions are welcome!
Thanks in advance!

I forgot to say that there is not any exceptions while running icefaces test application

Solved.
At first this is from icefaces 1.8 documentation:

According to this web.xml must contain following:

    <context-param>
        <param-name>com.icesoft.faces.standardRequestScope</param-name>
        <param-value>true</param-value>
    </context-param>

The next step is to make a backing page bean for gr_events.jsp (I had no luck to make it work without page bean). So i removed getEvent() declaration and invokation from jsp. Full page bean code:

/*
 * gr_events.java
 */
package calendarwar;

import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 */
public class gr_events extends AbstractPageBean {
    private int __placeholder;
    private void _init()  {
    }
    public gr_events() throws Exception {
        eventsInit();
    }
    @Override
    public void init() {
        super.init();
        try {
            _init();
        } catch (Exception e) {
            log("gr_events Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }
    }
    public void eventsInit() throws Exception{
        getEvents((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
    }
    String getEvents(HttpServletRequest request) throws Exception {
        EventsMan evs = new EventsMan(request);
        return evs.run();
    }
}

Saving, editing and deleting events works. But Ajax loading does not work - at now i have no idea why. Not a big problem for me - i made Static loading and seems fine. If there is another more elegant solution please, let me know.