begiPass
begiPass

Reputation: 2174

redirect to another page after some seconds jsf2 primefaces

I have a page that allow to edit user, and when a user click in "edit" button, I redirect him to another page for some seconds an I want to redirect him again but this time to another page once and for all, I tried to use <p:poll>

but it doesn't work here is my code :

 <?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./template_admin.xhtml">

            <ui:define name="content">
                <h:form id="form">

                            <p:panel id="panel" header="Confirmation" style="width: 400px;margin: auto;" >

                                <h:panelGrid columns="1">
                                    <h:outputText value="votre edition est sauvegardé avec succée"/>
                                    <h:outputText value="vous serez rediriger vers la page de la liste des utilisateurs dans quelques instants" />
                                    <p:poll interval="3" action="utilsateurs" />
                                </h:panelGrid>


                            </p:panel>

                        </h:form>

            </ui:define>

        </ui:composition>

    </body>
</html>

do you have any idea thank you in advance

Upvotes: 1

Views: 3531

Answers (1)

damian
damian

Reputation: 4044

You don't need poll. you can do it with plain html. add this tag to the head of the page

<meta http-equiv="refresh" content="5;URL=otherUrl.jsf" />

This will redirect to "otherUrl.jsf" after 5 seconds. Since you are using a template, maybe you can add a ui:insert in the header, so you can insert the meta into the header from template client.

Upvotes: 1

Related Questions