adapforms.web
Interface WebSession

All Known Implementing Classes:
WebSessionImpl

public interface WebSession

Represents an adaptive form session, coupled to a single adaptive form. The web session is uniquely identified by a GUID, and provides additional web-specific features to the FormInstance.

Use the writeToClient(ServletRequest, ServletResponse) to output the form to the web client.

Not to be confused with a J2EE web sessions.

Author:
Henrik Gammelmark, geemark@cs.au.dk

Method Summary
 java.util.Date createdAt()
          When was this session created?
 void executeScript(java.lang.String scriptFragment)
          Execute a fragment of JavaScript on the web client.
 GUID getGUID()
          The unique identifier of the web session.
 FormInstance getInstance()
          Obtain the instance belonging to the session.
 boolean getRenderTitle()
           
 void redirectClient(java.lang.String url)
          Force the user web browser page containing the form to redirect to the specified URL.
 void setRenderTitle(boolean render)
          Specify whether the title of the document should be rendered to the web client.
 void writeHeadersToClient(javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp)
          Render the required XHTML headers to the web client.
 void writeToClient(javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp)
          Render the instantiated form to the web client.
 

Method Detail

getGUID

GUID getGUID()
The unique identifier of the web session.


getInstance

FormInstance getInstance()
Obtain the instance belonging to the session.


writeToClient

void writeToClient(javax.servlet.ServletRequest req,
                   javax.servlet.ServletResponse resp)
                   throws FormRuntimeException
Render the instantiated form to the web client.

Notice: It is recommended that you call writeHeadersToClient(ServletRequest, ServletResponse) manuelly inside the "head" tag of your document. If not, the call to this method will ourput the headers in the position of the form, which may work but is not valid XHTML.

Parameters:
req - The HTTP servlet request. Used for reading context information.
resp - The HTTP servlet response. Used for outputting the rendered form.
Throws:
FormRuntimeException - If anything goes wrong during the process.

writeHeadersToClient

void writeHeadersToClient(javax.servlet.ServletRequest req,
                          javax.servlet.ServletResponse resp)
                          throws FormRuntimeException
Render the required XHTML headers to the web client.
This provides a means of generating valid XHTML, as these headers should be placed inside the XHTML "head" tag.

Parameters:
req - The HTTP servlet request. Used for reading context information.
resp - The HTTP servlet response. Used for outputting the rendered header
Throws:
FormRuntimeException - If anything goes wrong during the process.

redirectClient

void redirectClient(java.lang.String url)
                    throws FormStateException
Force the user web browser page containing the form to redirect to the specified URL. The web URL may be relative or absolute.

Throws:
FormStateException

executeScript

void executeScript(java.lang.String scriptFragment)
                   throws FormStateException
Execute a fragment of JavaScript on the web client. This may be a function call to an already loaded JavaScript library, or a complete block of JavaScript.

Use with caution: No checks are performed on the parsed script; it is merely attempted executed as is.

Throws:
FormStateException

setRenderTitle

void setRenderTitle(boolean render)
Specify whether the title of the document should be rendered to the web client.


getRenderTitle

boolean getRenderTitle()
See Also:
setRenderTitle(boolean)

createdAt

java.util.Date createdAt()
When was this session created?