com.sdm.quasar.client.jsf.dialog
Class BrowserWindow

java.lang.Object
  extended bycom.sdm.quasar.client.jsf.dialog.BrowserWindow

public class BrowserWindow
extends java.lang.Object

This is the application side representation of the browser window.

The BrowserWindow is responsible for managing shown or hidden VisualRepresentations. The VisualRepresentation of a dialog is shown when the dialog is activated and it is hidden, when the dialog is deactevated. To be informed about your visibility state register a listener at your VisualRepresentation.

Note: A deactivated but not closed dialog is activated by user code only (i.e. a controlling dialog of the concerning dialog) never by the framework.

The BrowserWindow supports to show modal and non modal dialogs and hide dialogs with four different strategies concerning backnavigation to the corresponding page:

Default is hide and reopen. Be carefull using modal dialogs and other than the default hide strategy: The browser navigation will not always match the users expection. If you use modal dialogs, make them singletons to get less problems with multi windows!

Note: Up to now there will be only one instance of this at all, because we can't control new browser windows sufficiently. This has shortcomming for correct information about visibility of VisualRepresentation and modal dialogs that are no singletons when more than one browser windows are opend.

Author:
Martin Haft

Constructor Summary
BrowserWindow(java.lang.String browserWindowId)
          A BrowserWindow with no history is constructed
 
Method Summary
 java.lang.String buildActionURL(java.lang.String requestContextPath)
           
 java.lang.String buildIdFromPostParameters()
           
protected  boolean checkSequenceNumber(DialogInstanceId dialogInstanceId, java.lang.Integer sequenceNumber)
          Check correct sequece number to detect double submit
 boolean determineVisualRepresentation(HttpServletRequest request, BrowserWindowCallBack callBack)
          Analyses the request parameters and determines the page to be shown.
protected  VisualRepresentation findPredecessor(VisualRepresentation from)
           
 java.lang.String getBrowserWindowId()
           
protected  VisualRepresentation getPredecessor(VisualRepresentation visRep)
           
 java.util.Set getRegisteredVisualRepresentations()
           
 VisualRepresentation getVisualRepresentation()
           
protected  VisualRepresentationInfo getVisualRepresentationInfo(VisualRepresentation visRep)
           
protected  boolean handleDoubleSubmit(HttpServletRequest request, BrowserWindowCallBack callBack, VisualRepresentation visRep)
          Checks if this is a request to a previous state of the dialog.
 boolean hasCurrentPage()
           
 void hideVisualRepresentation(VisualRepresentation visRep, boolean recreate, java.lang.String redirectUrl, java.lang.String replacingDialogId, java.lang.Object context)
          Marks the VisualRepresentation to be not shown any more.
