问题
I have a JSF page where a popup would appear if he is idle for some period of time. 3 min 10 min etc If he is idle for some period of time a confirmDialog box would comeup with a message - "Your session has expired." and a command button id="quitConfirm" OK
Upon clicking the button ID it redirects to the home page or what ever path that you mentioned
To test this I deployed this in my local weblogic server and after a wait time of 4 min or so clicked on the commandButton OK it redirected as expected.
Issue -
after a wait time of 1 hour or so clicked on the commandButton, It did nothing
It doesnot redirect/ does nothing.
Did not change anything in the code, Just had to wait for a period of 30 min or a hour.
Actual Function
It should redirect even after a longer period of time. I mean the pop up dialogue can appear after 3 min but if you click on it after an hour or so it should redirect.
Reproducible code -
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:panelGrid>
<p:column>
<h:outputText id="bankwithdrawid" />
<h:form prependId="false">
<h:commandButton value="Expired" id="submit" type="submit" title="Click here to Restart" action="#{expiredMB.logout}"/>
<p:idleMonitor timeout="9000">
<p:ajax event="idle" onstart="PF('sessionTimout').show()" />
</p:idleMonitor>
<p:confirmDialog showEffect="fade" hideEffect="explode"
message="Your session has expired."
header="Session Timeout " widgetVar="sessionTimout" appendTo="@(body)">
<p:commandButton id="quitConfirm" value="OK" action="#{expiredMB.logout}" process="@this" onclick="PF('sessionTimout').hide()" />
</p:confirmDialog>
</h:form>
</p:column>
</h:panelGrid>
</ui:composition>
Java bean ExpiredMB
public class ExpiredMB {
private static final Logger logger = LoggerFactory
.getLogger(ExpiredMB.class);
public void logout() {
ExternalContext ectx = FacesContext.getCurrentInstance()
.getExternalContext();
ectx.getSessionMap().clear();
ectx.invalidateSession();
try {
ectx.redirect("/security/home.do?submit=Log In");
} catch (IOException e) {
logger.error("Problem with login." + e.getMessage());
}
}
}
来源:https://stackoverflow.com/questions/60814396/confirmdialog-commandbutton-does-not-redirect-does-nothing-if-you-wait-for-a-lo