Logout with confirmation dialog

A question on OTN (http://forums.oracle.com/forums/forum.jspa?forumID=83) leads to this short article.

The use case requires to ask for a confirmation before logging out of the application.  This can easily implemented using a OK/Cancel dialog  which we show on a button click.

My simple test page looks like this:

On a click on the logout button we show a confirmation dialog as popup:

The dialog uses a dialog listener to catch the user input.  For an OK/Cancel dialog only the click on the OK button is passed to the listener. Closing the dialog or clicking cancel never calls the dialog listener. Clicking on OK navigates to a logout page:

Looks pretty simple,  still we need  a few things to mention. The code for the logout button and popup  looks like:

<af:panelGroupLayout id="pgl1">
  <af:commandButton text="Logout" id="cb2">
    <af:showPopupBehavior popupId="p1" triggerType="action"/>
  </af:commandButton>
  <af:popup id="p1">
    <af:dialog id="d2" dialogListener="#{LoginLogout.dialogLogoutListener}" title="Confirmation">
    <af:outputText value="Do you want to logout?" id="ot2"/>
    </af:dialog>
  </af:popup>
 </af:panelGroupLayout>

The real work is done in the dialog listener in the managed bean (here called LoginLogout). The dialog listener checks if OK was clicked, and then calls the logoutTarget method with a parameter which is the target page after invalidating the session. This page is a normal html page just showing the user that his session has ended. On this page you can put a link back to the application as shown above.

public String logoutTarget(String aTarget)
{
  ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
  HttpServletResponse response = (HttpServletResponse) ectx.getResponse();
  String url = ectx.getRequestContextPath() + aTarget;
  HttpSession session = (HttpSession) ectx.getSession(false);
  //close session
  session.invalidate();
  try
  {
    response.sendRedirect(url);
    FacesContext.getCurrentInstance().responseComplete();
  }
  catch (IOException e)
  {
    e.printStackTrace();
  }
  return null;
}

public void dialogLogoutListener(DialogEvent dialogEvent)
{
  if (dialogEvent.getOutcome() == DialogEvent.Outcome.ok)
  {
    logoutTarget("/ByBy.html");
  }
}

If you use a jspx page which is part of  your application, the session gets invalidated but you see that url rewriting stuff is still part of the url you see in the browser.

http://127.0.0.1:7101/LoginLogout/faces/Logout.jspx?_afrWindowMode=0&_afrLoop=10962072683890&_adf.ctrl-state=10eyn0547w_4

I like it if the url looks like

http://127.0.0.1:7101/LoginLogout/ByBy.html

so I use a normal html page.

Feel free to play with this. You only have to change the parameter in the logoutTarget(…) method call to

logoutTarget("/faces/Logout");

if you have a page Logout.jspx in your application.

Upgrade an existing WLS 10.3.2 to WLS 10.3.3

Since JDev 11.1.1.3.0 is out we have to think about where to deploy the apps to which are developed with the new version. Bad new is, that you can’t use existing WLS 10.3.2 and just delpoy application compiled or developed with the new JDev 11.1.1.3.0 version. Good news is, that you don’t have to setup a whole new WLS 10.3.3, at least if you have a valid support contract.

Log in to MOS and download the upgrade installer for WLS 10.3.3 (from the patch and update section) and the ‘Oracle Application Development Runtime 11g Patch Set 2’ (from E-Delivery)

In this short post I’ll just describe the ease routine of updating an existing WLS 10.3.2 :

  1. remove all your applications running on WLS 10.3.2 (first stop them, then delete them)
  2. stop WLS 10.3.2
  3. make a backup of all the files in WLS you have changed. The upgrade process does this for only a barely minimum of files.
  4. run the upgrade installer for WLS 10.3.3: this is just pointing to the existing ‘Middleware’ folder (the folder you installed the WLS 10.3.2 to) and let the installer do the rest of the work
  5. run the ADF runtime installer patch to 11.1.1.3.0: this is patch installer, so you need to have ADF 11.1.1.2.0 installed, otherwise you’ll get an error. The only thing to do is to point to an existing domain in the now upgraded WLS.
  6. start WLS now 10.3.3
  7. deploy your apps (compiled with JDev 11.1.1.3.0) again

That all you need to do. For more complex scenarios like clusters  and/or WLS installation which have been adopted to special needs you my have to do some more work. This is all well documented in the README.TXT file you get together with the upgrade installer.