|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--org.locomotive.loco.servlet.LocoServlet | +--org.locomotive.module.discuss.DiscussionServlet
This class is the main handler class for The Locomotive Discussion system. The Locomotive Discussion system is a simple three-level web-based conferencing system for hosting non-threaded discussions. This particular class directs the appropriate requests to the appropriate Handlers and provides a number of utility methods for use by those handlers. The templates used for the various URL's handled by this class are listed under the service method.
One config property can be set for this servlet- the number of posts to display on a single list of posts. One does this by setting the num.posts.to.display property in a property file that is loaded at startup for this Servlet. For example, the following line would specify 4 posts per page:
num.posts.to.display = 4
Field Summary | |
protected DiscussionAdminServlet |
admin
|
protected DiscussionLib |
lib
|
int |
numPostsToDisplay
SET THIS TO DETERMINE THE NUMBER OF POSTS TO DISPLAY ON THE PAGE |
Fields inherited from class org.locomotive.loco.servlet.LocoServlet |
conn,
DEBUG,
ERROR,
form_data,
NORMAL,
req,
resp,
session,
steam_vars,
url_tokens,
user,
WARNING |
Constructor Summary | |
DiscussionServlet()
|
Method Summary | |
protected void |
addPost()
This method handles adding a post to a topic. |
protected void |
addTopic()
This method handles adding a topic to a category. |
void |
destroy()
Makes sure the Admin servlet gets destroyed too. |
void |
init(javax.servlet.ServletConfig config)
The required init method, as defined in org.locomotive.loco.Handler. |
protected static void |
insertTemplate(java.lang.String key,
javax.servlet.http.HttpServletResponse resp,
java.util.Hashtable steam_vars)
evaluate a template using the template path from the template hash and flush the template to our response object. |
protected SortableTable |
permPruneCategoriesTable(SortableTable categoriesTable)
Permission prune the categories table, removing the categories for which this user does not have read permission. |
protected SortableTable |
permPruneTopicsTable(SortableTable topicsTable)
|
void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
The main method to call for this Servlet. |
protected void |
showCategory()
This method displays the Discussion cateogory page, which shows a list of the topics in that category. |
protected void |
showDefault()
This method displays the default Discussion Page, which contains a list of categories to choose from along with choices on where to go. |
protected void |
showSummary()
This method shows a summary of posts for a given topic. |
protected void |
showTopic()
This method displays the topic page, which contains a set of the posts for that topic. |
Methods inherited from class org.locomotive.loco.servlet.LocoServlet |
displayPage,
displayString,
handleException,
log,
logEvent,
sayBadURL,
setup |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete,
doGet,
doOptions,
doPost,
doPut,
doTrace,
getLastModified,
service |
Methods inherited from class javax.servlet.GenericServlet |
getInitParameter,
getInitParameterNames,
getServletConfig,
getServletContext,
getServletInfo,
init,
log,
log |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected DiscussionLib lib
protected DiscussionAdminServlet admin
public int numPostsToDisplay
Constructor Detail |
public DiscussionServlet()
Method Detail |
public void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException, javax.servlet.ServletException
Token Method Template CMCAT showCategory() discuss/community/comm_disc.tmpl CMTOP showTopic() discuss/community/comm_disc_topic.tmpl POST addPost() discuss/community/comm_disc_topic.tmpl TOPIC addTopic() discuss/community/comm_disc_topic_new.tmpl SUMMARY showSummary() discuss/community/comm_disc_topic_sum.tmpl Admin see handleAdminHandler() [no token] showDefault() discuss/community/comm_section.tmpl
LocoServlet.setup(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
javax.servlet.http.HttpServlet.html#service
protected void showDefault() throws java.io.IOException
Puts the following subs into the environment:
categories_table SortableTable with columns: id, title, description num_posts_to_display the number of posts to display on the topics page
protected void showCategory() throws java.io.IOException
Puts the following subs into the environment:
navigation the html for the navigation sidebar category_info SortableTable with columns: id, title, description, topic_count, post_count, last_post_date topics_table SortableTable with columns: topicid, communityid, topicname, post_count, last_post_date num_posts_to_display the number of posts to display on the topics page
protected void showTopic() throws java.io.IOException
Community?CMTOP+<topicID>+<numberOfPostsToDisplay>+<postStartNum>where the topicID is the unique topic id number for the topic whose posts the page show display, the postStartNum is the post number to start on, and the numberOfPostsToDisplay is the number of posts to display on the page.
Note that this method displays the posts in descending order, so that a URL of Community?CMTOP+2+10+192 would display posts 183 to 192 from top to bottom on the first page, and the URL of Community?CMTOP+2+10+182 would display posts 173 to 182 from the top to the bottom of the page.
The defaults for these values are the latest post for postStartNum, and 10 for numberOfPostsToDisplay, so the URL Community?CMTOP+2 evaluates to Community?CMTOP+2+10+192, if 192 is the number of the latest post.
This method also inserts into steam_vars an array of urls to all the pages that would be generated to see all the posts for the current topic, at the current numberOfPostsToDisplay token. Thus, the first example above would provide an array of 20 urls which would point to each page needed to display all the posts. Note that The page designer, using the [loop ] expression, can display as many or all of these as he or she would like. See the steam documentation for more on this.
Puts the following subs into the environment:
navigation the html for the navigation sidebar category_info SortableTable with columns: id, title, description, topic_count, post_count, last_post_date topic_info SortableTable with columns: topicid, communityid, topicname, post_count, last_post_date post_table SortableTable with columns: postid, posttitle, postbody, postauthorfn, postauthorln, postemail, postdate post_links Array of strings that provide the links to each page of posts num_posts_to_display the number of posts to display on the topics page
protected void addTopic() throws java.io.IOException
Puts the following subs into the environment:
category_info SortableTable with columns: id, title, description, topic_count, post_count, last_post_date topic_info SortableTable with columns: topicid, communityid, topicname, post_count, last_post_date, error_msg Message if topic could not be added num_posts_to_display the number of posts to display on the topics page
protected void addPost() throws java.io.IOException
Puts the following subs into the environment:
These are added only if there was an error adding the post: error_msg an error explaining why post could not be added post_title title entered for the failed post post_body body entered for the failed post firstname first name entered the for the failed post lastname last name entered for the failed post email email entered for the failed post num_posts_to_display the number of posts to display on the topics page
protected void showSummary() throws java.io.IOException
Community?SUMMARY+<topicID>+<displayOrder>The order token may be either DATE, POST, or AUTHOR. Thus an example summary URL might look like: Community?SUMMARY+174+AUTHOR.
Puts the following subs into the environment:
navigation the html for the navigation sidebar post_summaries SortableTable with columns: postid, posttitle, postauthorfn, postauthorln, postemail, postdate topic_info SortableTable with columns: topicid, communityid, topicname category_info SortableTable with columns: id, title, description, topic_count, post_count, last_post_date post_links an array containing the post numbers to show at the bottom of the topics page when the links for each post are followed num_posts_to_display the number of posts to display on the topics page
protected static void insertTemplate(java.lang.String key, javax.servlet.http.HttpServletResponse resp, java.util.Hashtable steam_vars) throws java.io.IOException
key
- the key to use to get the template path from the hashprotected SortableTable permPruneCategoriesTable(SortableTable categoriesTable)
categoriesTable
- SortableTable containing the categoriesprotected SortableTable permPruneTopicsTable(SortableTable topicsTable)
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
public void destroy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |