Question

I'm using ICEfaces with ICEpush to push some data to the browser.

However, it does not work like planned: It does no AJAX, it just invokes the action and returns from the action like any other non-AJAX action does.

I'm using the newest ICEfaces and ICEpush versions and Tomahawk 7 and JSF 2.

It works with neither Servlet 2.5 nor Servlet 3.0.

These are the important parts of my bean (view scoped):

public AjaxTest() {
    PushRenderer.addCurrentSession(PUSH_GROUP);
}

    public void addText() throws InterruptedException {
    for(int i = 0; i < 5; i++) {
        lines.add("line " + i);
        PushRenderer.render(PUSH_GROUP);
        Thread.sleep(1000);                     
    }
}

And this is a snippet of my form:

    <h:panelGroup>
        <h:dataTable id="ajaxTestTable" value="#{ajaxTest.lines}" var="line">
            <h:column>
                <h:outputText value="#{line}" />
            </h:column>
        </h:dataTable>
        <h:commandButton id="startAjax" value="Start"
            action="#{ajaxTest.addText}" />
    </h:panelGroup>

Did I miss something? Thanks!

Was it helpful?

Solution

ICEfaces 2.0 is not yet integrated with MyFaces. Have you tried your application with the included Mojarra .jar files?

OTHER TIPS

I'm only familiar with Icefaces 1.8, but it seems to me you're command button isn't ajax enabled. As well you have to use an actionListener instead of an action

You can use either the icefaces command button:

<ice:commandButton id="startAjax" value="Start" 
       actionListener="#{ajaxTest.addText}"/>

or the JSF 2 ajax tags:

<h:commandButton id="startAjax" value="Start">
    <f:ajax listener="#{ajaxTest.addText}"/>
</h:commandButton>

Do you have some development tool that can validate the code? At least on Vaadin version of ICEPush you could not trust to their examples. On their official demo there was deprecated code and on their chat they gave code where imports were from another planet with the correct ones.

My Eclipse told that many imports were wrong and code had deprecated marks on some functions. These guys there develop so fast that their documents are permanently out of date. So, read carefully what your tool says about the code!

I also have the problem with integration of IceFaces (to use push) with the app which already use Richfaces. But it is possible to integrate the IcePush directly with almost any java-web-application (with Servlet Api). You can see more details on http://achorniy.wordpress.com/2012/02/29/icepush-integration-to-web-application/

The idea is to use javascript-api(or jQuery-api) provided by IcePush. So, your page with javascript-api register itself as a listener to push notifications and in the callback you can call whatever javascript functions to update your page. In Richfaces example you may use ajaxUpdateFunction() which is actually backed by <a4j:jsFunction name="ajaxUpdateFunction" action="#{myBean.update} reRender="updatedComponent(s)" ajaxSingle="true"/> or perform ajax-request with jQuery. In your case (JSF-2.0) I think you can call jsf.ajax.request(this, event, {render:'ajaxTestTable'}) to update what you want (examples http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/)

all you need to do on server-side - is to register IcePush servlet and initialize icePush connection on the client side with javascript api.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top