jaxcent
Class JaxcentPage

java.lang.Object
  extended byjaxcent.JaxcentPage

public class JaxcentPage
extends java.lang.Object

JaxcentPage is the base class from which all Jaxcent URL handlers need to be derived. In cases where no particular handler is needed (when using auto-session-management and when no data verification is needed), this class can be specified directly as the handler. This class provides over-ridable methods to process operations like load and unload. It also provides various common utility methods, such as showing JavaScript alert (dialog box) messages.


Constructor Summary
JaxcentPage()
          Default constructor.
 
Method Summary
 boolean checkElementExists(SearchType searchType, java.lang.String searchString, int searchIndex)
          Check if an element exists, without attempting to assign it to an object.
 void deleteCookie(java.lang.String cookieName)
          Delete cookie.
 void deleteSelectOption(java.lang.String id)
          Delete a SELECT OPTION referenced by an ID.
 void deleteTableCell(java.lang.String id)
          Delete a table cell (TD) referenced by an ID.
 void deleteTableRow(java.lang.String id)
          Delete a table row (TR) referenced by an ID.
 java.lang.String evalJavaScriptCode(java.lang.String code, boolean argsAsArray, java.lang.Object[] args)
          same as execJavaScriptCode, but waits for the result of the evaluation and returns it.
 void execJavaScriptCode(java.lang.String code, boolean argsAsArray, java.lang.Object[] args)
          Call JavaScript, do not wait for results.
 java.util.Map getAllFormData()
          Retrieve all form data on page.
 java.util.Map getAllSessionData(boolean getFromCurrentPage)
          Get all data from session so far.
 java.lang.Object getAppContext()
          This method will return the application server's or Jaxcent connector's application context.
 java.lang.String getCookie(java.lang.String cookieName)
          Get cookie value.
 java.util.Map getCookies()
          Get cookies from page as name->value pairs.
 java.lang.String getCurrentPath()
          Get the path of the URL that is being processed.
 java.lang.Object getHttpSession()
          If "UseSession" or "AutoSessionData" have been configured as true in the configuration file for this page, this method will return the HTTP session object from the application server or Jaxcent connector.
 java.util.Locale getLocale()
          Get the remote locale if specified in HTTP Accept-Language header.
 java.util.Locale[] getLocales()
          Get a list of remote locales if specified in HTTP Accept-Language header.
 java.lang.String getRemoteAddr()
          Get the client IP address.
 java.awt.Dimension getScreenSize()
          Get screen dimensions
 java.lang.String getStatusText()
          Get status text.
 java.awt.Dimension getWindowSize()
          Get window dimensions
 void goBack()
          Navigate back.
 void goForward()
          Navigate forward.
 void navigate(java.lang.String url)
          Navigate to a given URL.
protected  void onFinalFormData(java.util.Map formData)
          Override to receive form data during page unloading.
protected  void onJavaScriptRequest(java.lang.String cmd, java.lang.String[] args)
          Override to process data from JavaScript methods sent by calling the "JaxcentServerRequest( args...
protected  void onLoad()
          Override to handle page loading.
protected  void onUnload()
          Override to handle page unloading.
 void setBatchUpdates(boolean batchUpdates)
          Used to hold updates without sending them out to the client.
 void setCookie(java.lang.String cookieString)
          Add cookie to page.
 void setCookie(java.lang.String name, java.lang.String value, java.util.Date expires, java.lang.String domain, java.lang.String path, boolean isSecure)
          Add cookie to page.
 void setStatusText(java.lang.String text)
          Set status text.
 boolean showConfirmDialog(java.lang.String message)
          Show JavaScript confirm dialog box to the user.
 java.lang.String showInputDialog(java.lang.String prompt, java.lang.String defaultResult)
          Show JavaScript prompt dialog box to the user.
 void showMessageDialog(java.lang.String message)
          Show JavaScript alert dialog box to the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxcentPage

public JaxcentPage()
Default constructor. Called by the Jaxcent framework, do not call directly. Usually this class is overridden.

Method Detail

getHttpSession

public java.lang.Object getHttpSession()
                                throws Jaxception
If "UseSession" or "AutoSessionData" have been configured as true in the configuration file for this page, this method will return the HTTP session object from the application server or Jaxcent connector.

If running with a standard Java servlet-container/application-server, the object returned is of type javax.servlet.http.HttpSession, and can be cast to that type.

If running with a direct Jaxcent connector for IIS/Apache, the object returned is of type jaxcentConnector.JaxcentSession.

Throws:
Jaxception

getAppContext

public java.lang.Object getAppContext()
                               throws Jaxception
This method will return the application server's or Jaxcent connector's application context.

If running with a standard Java servlet-container/application-server, the object returned is of type javax.servlet.ServletContext, and can be cast to that type.

If running with a direct Jaxcent connector for IIS/Apache, the object returned is of type jaxcentConnector.JaxcentAppContext.

Throws:
Jaxception

onLoad

protected void onLoad()
Override to handle page loading. Data can be retrieved from the page at this time.


onFinalFormData

protected void onFinalFormData(java.util.Map formData)
Override to receive form data during page unloading. The data has the same format as getAllFormData. But at this time, no further interactions with the page are possible. The data can be saved in the session, or otherwise processed. Field verifications cannot be done here. For field verifications, add handler on buttons or other fields, and retrieve the data either individually or by calling getAllFormData().


getAllFormData

public java.util.Map getAllFormData()
                             throws Jaxception
Retrieve all form data on page. The data must be identifiable with a name or an ID. In addition to INPUT tags, also retrieves data from SELECT and TEXTAREA tags. The returned Map maps names or ids, to values. Multile checkboxes can have the same name and multiple values. These are separated by commas. If the checkbox (or none of the checkboxes) is not selected, there will still be a value, and this value will be an empty string. For lists (SELECT), the value contains of a selected index, followed by a colon character and the text selected.

Throws:
Jaxception

onUnload

protected void onUnload()
Override to handle page unloading.


getAllSessionData

public java.util.Map getAllSessionData(boolean getFromCurrentPage)
                                throws Jaxception
Get all data from session so far. If the "getFromCurrentPage" parameter is true, first retrieve current page's data into session, otherwise just returns the data collected so far. This method is only available if auto-session-data is set to true. If getFromCurrentPage is true, this method cannot be called from the constructor (before page loading.)

Throws:
Jaxception

navigate

public void navigate(java.lang.String url)
              throws Jaxception
Navigate to a given URL.

Throws:
Jaxception

goBack

public void goBack()
            throws Jaxception
Navigate back.

Throws:
Jaxception

goForward

public void goForward()
               throws Jaxception
Navigate forward.

Throws:
Jaxception

execJavaScriptCode

public void execJavaScriptCode(java.lang.String code,
                               boolean argsAsArray,
                               java.lang.Object[] args)
                        throws Jaxception
Call JavaScript, do not wait for results.

The arguments array can contain Strings, Integers, Doubles, Strings, Boolean, Integers, Jaxcent HTML Elements, or it can be null. If the argument array is not null, the "code" is just a JavaScript function name, and must not contain the parentheses character. In this case, the characters "( )" containing any arguments are appended to the "code". The array specifies the list of parameters. If the argument array is null, the "code" is evaluated as is, as an expression. To call a function with no args, use the form execJavaScriptCode( "myFunction()", null, false );

If the "argsAsArray" argument is true, the JavaScript function will be called with a single argument, which will be an array. Otherwise, the "args" array will be used as a list of arguments.

Throws:
Jaxception

evalJavaScriptCode

public java.lang.String evalJavaScriptCode(java.lang.String code,
                                           boolean argsAsArray,
                                           java.lang.Object[] args)
                                    throws Jaxception
same as execJavaScriptCode, but waits for the result of the evaluation and returns it.

Throws:
Jaxception

onJavaScriptRequest

protected void onJavaScriptRequest(java.lang.String cmd,
                                   java.lang.String[] args)
