Intercepting session time-out when calling show on rich:modalpanel - jsf

I am trying to intercept a session time-out when a user click on commadLink that shows a modal panel. So far, I haven't been successful...
Example :
<a4j:commandLink execute="#form" oncomplete="#{rich:component('ContactModalPanel')}.show(); return false;" limitRender="true" render=":ContactModalPanelSubViewForm:ContactDataTable">
Many thanks,
JSF 2.1
RichFaces 4.3.3.Final

Related

Returning invalid view from JSF action method shows warning in the facelet, but how could I detect it earlier?

I have a JSF 2.3 application.
In my LoginBean, the username and password entered by the user are varified and then the user is redirected to the URL initially inquired: for example if the user inquires:
http://myhostname/admin/manage.jsf
then because every resource under http:///admin requires authentication, the user is first redirected to the logon view, something like
http://myhostname/login/login.jsf
and then, upon successful authentication, they are redirected to their initially inquired URL (in this case, the first URL above)
However, if the initially inquired URL is a view that does not exist, i.e.
http://myhostname/admin/nonExisting.jsf
after the user gets authenticated, nothing happens: He / she is neither shown an error page, nor an erroneous log entry is made in the logs. Just the user remains on the login page.
How could I solve this?!
I added an error handling in the facelet like this:
<p:growl id="messages" autoUpdate="true" showDetail="true" />
and then, for the logon button:
<p:commandButton action="#{loginBean.login}" value="Log In" update="#form"/>
Now, when a non-existing view is returned, I do see the warning message:
but how coul I handle it earlier?

JSF Primefaces application doesn't render properly on upgraded WildFly 18

I upgraded my server in Eclipse from WildFly v10.x to WildFly 18.0.0 Final and now one of my JSF/Primefaces applications doesn't render properly after updating the view. On initial page load the view looks fine but if I select some filters (Primeface dropdowns, checkboxes, etc..) and click a command button to refresh the view (AJAX), it renders as if Primefaces is no longer available. See screenshots
Initial View Renders Fine:
After View Is Updated:
The error while debugging in Chrome:
SCRIPT5007: Unable to get property 'cw' of undefined or null reference
.
$(function(){PrimeFaces.cw('Growl','widget_growl',{id:'growl',sticky:false,life:5000,escape:true,msgs:[]});});
Not sure why the application is now not working after just upgrading WildFly.
I fixed by replacing #all on the p:commandButton with a more specific target
<p:commandButton action="#{...}" update="#all" />
<p:commandButton action="#{...}" update=":tripFormId:dataTableId" />
I realized after seeing this in the Chrome console debugger
jquery.js.xhtml?ln=primefaces&v=7.0:2 [Deprecation] Synchronous
XMLHttpRequest on the main thread is deprecated because of its
detrimental effects to the end user's experience. For more help, check
https://xhr.spec.whatwg.org/.

simple jsf commandbutton work on every single page except home page

A Java EE 8/SE 8 web application in deployement runnnig on Glassfish 5 build 25 both production and development, uses jsf 2.3. users create accounts and login. there is a 'logout' button for loging out.
Problem: 'logout' button works as expected everywhere on the website. EXCEPT home page (example.com) & (example.com/home.xhtml). the problem does not exists on my local computer. only in production (example.com).
So I have a template called : index.xhtml . all pages use it, including home.xhtml:
<ui:composition template="index.xhtml">
<ui:define name="top-bar">
<c:if test="#{request.remoteUser ne null}">
<h:form ><h:commandButton value="Log out" action="#{registerAdvanced.logout}"/></h:form>
</c:if>
</ui:define>
and
#Named
#RequestScoped
public class RegisterAdvanced extends BaseBacking implements Serializable {
public String logout() {
try {
getRequest().logout();
getContext().getExternalContext().getSessionMap().remove("user");
return REDIRECT_PAGE;
} catch (ServletException ex) {
return REDIRECT_PAGE;
}
}
}
Users login & logout fairly easily until I noticied that clicking on logout on the home page (home.xhtml) prints a null pointer exception AND redirect to 404 error page.
[[/home.xhtml #450,77 value="#{passesTestBean.displayPassSummaryList}": java.lang.NullPointerException
javax.el.ELException: /home.xhtml #450,77 value="#{passesTestBean.displayPassSummaryList}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:119)
at com.sun.faces.facelets.component.UIRepeat.getValue(UIRepeat.java:314)
at com.sun.faces.facelets.component.UIRepeat.getDataModel(UIRepeat.java:256)
at com.sun.faces.facelets.component.UIRepeat.setIndex(UIRepeat.java:507)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:557)
at com.sun.faces.facelets.component.UIRepeat.processDecodes(UIRepeat.java:861)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1258)....
part of jsf where there is a call to value="#{passesTestBean.displayPassSummaryList}" is 100% seperate to logout and PassesTestBean CDI is request scope.
so the problem is SOMEHOW when I click on logout button. PassesTestBean is called for no reason and not since jsf must Initialize (since Request Scoped). it ends up returning null.
Now remember this only happens in: production at example.com AND only home page of all pages.
I'm thinking of writing a page only for loging out: has a log out button only.
Check for null pointer exception
getRequest().logout(); //here
getContext().getExternalContext().getSessionMap().remove("user");//here

JSF commandButton giving 404 - /500.shtml

I have a JSF commandButton, simply should submit a form,
<h:form role="form" enctype="multipart/form-data">
....
<h:commandButton id="submit" value="add"
onclick="return validate('submitForm')"
action="#{propertyBean.submit}"
class="btn btn-green btn-lg arabic"
rendered="#{propertyBean.isNew == true}">
</h:commandButton>
</h:form>
the button is working okey on localhost but when I deploy the application on a server I get this error
HTTP Status 404 - /500.shtml
type Status report
message /500.shtml
description The requested resource is not available.
the action method is never called, as the backing methods prints a statement as its called.
This problem is two-fold. A HTTP 500 error occurred (usually, because an exception was thrown), so the container needs to display a HTTP 500 error page which was in your case apparently registered as /500.shtml, but the container could in turn not find that file and hence the HTTP 404 error on that file.
In order to find out the problem causing the method not being invoked, you've 2 options:
Read the server logs to find the exception.
Register a valid HTTP 500 error page and let it print the stack trace.
Once having the real exception at hands, you can easily solve the underlying problem.

multiple JSESSIONID cookie with JSF

I have JEE application Wildfly RC1 JEE7 - CDI,EJB, JSF Mojarra 2.2.4
In my application i use h:outputLink for create links simply without calling bean actions.
like this
<h:outputLink styleClass="btn btn-primary" value="#{request.contextPath}/views/product/addproduct.xhtml" >
<i class="glyphicon glyphicon-plus" />
add product
</h:outputLink>
After many navigation, Bean actions don't work. In chrome i discover 3 cookies JSESSIONID with different path corresponding to each navigation link
Any idea to handle this
source of problem not identified but resolved by replacing apache shiro servlet session manager by
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
securityManager.sessionManager = $sessionManager

Resources