|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provider
defines the interface for
implementing the provider component of a channel.
Desktop channels consist of two major pieces; a provider object
and its runtime configuration.
A provider is the programmatic entity responsible for generating
channels on the desktop. There is not necessarily a one-to-one mapping
between providers and channels; a single provider can generate one or
more channels depending on how it is configured.
A provider must implement this interface. Clients of the provider interface call these methods to query information about or to cause an action in the provider. Such clients include but are not limited to the Desktop servlet and other channels (container channels).
There are essentially two types of methods in this interface;
HttpServletRequest
HttpServletResponse
If these methods are called, an UnsupportedOperationException is thrown.
Method Summary | |
StringBuffer |
getContent(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Gets the provider's objects default view. |
StringBuffer |
getContent(Map m)
Deprecated. Using this method has negative performance implications. Use getContent(HttpServletRequest, HttpServletResponse) instead. |
String |
getDescription()
Gets the description of this provider. |
StringBuffer |
getEdit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Gets the edit view for the provider. |
StringBuffer |
getEdit(Map m)
Deprecated. Using this method has negative performance implications. Use getEdit(HttpServletRequest, HttpServletResponse) instead. |
int |
getEditType()
Gets the edit form type of the provider. |
URL |
getHelp(javax.servlet.http.HttpServletRequest req)
Gets the help URL for this provider. |
String |
getName()
Gets the name of this provider. |
long |
getRefreshTime()
Gets the refresh time for this provider, in seconds. |
String |
getTitle()
Gets the title of this provider. |
int |
getWidth()
Gets the width of this provider. |
void |
init(String name,
javax.servlet.http.HttpServletRequest req)
Initializes the provider. |
boolean |
isEditable()
This method determines if the provider has an edit view. |
boolean |
isPresentable()
Determines if the provider is presentable based on the client device type. |
URL |
processEdit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Processes a form for this provider. |
URL |
processEdit(Map m)
Deprecated. Using this method has negative performance implications. Use processEdit(HttpServletRequest, HttpServletResponse) instead. |
Method Detail |
public void init(String name, javax.servlet.http.HttpServletRequest req) throws ProviderException
This method must be called by clients of the provider object when the provider object is created (after it is constructed, or before the object is used). This method should not be called more than once per object.
name
- Unique name identifying this provider. This value
should always be returned from getName()
.req
- The HTTP request object corresponding to the HTTP request
that caused this provider object to be created. This request may be
used to extract session or user information that could be used to
gain access to external resources.ProviderException
- If there was an error initializing the
provider. How this exception is handled is up to the client of the
provider object.getName()
public StringBuffer getContent(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws ProviderException
This method may return null if the provider does not implement a default view. In this case, the provider should return false from its isPresentable() method.
request
- An HttpServletRequest that contains
information related to this request for content.response
- An HttpServletResponse that allows the provider
to influence the
overall response for the desktop page (besides generating the content).ProviderException
- If there was an error generating the
content. How this exception is handled is up to the client of the
provider object.ProviderException
public StringBuffer getContent(Map m) throws ProviderException
The adapters for the Provider class (ProfileProviderAdapter and ProviderAdapter) call this method by default from the other getContent method. This method preserves backward compatibility for older providers and it offers a simpler interface than the one that passes in the request and response.
m
- A key-value mapping of HTTP parameters passed to the desktop
by the requesting browser.ProviderException
- If there was an error generating the
content. how this exception is handled is up to the client of the
provider object.ProviderException
public StringBuffer getEdit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws ProviderException
This method is called by the clients of the provider object to request the provider's edit view.
This method must generate either a complete document, or a subset,
depending on the return value of .getEditType()
.
A subset document should include all code that goes between
the FORM
tags. The exception is that the
submit and cancel buttons should not be
generated. A subset document is always submitted back to the
desktop servlet, where control is passed to the provider's
processEdit()
method for processing the
form data.
If a complete document is returned, there are several restrictions:
The above restrictions only apply if the form is to be submitted to the desktop servlet. If the form is submitted to a third-party CGI or servlet, the format will depend on what this entity is expecting.
This method may return null if the provider does not implement an edit view. In this case, the provider should return false from its isEditable() method.
request
- An HttpServletRequest that
contains information related to this request for content.response
- An HttpServletResponse that
allows the provider to influence the
overall response for the desktop page (besides generating the content).ProviderException
- If there was an error generating the
edit form. How this exception is handled is up to the client of the
provider object.getContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
isEditable()
,
processEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
getEditType()
,
DesktopServlet
,
ProviderException
public StringBuffer getEdit(Map m) throws ProviderException
The adapters for the Provider class (ProfileProviderAdapter and ProviderAdapter) call this method by default from the other getEdit() method. This method preserves backward compatibility for older providers and it offers a simpler interface than the one that passes in the request and response.
m
- A key-value mapping of HTTP parameters passed to the desktop
by the requesting browser.ProviderException
- If there was an error generating the
edit form. How this exception is handled is up to the client of the
provider object.public int getEditType() throws UnknownEditTypeException
This method returns, and therefore defines, the edit form type for provider.
EDIT_SUBSET
or
EDIT_COMPLETE
UnknownEditTypeException
- If an unknown or undefined
edit type is encountered.getEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
ProviderEditTypes
public URL processEdit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws ProviderException
This method is called to process form data associated with the provider. Typically, this method is called to process the edit page generated from the getEdit() method. Usually, the client calling this method on a provider object is the desktop servlet.
Form data, passed into this method in the request, has been decoded into Unicode.
When the desktop servlet receives a request where the action is "process", it looks at the parameters to identify which provider will handle the action, through this method. The request passed in contains the parameters.
After calling this method, the desktop servlet will re-direct to the URL
returned from this method. Therefore, the result of a provider post
can be any desktop serlvet action, or the content of an arbitrary URL.
For more information on constructing desktop serlvet URLs, see
DesktopSerlvet
.
request
- An HttpServletRequest that contains
information related to this
request for content.response
- An HttpServletResponse that allows the
provider to influence the
overall response for the desktop page (besides generating the content).ProviderException
- If there was an error processing
the edit form. How this exception is handled is up to the client of the
provider object.getEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
isEditable()
,
InvalidEditFormDataException
,
DesktopServlet
public URL processEdit(Map m) throws ProviderException
The adapters for the Provider class (ProfileProviderAdapter and ProviderAdapter) call this method by default from the other processEdit method. This method preserves backward compatibility for older providers and it offers a simpler interface than the one that passes in the request and response.
m
- A key-value mapping of HTTP parameters passed to the desktop
by the requesting browser
as returned by the ServletRequest.parsePostData() method.
Maps string keys to an array of strings values.
For example, to access a parameter named "foo" in the map,
do the following:
String bob = (String[])m.get("foo")[0];
getEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
isEditable()
,
InvalidEditFormDataException
,
DesktopServlet
public boolean isEditable() throws ProviderException
true
or false
, indicating if the
provider has an edit view.getEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
processEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public boolean isPresentable()
true
or false
, indicating if the
provider is presentable to the user's client device.public String getTitle() throws ProviderException
public String getName()
The name returned from this method must match the name of the provider that it was initialized with.
public String getDescription() throws ProviderException
init(java.lang.String, javax.servlet.http.HttpServletRequest)
public URL getHelp(javax.servlet.http.HttpServletRequest req) throws ProviderException
The returned help URL can be either fully-qualified URL string or a relative path. When it is relative path, the desktop software will prepend the server request string, plus the document root, plus the user locale to it to resolve the full URL.
public long getRefreshTime() throws ProviderException
Clients of the provider object should use this value to determine
if they should fetch a fresh default view for the provider.
If the return value from this method is X, they may choose to
not fetch fresh content (and use a cached copy instead) if less than
X seconds has elapsed since the last time content was fetched.
If provider content is expected to change very infrequently, this method can return some value so that the provider's content is not fetched every time the front page is drawn, thereby saving significant processing time.
Clients may choose not to use this value.
public int getWidth() throws ProviderException
Clients of the provider object may call this method, allowing the channel to suggest how much / what type of screen real estate it requires. The return value of this method is only a suggestion, clients are free to interpret the return value or ignore it all together.
WIDTH_THICK
or WIDTH_THIN
or WIDTH_FULL_TOP
or WIDTH_FULL_BOTTOM
.ProviderException
- When there was an exception getting the widthProviderWidths.WIDTH_THIN
,
ProviderWidths.WIDTH_THICK
,
ProviderWidths.WIDTH_FULL_TOP
,
ProviderWidths.WIDTH_FULL_BOTTOM
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |