1

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" />
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
CaptainB
  • 51
  • 5

1 Answers1

1

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.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Melloware
  • 10,435
  • 2
  • 32
  • 62