protected  void setPredecessor(VisualRepresentation visRep, VisualRepresentation predecessor)
           
 void setVisualRepresentation(VisualRepresentation newVisRep)
          Sets a new VisualRepresentation to be shown in the current request.
 void showRepresentation(VisualRepresentation visRep)
          A VisualRepresentation - corresponding to a dialog - will be shown in the browser.
 void showVisualRepresentation(VisualRepresentation visRep, boolean modal)
          A VisualRepresentation - corresponding to a dialog - will be shown in the browser.
 java.lang.String toString()
           
 void writePostParameters(UIComponent component, ResponseWriter writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BrowserWindow

public BrowserWindow(java.lang.String browserWindowId)
A BrowserWindow with no history is constructed

Parameters:
browserWindowId - the id of this BrowserWindow
Method Detail

getBrowserWindowId

public java.lang.String getBrowserWindowId()
Returns:
the id of this browser window

showVisualRepresentation

public void showVisualRepresentation(VisualRepresentation visRep,
                                     boolean modal)
A VisualRepresentation - corresponding to a dialog - will be shown in the browser. You can set it modal: the page could not be exited by browser navigation until it is hidden again. Be careful with modal dialogs!

Parameters:
visRep - The VisualRepresentation to be shown in the browser
modal - true if ths VisualRepresentation will be shown modal

showRepresentation

public void showRepresentation(VisualRepresentation visRep)
A VisualRepresentation - corresponding to a dialog - will be shown in the browser.

Parameters:
visRep - The VisualRepresentation to be shown in the browser

hasCurrentPage

public boolean hasCurrentPage()

getVisualRepresentation

public VisualRepresentation getVisualRepresentation()
Returns:
The VisualRepresentation to be shown in the actual request.

determineVisualRepresentation

public boolean determineVisualRepresentation(HttpServletRequest request,
                                             BrowserWindowCallBack callBack)
Analyses the request parameters and determines the page to be shown. TODO: Interface for the framework only

Parameters:
request - The current request containing the id to identify the requested page
callBack - CallBack with exits when no page could be reconstructed or other than the requested page will be shown.
Returns:
true if response is completed due to redirect to other than requested dialog

handleDoubleSubmit

protected boolean handleDoubleSubmit(HttpServletRequest request,
                                     BrowserWindowCallBack callBack,
                                     VisualRepresentation visRep)
Checks if this is a request to a previous state of the dialog. If so, the handling per ReactivationCallback is invoked.

Parameters:
request - the actual request
callBack - a callback to handel other than the normal action
visRep - the VisualRepresentation connected to the request
Returns:
true when request is completed e.g. due to redirect

checkSequenceNumber

protected boolean checkSequenceNumber(DialogInstanceId dialogInstanceId,
                                      java.lang.Integer sequenceNumber)
Check correct sequece number to detect double submit

Returns:
true if sequence number is correct

setVisualRepresentation

public void setVisualRepresentation(VisualRepresentation newVisRep)
Sets a new VisualRepresentation to be shown in the current request.

Parameters:
newVisRep - the VisualRepresentation to be shown in the request.

hideVisualRepresentation

public void hideVisualRepresentation(VisualRepresentation visRep,
                                     boolean recreate,
                                     java.lang.String redirectUrl,
                                     java.lang.String replacingDialogId,
                                     java.lang.Object context)
Marks the VisualRepresentation to be not shown any more. If there is a request to this hidden VisualRepresentation you can define which of the following strategies shold be perfomed: If the hidden page is the currently shown page, the VisualRepresentation privious shown is now the current VisualRepresentation for the request.

Parameters:
visRep - the VisualRepresentation to be hidden
recreate - if true: Hide and recreate; false: redirect when redirect url or dialog is set else hied and do not show again
redirectUrl - if != null (and recreate == false): perform redrect to this url
replacingDialogId - if != null (and recreate == false): perform redrect to this dialog

getVisualRepresentationInfo

protected VisualRepresentationInfo getVisualRepresentationInfo(VisualRepresentation visRep)
Parameters:
visRep - a VisualRepresentation
Returns:
an object with additional informations of the given VisualRepresentation

buildActionURL

public java.lang.String buildActionURL(java.lang.String requestContextPath)
See Also:
ResponseParameterService.buildActionURL(java.lang.String)

buildIdFromPostParameters

public java.lang.String buildIdFromPostParameters()
See Also:
ResponseParameterService.buildIdFromPostParameters()

writePostParameters

public void writePostParameters(UIComponent component,
                                ResponseWriter writer)
                         throws java.io.IOException
Throws:
java.io.IOException
See Also:
com.sdm.quasar.client.jsf.dialog.services.ResponseParameterService#writePostParameters(javax.faces.component.UIComponent, javax.faces.context.ResponseWriter)

toString

public java.lang.String toString()

getRegisteredVisualRepresentations

public java.util.Set getRegisteredVisualRepresentations()
Returns:
List of WebPages

findPredecessor

protected VisualRepresentation findPredecessor(VisualRepresentation from)

setPredecessor

protected void setPredecessor(VisualRepresentation visRep,
                              VisualRepresentation predecessor)

getPredecessor

protected VisualRepresentation getPredecessor(VisualRepresentation visRep)