This content has been marked as final.
Show 6 replies
-
1. Re: Is it possible to ask the framework if the session is ex
nbelaevski Jun 29, 2009 1:47 PM (in response to derkd)...alert is working but the redirection not because the oncomplete is executed
How does oncomplete look like? Why does it stops redirection? -
2. Re: Is it possible to ask the framework if the session is ex
derkd Jun 30, 2009 1:28 AM (in response to derkd)Hi Nick,
Thanks for replying.
the oncomplete javascript looks like this:function registreer(waarde) { tempArray = waarde.split("+"); refCode=tempArray[0]; refOmschrijving=tempArray[1]; synCode=""; synOmschrijving=""; if (tempArray.length >= 4) { synCode=tempArray[2]; synOmschrijving=tempArray[3]; } if(refCode == synCode){ synCode = ""; } if(refOmschrijving == synOmschrijving){ synOmschrijving = ""; } //alert("waarde=" + waarde + "\n" + refCode + "\n" + refOmschrijving + "\n" + synCode + "\n" + synOmschrijving); var ClientObj = new Object(); ClientObj.Code = refCode; ClientObj.Omschrijving = refOmschrijving; ClientObj.CodeSyn = synCode; ClientObj.OmschrijvingSyn = synOmschrijving; ClientObj.Type = "Beroep"; top.pCallBackFunction(ClientObj); top.window.close(); }
A 3rd party app can open a browser window displaying my web app. My web app passes the id's of some variables back to the 3rd party app.
the template for the layout of my pages with the richfaces javascript onExpired method looks like this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <f:subview contentType="text/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:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:s="http://jboss.com/products/seam/taglib"> <div class="body"> <a4j:region> <script language="javascript"> A4J.AJAX.onExpired = function(loc, expiredMsg){ alert('Uw sessie is verlopen (Layout)! U wordt teruggeleid naar deze pagina: '+loc); //return loc; window.location = "../timeout.seam"; } </script> </a4j:region> <ui:insert name="body"/> </div> </f:subview>
-
3. Re: Is it possible to ask the framework if the session is ex
derkd Jun 30, 2009 4:38 AM (in response to derkd)I think I have got it.
When having the layout.xhtml template file like this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <f:subview contentType="text/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:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:s="http://jboss.com/products/seam/taglib"> <div class="body"> <a4j:region> <script language="javascript"> A4J.AJAX.onExpired = function(loc, expiredMsg){ //alert('Uw sessie is verlopen (Layout)! U wordt teruggeleid naar deze pagina: '+loc); //return loc; window.location = "../timeout.seam"; } </script> </a4j:region> <ui:insert name="body"/> </div> </f:subview>
It will execute the oncomplete, but if I uncomment the alert, the redirect sometimes works... isn't that strange? I assume that retrieving the window.location isn't going fast enough and then the oncomplete is already executing. Howto cancel the oncomplete? -
4. Re: Is it possible to ask the framework if the session is ex
nbelaevski Jun 30, 2009 5:53 AM (in response to derkd)Try this:
A4J.AJAX.onExpired = function(loc, expiredMsg){ alert('Uw sessie is verlopen (Layout)! U wordt teruggeleid naar deze pagina: '+loc); //return loc; return "../timeout.seam"; }
-
5. Re: Is it possible to ask the framework if the session is ex
derkd Jun 30, 2009 6:36 AM (in response to derkd)Unfortunatly it isn't working either. Especially when I remove the alert it goes almost straigt to the oncomplete. So the javascript is going faster than the redirect.
I think I have 2 options:
solve this in the oncomplete javascript and make a check if the session is expired, but how?
or do a check like this:<a4j:commandLink id="beroep" action="#{zoekBeroepAction.retrieveBeroepRelatie(_beroep)}" oncomplete="zoekBeroepAction.beroepRelaties.cdBeroepsnaam != null ? registreer('#{zoekBeroepAction.beroepRelaties.cdBeroepsnaam}+#{zoekBeroepAction.beroepRelaties.omsBeroepsnaam}+#{_beroep.cdBeroepsnaam}+#{_beroep.omsBeroepsnaam}'): 'false' ">#{_beroep.omsBeroepsnaam}</a4j:commandLink>
it looks like the last option seem to work! -
6. Re: Is it possible to ask the framework if the session is ex
derkd Jul 1, 2009 3:08 AM (in response to derkd)hmmm I made a typo... forgot the #{ and } in oncomplete.
So this isn't working either. I now solved it by checking on empty results in the javascript of the oncomplete (the registreer method) and then forward it to another location.
If somebody got a better idea, let me know.
regards,
Derk