|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.shr.page.AgpPage
Dynamically generated HTML page or subpage. Subpages have a smaller set of properties than pages. All the methods of AgpPage apply both to top-level pages and to subpages contained within another page.
Every page has these instance variables built-in:
agData
- an instance of the AgpDataPrimary
class that
binds the page to a primary dataset.
agDataMgr
- an instance of the AgoBindingManager
class that manages data binding and enables searching the data.
agScriptHelper
- an instance of the AgpScriptHelper
class that
performs common JavaScript functions.
Field Summary | |
static int |
MISMATCH_GET
Return this value from handleStateMismatch() to indicate that an out-of-sync request should be handled as a GET. |
static int |
MISMATCH_POST
Return this value from handleStateMismatch() to indicate that an out-of-sync request should be handled as a POST. |
Constructor Summary | |
AgpPage()
|
Method Summary | |
static String |
fullUrlForPage(String dbname,
String pageurl)
Returns a server-relative URL given a database name and a page specifier. |
AgpTag |
getBodyTag()
Returns the BODY tag. |
String |
getCharEncoding()
Returns the name of the character encoding scheme used by the page. |
AgiPageControl |
getControl(String name)
Returns the control, as a Java object, whose Java name is given. |
AgiPageControl[] |
getControls()
Returns an array of all the controls on a page. |
String |
getControlURL(String namespace)
This method is for use in writing page controls. |
AgiHttpServletRequest |
getCurrentRequest()
Provides access to the current request. |
AgiHttpServletResponse |
getCurrentResponse()
Provides access to the response object for this request. |
String |
getDatabase()
Returns the name of the database containing the page. |
URL |
getDatabaseURL()
Returns an URL pointing to the database that contains the page. |
boolean |
getEmbedHTMLInTable()
Returns true if the subpage or HTML control should be embedded in a table. |
boolean |
getEnableGenerateScript()
Returns true if generation of JavaScript is enabled. |
boolean |
getEnableHistoryFixup()
Returns true if history fixup is enabled. |
boolean |
getEnableHTMLGeneration()
Returns whether HTML generation is enabled for this page. |
String |
getFormDataCharEncoding()
Determine the encoding the server should expect from the browser for URL-encoded form data. |
AgpTag |
getFormTag()
Returns the FORM tag if this page or a parent page defines a form processing tag. |
AgpFrame |
getFrame(String name)
Returns the named frame control. |
AgpTag |
getHeadTag()
Returns the HEAD tag. |
long |
getLastModified()
Returns the last modified date as a long . |
Locale |
getLocale()
Returns the locale for the client system |
AgpPage |
getPage(String pageurl)
Returns a page from the user session. |
URL |
getPageURL()
Returns an URL that can be used to access this page. |
URL |
getPageURL(String pageSpec)
Returns an URL representing the specified page. |
URL |
getPageURL(String pagespec,
String query,
String orderby,
Hashtable params)
Returns an URL representing the specified page, using optional query, orderby, freeform parameters. |
AgpPage |
getParentPage()
Returns the containing page if this page is used as a subpage. |
String |
getPath()
Returns the server relative path of the page. |
Object |
getProperty(String name)
Returns the specified page property. |
Object |
getSessionValue(String name)
Retrieves a named value which has previously been stored in the session. |
AgpTag |
getTag(String name)
Returns the named AgpTag object. |
String |
getTimeZoneID()
Returns the server setting that keeps track of the client time zone |
boolean |
getUrlQueryMode()
Determine whether the 'query' and 'order-by' parameters of the request URL are processed automatically by the page. |
boolean |
getUseMultipartFormData()
Determine whether the page is set to request MIME multipart/form-data from the browser. |
String |
getUser()
Gets the name of the current user. |
String |
getUserAgent()
Returns the user agent string, obtained from the "user-agent" header of the HTTP request. |
int |
handleStateMismatch()
handleStateMismatch() can be overridden to change the way that the page handles out-of-sync POST requests, which may occur if the end user navigates through the browser history, or if the server restarts between a user's requests to a page. |
boolean |
hasServicedRequest()
Returns true if the page has serviced the request. |
void |
removePage(String pageurl)
Removes a page from the user session. |
void |
removeSessionValue(String name)
Removes a value from the user's session object. |
void |
setCharEncoding(String encoding)
Sets the character encoding. |
void |
setEmbedHTMLInTable(boolean embed)
Specifies whether the subpage or HTML control should be embedded in a table. |
void |
setEnableGenerateScript(boolean scriptenable)
Specifies whether script generation is enabled. |
void |
setEnableHistoryFixup(boolean flag)
Specifies the flag which indicates fixup of the browser history through JavaScript. |
void |
setEnableHTMLGeneration(boolean enable)
Specifies whether HTML generation should be enabled. |
void |
setFormDataCharEncoding(String encoding)
Specify the encoding the server should expect from the browser for URL-encoded form data. |
void |
setLocale(Locale locale)
Sets a server variable that keeps track of the locale for the client system |
void |
setProperty(String name,
Object obj)
Sets the specified page property. |
void |
setSessionValue(String name,
Object value)
Sets a value in the user's session object. |
void |
setTimeZoneID(String zoneStr)
Sets a server variable that keeps track of the time zone for the client system |
void |
setUrlQueryMode(boolean enable)
Specify whether the 'query' and 'order-by' parameters of the request URL are handled by the page. |
void |
setUseMultipartFormData(boolean use)
Tells the page to specify whether data POSTed from the browser should be encoded using MIME multipart/form-data. |
boolean |
showPage(String pageSpec)
Redirects the most recent request for this page to a different URL. |
boolean |
showPage(String pageSpec,
String query,
String orderby)
Redirects the most recent request for this page to a different URL. |
boolean |
showPage(String pageSpec,
String query,
String orderby,
Hashtable params)
Redirects the most recent request for this page to a different URL. |
boolean |
userInGroup(String groupName)
Tests whether the current user is in the specified group |
void |
writeScript(String javascript)
Adds the JavaScript to the current response. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Methods implemented from interface com.sssw.rt.util.AgiInvokeBusinessObject |
invokeBusinessObject,
invokeBusinessObject |
Methods implemented from interface com.sssw.shr.page.AgiPageControl |
generateHTML,
getPrefix,
notifyPageLoaded,
notifyPageRequestBegin,
notifyPageRequestEnd,
notifyPostValue,
notifyPostValues |
Methods implemented from interface java.util.Comparator |
compare |
Methods implemented from interface javax.servlet.Servlet |
destroy,
getServletConfig,
getServletInfo,
init,
service |
Field Detail |
public static int MISMATCH_GET
public static int MISMATCH_POST
Constructor Detail |
public AgpPage()
Method Detail |
public long getLastModified()
long
. This value represents
the difference, measured in milliseconds, between the time of the last modification and midnight, January 1, 1970 UTC.
The Java classes Java.util.Date
and Java.util.DateFormat
can
be used to interpret and manipulate this value.// Display the last-mod date of this page in a label long lastMod = getLastModified(); if (lastmod == -1) lastmodLabel.setText("Modification date not available"); else { Java.util.Date lastModDate(lastMod); String lastModString = DateFormat.getDateInstance().format(lastModDate); lastmodLabel.setText(lastModString); }
public AgiHttpServletRequest getCurrentRequest()
null
.// determine whether the page is processing a "GET" or a "POST" if (getCurrentRequest().getMethod().equals("GET")) { // ... process GET ... } else if (getCurrentRequest().getMethod().equals("POST")) { // ... process POST ... } // see if the current request includes one or more values for the "initialValues" parameter String [] initialValues; initialValues = getCurrentRequest().getParameterValues("initialValues"); if (initialValues != null) { for (int i = 0; i < initialValues.length; i++) { // ...process each initial value... } }
AgiHttpServletRequest
,
AgpPage.getCurrentResponse()
public AgiHttpServletResponse getCurrentResponse()
AgiHttpServletResponse resp = getCurrentResponse(); resp.setError(403); // status code for "forbidden"
AgiHttpServletResponse
,
AgpPage.getCurrentRequest()
public Object getSessionValue(String name)
name
- the name of the desired value// if the user has entered a name in a previous step, initialize the // "Author" text field with it. Object prevValue = getSessionValue("UserName"); if (prevValue != null) { txtAuthor.setText((String)prevValue); }
AgpPage.removeSessionValue(String name)
,
AgpPage.setSessionValue(String name, Object value)
public void setSessionValue(String name, Object value)
name
- name of the object value.value
- object value.AgpPage.getSessionValue(String name)
,
AgpPage.removeSessionValue(String name)
public void removeSessionValue(String name)
getSessionValue()
will return null.name
- The name of the object value.AgpPage.getSessionValue(String name)
,
AgpPage.setSessionValue(String name, Object value)
public boolean getUrlQueryMode()
true
.if (getUrlQueryMode() == false) { Label1.setText("Automatic query processing disabled"); }
AgpPage.setUrlQueryMode(boolean enable)
public void setUrlQueryMode(boolean enable)
enable
- true
if the 'query' and 'order-by' parameters
should be handled by the page, otherwise false
.AgpPage.getUrlQueryMode()
public String getDatabase()
String dbName = getDatabase(); Label1.setText(dbName);
public URL getDatabaseURL()
For example, this method might return:
"http://MyServer/MyDatabase/"
String dbURL = getDatabaseURL().toString(); // Set up Label1 as a link pointing to the database directory Label1.setType(AgpLabel.EXPRESSION_LINK); Label1.setText("Database directory"); Label1.setLinkTarget(dbURL);
public String getPath()
String pagePath = getPath();
public boolean getEnableHTMLGeneration()
// If we're not showing the first subpage, don't show the second one either if (!Subpage1.getEnableHTMLGeneration()) Subpage2.setEnableHTMLGeneration(false);
AgpPage.setEnableHTMLGeneration(boolean enable)
public void setEnableHTMLGeneration(boolean enable)
enable
- true
to enable
HTML generation, otherwise false
AgpPage.getEnableHTMLGeneration()
public boolean getEnableHistoryFixup()
true
if history fixup is enabled. The default value is false
.
History fixup requires JavaScript, so it will not work in all browsers.
If an end user is viewing a page that has history fixup enabled, pressing the browser's Back button will return the user to the page that was viewed before the current page, regardless of how many POSTs have been made to the current page. If history fixup is not enabled, the Back button causes an error.
if (getEnableHistoryFixup()) { Label1.setText("Press your browser's BACK button to return to the previous page."); }
AgpPage.setEnableHistoryFixup(boolean flag)
public void setEnableHistoryFixup(boolean flag)
flag
- true
to enable
browser history fixup; otherwise false
.AgpPage.getEnableHistoryFixup()
public void setUseMultipartFormData(boolean use)
use
- Set to "true" to use MIME multipart/form-data.AgpPage.getUseMultipartFormData()
,
AgpPage.setFormDataCharEncoding(String encoding)
,
AgpPage.setCharEncoding(String encoding)
public boolean getUseMultipartFormData()
AgpPage.setUseMultipartFormData(boolean use)
,
AgpPage.getFormDataCharEncoding()
,
AgpPage.setFormDataCharEncoding(String encoding)
,
AgpPage.getCharEncoding()
public AgpTag getFormTag()
The tag returned by this method can be used to set JavaScript on it (dynamically) just like setting any other properties.
AgpPage.getBodyTag()
,
AgpPage.getHeadTag()
public AgpTag getBodyTag()
The AgpTag object that this method returns can be used to set properties for the body of the page. The properties that are attributes of the HTML BODY tag can be set, such as BGCOLOR. JavaScript can also be added to the BODY tag using this object.
// This code could be used in an event handler on a page AgpTag bodyTag = getBodyTag(); bodyTag.setProperty("BGCOLOR", "Red");
AgpTag
,
AgpPage.getFormTag()
,
AgpPage.getHeadTag()
public AgpTag getHeadTag()
Use the tag returned by this method to set JavaScript on it (dynamically) just like setting any other properties.
AgpPage.getBodyTag()
,
AgpPage.getFormTag()
public void setEnableGenerateScript(boolean scriptenable)
scriptenable
- true
if
generation should be enabled; otherwise false
.AgpPage.getEnableGenerateScript()
public boolean getEnableGenerateScript()
true
if generation of JavaScript is enabled. The default value is true
.// put up a warning label if this page uses JavaScript Label1.setType(AgpLabel.EXPRESSION_LINK); if (getEnableGenerateScript()) { Label1.setText("JavaScript version: click here to use HTML-only version"); Label1.setLinkTarget(htmlURL); } else { Label1.setText("HTML-only version: click here to use JavaScript version"); Label1.setLinkTarget(javascriptURL); }
AgpPage.setEnableGenerateScript(boolean scriptenable)
public String getCharEncoding()
setCharEncoding()
method.String encodingName = getCharEncoding();
AgpPage.setCharEncoding(String encoding)
,
AgpPage.getFormDataCharEncoding()
,
AgpPage.getUseMultipartFormData()
public void setCharEncoding(String encoding)
encoding
- a string containing the encoding.This method assumes that the converter has the same name.
AgpPage.getCharEncoding()
,
AgpPage.setFormDataCharEncoding(String encoding)
,
AgpPage.setUseMultipartFormData(boolean use)
public void setFormDataCharEncoding(String encoding)
encoding
- The string representing the encoding. For example "iso-8859-1".AgpPage.getFormDataCharEncoding()
,
AgpPage.setUseMultipartFormData(boolean use)
,
AgpPage.setCharEncoding(String encoding)
public String getFormDataCharEncoding()
AgpPage.setFormDataCharEncoding(String encoding)
,
AgpPage.getUseMultipartFormData()
,
AgpPage.getCharEncoding()
public AgpPage getParentPage()
null
if there is no containing page.// If this is a top-level page, show a label for the title if (getParentPage() == null) { lblTitle.setEnableHTMLGeneration(true); } else { lblTitle.setEnableHTMLGeneration(false); }
public AgiPageControl getControl(String name)
name
- the Java name of the desired control.// set the value of a control on a subpage AgiPageControl c = Subpage1.getControl("TitleLabel"); if (c instanceof AgpLabel) { AgpLabel label = (AgpLabel)c; label.setText("Enter detail information here:"); }
AgiPageControl
,
AgpPage.getControls()
public AgpTag getTag(String name)
name
- a string representing the name.
If the named object does not exist, or if the named
object is not a tag, returns null
.
This method is meant to be used for tags that
are not programmable by the WYSIWYG editor but marked
with "_NAME" in the raw HTML editor.
// center-align the paragraph named "HighlightMe". AgpTag paraTag = getTag("HighlightMe"); if (paraTag != null) paraTag.setProperty("ALIGN", "CENTER");
AgpPage.getFrame(String name)
public AgpFrame getFrame(String name)
name
- the name of the desired frame.
If the named object does not exist, or if the named
object is not a frame, returns null
.
This method is very useful to access a frame
object in the frameset page from elsewhere.
AgpPage.getTag(String name)
public AgiPageControl[] getControls()
// Hide any text buttons that appear on a subpage AgiPageControl [] controlArray = Subpage1.getControls(); for (int i = 0; i < controlArray.length; i++) { if (controlArray[i] instanceof AgpButtonText) { AgpButtonText button = (AgpButtonText)controlArray[i]; button.setEnableHTMLGeneration(false); } }
AgpPage.getControl(String name)
public AgpPage getPage(String pageurl) throws AgoApiException
pageurl
- a string containing the URL.The string must be a database relative url if in the same database as the page being called, or DBNAME:database relative url if in another database.
This is an example of retrieving another page in the same database:
AgpPage p = getPage("anotherpage.html");
AgpPage.getPageURL()
public void removePage(String pageurl) throws AgoApiException
public static String fullUrlForPage(String dbname, String pageurl)
dbname
- a string representing the dbname.pageurl
- a string representing the URL.This is a static method.
The database name is ignored if the pageurl includes a database specifier. For example:
fullUrlForPage("mydb", "MyPage")
/mydb/SilverStream/Pages/MyPage
fullUrlForPage("mydb", "XXXX:MyPage")
/XXXX/SilverStream/Pages/MyPage
// two ways to get a server-relative url for the page "foobar.html" in the // database "MyDB" String foobarUrl1 = AgpPage.fullUrlForPage("MyDB", "foobar.html"); String foobarUrl2 = AgpPage.fullUrlForPage(null, "MyDB:foobar.html");
public String getUserAgent()
public boolean showPage(String pageSpec)
pageSpec
- a page-spec for the page This can be:
boolean successful; successful = AgpPage.showPage("index.html");
public boolean showPage(String pageSpec, String query, String orderby)
pageSpec
- a page-spec for the page This can be:
query
- a query to subset the records displayed on the page.orderby
- an orderby clause for the records on the page.boolean successful; successful = AgpPage.showPage("Employees.html", "Employees.salary > 35000", "Employees.lastname asc");
public boolean showPage(String pageSpec, String query, String orderby, Hashtable params)
pageSpec
- a page-spec for the page This can be:
query
- a query to subset the records displayed on the page.orderby
- an orderby clause for the records on the page.params
- a hashtable containing parameters to pass to
the specified page.Hashtable params; params = new Hashtable(); // add useful data to hashtable here boolean successful; successful = AgpPage.showPage("Employees.html", "Employees.salary > 35000", "Employees.lastname asc", params);
public void writeScript(String javascript)
javascript
- a string containing the JavaScript.public Object getProperty(String name)
getProperty
for page controls, this method is not related to generated HTML. Instead it references a hashtable that pages use to store certain information. AgpPage.getProperty()
can be used for communication between parent pages and sub-pages, or between different pages in a session.name
- the name of the property.Note that we allow the derived class to override this method to do custom processing.
//Retrieve some previously stored information Integer custID=getProperty("CustomerID");
AgpPage.setProperty(String name, Object obj)
public void setProperty(String name, Object obj)
AgpPage.setProperty()
can be used for communication between parent pages and sub-pages, or between different pages in a session.name
- the name of the property.obj
- the value.Note that we allow derived class to override this method to do custom processing.
//Store some information for use elsewhere on the page setProperty("CustomerID", newInteger(custID));
AgpPage.getProperty(String name)
public boolean hasServicedRequest()
public boolean getEmbedHTMLInTable()
boolean b = Subpage1.getEmbedHTMLInTable()
AgpPage.setEmbedHTMLInTable(boolean embed)
public void setEmbedHTMLInTable(boolean embed)
embed
- true
to embed the
subpage or HTML control in a table, or
false
to make it "free-flow" into
the text.AgpPage.getEmbedHTMLInTable()
public URL getPageURL()
This is an example of retrieving the URL of the current page:
URL url = getPageURL(); System.out.println("This is the URL of the page: " + url);
AgpPage.getPage(String pageurl)
public URL getPageURL(String pageSpec)
pageSpec
- a page-spec for the page This can be:
A call to getPageURL may return null if the URL cannot be constructed or if the method is called outside the context of a service() request.
AgpPage.getPage(String pageurl)
public URL getPageURL(String pagespec, String query, String orderby, Hashtable params)
pagespec
- a page-spec for the page. This can be:
query
- a query to subset the records displayed on the page.orderby
- an orderby clause for the records on the page.params
- a hashtable containing parameters to pass to the specified page.A call to getPageURL may return null if the URL cannot be constructed or if the method is called outside the context of a service() request.
AgpPage.getPage(String pageurl)
public String getControlURL(String namespace)
public String getUser()
public boolean userInGroup(String groupName)
public int handleStateMismatch() throws AgoException
Sometimes, the end user issues a request that's out-of-sync with the server's page state. This happens when history fixup is turned off, and the user navigates through the browser history, or when the server restarts between user requests to a page. If the user enters information into the page, then submits it, while it is in this out-of-sync state, data may be unexpectedly overwritten in the database table.
The default implementation for handleStateMismatch() returns MISMATCH_GET, which ensures that any input from the user is ignored. You can instruct the server to accept input from the user by returning MISMATCH_POST in your overridden method.
public Locale getLocale()
public void setLocale(Locale locale)
public String getTimeZoneID()
public void setTimeZoneID(String zoneStr)
The server is unable to determine the time zone of the client unless the user provides this information. If the user provides this information, the page can call setTimeZoneID to set the time zone value that will be used to process the client request.
|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |