0

I'm using PrimeFaces 3.5 and OmniFaces 1.5. On my main page I've a poll component to refresh some content. Additionally I'm using FullAjaxExceptionHandler to show an error page in case of exceptions during ajax requests.

index.xhtml

<h:form id="formBsvtt">
  <p:messages autoUpdate="true" showDetail="false" />
  <p:outputPanel id="panelOut" layout="block">
    ...
    ... content to refresh
    ...
  </p:outputPanel>
  <p:panelGrid id="panelIn" layout="block">
    ...
    ... various interaction with user and database access
    ...
    <ui:include src="page1.xhtml" />
    <ui:include src="page2.xhtml" />
    <ui:include src="page3.xhtml" />
    ...
  </p:panelGrid>
  <p:poll widgetVar="poll1" autoStart="true" global="false" interval="15" 
    partialSubmit="true" process="@this" update="panelOut"
    listener="#{myBean.myListener}">
  </p:poll>
</h:form>

web.xml

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errorViewExpired.xhtml</location>
</error-page>
<error-page>
    <exception-type>java.sql.SQLException</exception-type>
    <location>/errorSQL.xhtml</location>
</error-page>
<error-page>
    <exception-type>java.lang.RuntimeException</exception-type>
    <location>/errorRuntime.xhtml</location>
</error-page>

My Problem is: In case of exceptions the specified error page will be shown, but polling will not be stopped and then ViewExpired error page is shown every 15 seconds. I tried to stop it with

<h:outputScript>poll1.stop();</h:outputScript>

on the error pages, but this didn't work.

How can I stop poll in case of exceptions?


Update I'm not working with templates. This is my error page:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:of="http://omnifaces.org/functions">

    <h:head>
    </h:head>

    <h:body>

        In der Anwendung trat ein Laufzeitfehler auf!
        <p><a href="#{requestScope['javax.servlet.error.request_uri']}">Anwendung neu starten ...</a></p>
        <ul>
            <li>Date/time: #{of:formatDate(now, 'yyyy-MM-dd HH:mm:ss')}</li>
            <li>User agent: #{header['user-agent']}</li>
            <li>User IP: #{empty header['x-forwarded-for'] ? request.remoteAddr : fn:split(header['x-forwarded-for'], ',')[0]}</li>
            <li>Request URI: <a href="#{requestScope['javax.servlet.error.request_uri']}">#{requestScope['javax.servlet.error.request_uri']}</a></li>
            <li>Ajax request: #{facesContext.partialViewContext.ajaxRequest ? 'Yes' : 'No'}</li>
            <li>Status code: #{requestScope['javax.servlet.error.status_code']}</li>
            <li>Exception type: #{requestScope['javax.servlet.error.exception_type']}</li>
            <li>Exception message: #{requestScope['javax.servlet.error.message']}</li>
            <li>Stack trace: <pre><code>#{of:printStackTrace(requestScope['javax.servlet.error.exception'])}</code></pre></li>
        </ul>
        <h:outputScript>poll1.stop();</h:outputScript>
        <h:outputScript>poll2.stop();</h:outputScript>
        <h:outputScript rendered="#{facesContext.partialViewContext.ajaxRequest}">scrollTo(0, 0);</h:outputScript>

    </h:body>

</html>
RueKow
  • 193
  • 3
  • 10
  • The `poll1.stop();` should work. At least, I tried to reproduce your problem, but the `stop()` solved it. Did you really put it inside `` if you're using templating? – BalusC Jun 26 '13 at 12:59
  • Oh, I'm not using templating. So javascript function "poll1.stop()" is not available on my error page??? – RueKow Jun 26 '13 at 13:55
  • Where's the ``? This is invalid HTML. Put it around `` or replace `` by ``. – BalusC Jun 26 '13 at 14:02
  • I've changed with , but poll doesn't stop. Should I reorganize to templating ? – RueKow Jun 26 '13 at 18:46
  • Sorry, can't reproduce your problem with Mojarra 2.1.21. Which JSF impl/version are you using? Perhaps it has a bug in processing ` – BalusC Jun 26 '13 at 18:46
  • Try adding `console.log(...)` or `alert(...)` line to see if any ` – BalusC Jun 26 '13 at 18:52
  • I'm using Myfaces 2.1.12. Tomorrow I will try it with Mojarra! – RueKow Jun 26 '13 at 18:55
  • I have added alert('Here I am') line and this was processed. – RueKow Jun 26 '13 at 19:21
  • What does `console.log(poll1)` say? Does it exist in the scope at all? – BalusC Jun 26 '13 at 19:41
  • I feel a bit sheepish. I forgot that there is another poll in an included xhtml file. I was so focused on poll1 that I forgot poll2. After stopping poll2 with `poll2.stop();` it is working fine. Sorry for the trouble I made! – RueKow Jun 27 '13 at 05:19
  • You can post that as an answer, or better just delete the question. – BalusC Jun 27 '13 at 13:22

0 Answers0