CaptainB
CaptainB

Reputation: 51

Exception trying to poll with PrimeFaces

I am getting an exception trying to poll with PrimeFaces. I'm using solution #1 from Primefaces fileUpload and session timout.

javax.faces.FacesException: class java.lang.Long is not supported as "interval" for p:poll

<p:fileUpload id="fileUploadControl" oncomplete="PF('xmlUploadDialog').hide()"
              listener="#{xmlUploadBean.handleFileUpload}" mode="advanced"
              allowTypes="/(\.|\/)(xml|zip)$/" update=":mainForm:scriptTableId"
              multiple="true" />
<p:poll interval="#{session.maxInactiveInterval - 10}" async="true" />

Upvotes: 1

Views: 283

Answers (1)

Melloware
Melloware

Reputation: 11994

In PrimeFaces 10, the attribute interval does not take a Long it can take an Integer or Duration.

See the code:

        Object interval = poll.getInterval();

        int convertedInterval;
        if (interval instanceof Integer) {
            convertedInterval = (Integer) interval;
        }
        else if (interval instanceof Duration) {
            convertedInterval = (int) ((Duration) interval).getSeconds();
        }
        else if (interval instanceof String) {
            try {
                convertedInterval = Integer.parseInt((String) interval);
            }
            catch (NumberFormatException e) {
                throw new FacesException(interval + " is not a valid integer for \"interval\" for p:poll", e);
            }
        }
        else {
            throw new FacesException(interval.getClass() + " is not supported as \"interval\" for p:poll");
        }

Support for Long was added to PrimeFaces 11.

Upvotes: 1

Related Questions