Override to process data from JavaScript methods sent by calling the "JaxcentServerRequest( args... );" function defined by the Jaxcent JavaScript file.

The JavaScript call is asynchronous and does not wait for server response -- if it is required to process a server response in JavaScript, define a function in JavaScript and call that function via execJavaScriptCode or evalJavaScriptCode, from your override of this method.

If JaxcentServerRequest was called at the client with no arguments, this method is called with null args. If JaxcentServerRequest was called with 1 arg, this method is passed that arg as "cmd", the "args" is null. Otherwise, "cmd" is the first arg passed to JaxcentServerRequest, and "args" contains the rest of the args.


setStatusText

public void setStatusText(java.lang.String text)
                   throws Jaxception
Set status text.

Throws:
Jaxception

getStatusText

public java.lang.String getStatusText()
                               throws Jaxception
Get status text.

Throws:
Jaxception

getScreenSize

public java.awt.Dimension getScreenSize()
                                 throws Jaxception
Get screen dimensions

Throws:
Jaxception

getWindowSize

public java.awt.Dimension getWindowSize()
                                 throws Jaxception
Get window dimensions

Throws:
Jaxception

getCurrentPath

public java.lang.String getCurrentPath()
Get the path of the URL that is being processed.


getRemoteAddr

public java.lang.String getRemoteAddr()
Get the client IP address.


getLocale

public java.util.Locale getLocale()
Get the remote locale if specified in HTTP Accept-Language header. (If not specified, returns server's default locale.)


getLocales

public java.util.Locale[] getLocales()
Get a list of remote locales if specified in HTTP Accept-Language header. The most preferred locale is first, followed by other locales in order of preference. (If none specified, returns server's default locale.)


showMessageDialog

public void showMessageDialog(java.lang.String message)
Show JavaScript alert dialog box to the user.


showConfirmDialog

public boolean showConfirmDialog(java.lang.String message)
                          throws Jaxception
Show JavaScript confirm dialog box to the user. Returns true for confirmation, false for cancellation.

Throws:
Jaxception

showInputDialog

public java.lang.String showInputDialog(java.lang.String prompt,
                                        java.lang.String defaultResult)
                                 throws Jaxception
Show JavaScript prompt dialog box to the user. If the defaultResult is not null, the input dialog is initialized with this text. If the user cancels, the returned value is null, otherwise it is the input from user.

Throws:
Jaxception

getCookies

public java.util.Map getCookies()
                         throws Jaxception
Get cookies from page as name->value pairs.

Throws:
Jaxception

getCookie

public java.lang.String getCookie(java.lang.String cookieName)
                           throws Jaxception
Get cookie value.

Throws:
Jaxception

setCookie

public void setCookie(java.lang.String cookieString)
Add cookie to page. cookieString must be a correctly formatted cookie string.


setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value,
                      java.util.Date expires,
                      java.lang.String domain,
                      java.lang.String path,
                      boolean isSecure)
               throws Jaxception
Add cookie to page. Expires, domain, path may be null.

Throws:
Jaxception

deleteCookie

public void deleteCookie(java.lang.String cookieName)
Delete cookie.


deleteTableRow

public void deleteTableRow(java.lang.String id)
Delete a table row (TR) referenced by an ID.


deleteTableCell

public void deleteTableCell(java.lang.String id)
Delete a table cell (TD) referenced by an ID.


deleteSelectOption

public void deleteSelectOption(java.lang.String id)
Delete a SELECT OPTION referenced by an ID.


checkElementExists

public boolean checkElementExists(SearchType searchType,
                                  java.lang.String searchString,
                                  int searchIndex)
                           throws Jaxception
Check if an element exists, without attempting to assign it to an object.

Throws:
Jaxception

setBatchUpdates

public void setBatchUpdates(boolean batchUpdates)
Used to hold updates without sending them out to the client. This can improve performance by sending out a number of updates all at once.

If batch-updates has been set to true, no further data will be sent to the client until batch-updates is reset to false! This should be done in a try-finally clause.