我想了解這個論壇是如何實現引數傳遞????

xinxin發表於2003-01-18
<%@ page contentType="text/html;charset=ISO8859_1" %>
<%@ page import="java.util.*,
com.jivesoftware.forum.*,
com.jivesoftware.forum.util.*" %>

<%@ include file="global.jsp" %>

<%! // Global variables, methods, etc

// Permission presets
static final int USE_GLOBAL_PERMS = 1;
static final int ALL_ACCESS = 2;
static final int USERS_ONLY = 3;
static final int USERS_AND_ANON_READ = 4;

static final int DEFAULT_PERM_PRESET = USE_GLOBAL_PERMS;

static final int[] PERM_PRESETS = {
USE_GLOBAL_PERMS,
USERS_ONLY,
USERS_AND_ANON_READ,
ALL_ACCESS
};

static final String[][] PERM_PRESET_INFO = {
{"使用全域性許可權","對此論壇使用全域性許可權設定。"},
{"註冊使用者","只有註冊使用者可以閱讀和發表訊息。"},
{"註冊使用者,來客可讀","來客只能閱讀,註冊使用者可以閱讀和釋出訊息。"},
{"無限制","任何人都可以閱讀和釋出訊息。"}
};
%>

<% // Get parameters
String submitButton = ParamUtils.getParameter(request,"submitButton");
boolean doCreate = ParamUtils.getBooleanParameter(request,"doCreate");
String name = ParamUtils.getParameter(request,"name");
String description = ParamUtils.getParameter(request,"description");
int permPreset = ParamUtils.getIntParameter(request,"permPreset",DEFAULT_PERM_PRESET);
// Remove the forum in the session (if we come to this page, the sidebar
// shouldn't show the specific forum options).
session.removeAttribute("admin.sidebar.forums.currentForum");

// Cancel, if requested
if ("取消".equals(submitButton)) {
response.sendRedirect("forums.jsp");
return;
}

// Check for errors
boolean errors = false;
if (doCreate) {
if (name == null) {
errors = true;
}
}
if (doCreate && !errors)
{
Forum forum = forumFactory.createForum(name, description);
PermissionsManager permManager = forum.getPermissionsManager();

switch (permPreset)
{
case USE_GLOBAL_PERMS:break;
case USERS_ONLY:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
break;
case USERS_AND_ANON_READ:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
permManager.addAnonymousUserPermission(ForumPermissions.READ);
break;
case ALL_ACCESS:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
permManager.addAnonymousUserPermission(ForumPermissions.READ);
permManager.addAnonymousUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addAnonymousUserPermission(ForumPermissions.CREATE_MESSAGE);
break;
default:
}

// redirect back to the forums page
response.sendRedirect("forums.jsp");
return;
}
%>

<% // special onload command to load the sidebar
onload = " onload=\"parent.frames['sidebar'].location.href='sidebar.jsp?sidebar=forum';\"";
%>
<%@ include file="header.jsp" %>

<p>

<% // Title of this page and breadcrumbs
String title = "建立新論壇";
String[][] breadcrumbs = {
{"主頁面", "main.jsp"},
{"論壇", "forums.jsp"},
{title, "createForum.jsp"}
};
%>
<%@ include file="title.jsp" %>

<font size="-1">
注意:這將建立一個沒有許可權的論壇。建立完成後,你將被帶到論壇許可權設定頁面。
</font>

<p>

<% // error messages
if(errors) {
%>
<font color="<%= errorColor %>" size="-1">
論壇建立錯誤。請確認你輸入了論壇名!
</font>
<p>
<% } %>

<form action="createForum.jsp" method="post" name="createForm">
<input type="hidden" name="doCreate" value="true">

<font size="-1"><b>論壇名</b></font>
<ul>
<input type="text" name="name" size="40" maxlength="100" value="<%= (name!=null)?name:"" %>">
</ul>

<font size="-1"><b>論壇描述</b> (可選)</font>
<ul>
<textarea name="description" cols="40" rows="5" wrap="virtual"><%= (description!=null)?description:"" %></textarea>
</ul>

<font size="-1"><b>論壇許可權先期設定</b></font>
<ul>
<font size="-1">
要獲得更好的許可權控制(包括使用者組設定),請檢視許可權設定頁面。
<p>
</font>
<table cellpadding="3" cellspacing="0" border="0">
<% for (int i=0; i<PERM_PRESETS.length; i++) {
String checked = "";
if (PERM_PRESETS == permPreset) {
checked = " checked";
}
%>
<tr>
<td valign="top"><input type="radio" name="permPreset" value="<%= PERM_PRESETS %>" id="rb<%= i %>"<%= checked %>></td>
<td><font size="-1"><label for="rb<%= i %>">
<b><%= PERM_PRESET_INFO[0] %></b>
--
<%= PERM_PRESET_INFO[1] %>
</label></font>
</td>
</tr>
<% } %>
</table>
</ul>

<input type="submit" name="submitButton" value="建立論壇">
<input type="submit" name="submitButton" value="取消">
</form>

<script language="JavaScript" type="text/javascript">
<!--
document.createForm.name.focus();
//-->
</script>

<%@ include file="footer.jsp" %>



*************ForumFactory.java***************

package com.jivesoftware.forum;

import java.lang.reflect.*;
import java.util.*;

public abstract class ForumFactory
{
private static Object initLock = new Object();
private static String className = "com.jivesoftware.forum.database.DbForumFactory";
private static ForumFactory factory = null;

public static ForumFactory getInstance(Authorization authorization)
{

if (authorization == null)
{
return null;
}
if (factory == null)
{
synchronized(initLock)
{
if (factory == null)
{
String classNameProp =
JiveGlobals.getJiveProperty("ForumFactory.className");
if (classNameProp != null)
{
className = classNameProp;
}
try
{
Class c = Class.forName(className);
factory = (ForumFactory)c.newInstance();
}
catch (Exception e)
{
System.err.println("Failed to load ForumFactory class "
+ className + ". Jive cannot function normally.");
e.printStackTrace();
return null;
}
}
}
}
//Now, create a forum factory proxy.
return new ForumFactoryProxy(authorization, factory,
factory.getPermissions(authorization));
}


public abstract Forum createForum(String name, String description)
throws UnauthorizedException, ForumAlreadyExistsException;

public abstract ForumThread createThread(ForumMessage rootMessage) throws
UnauthorizedException;


public abstract ForumMessage createMessage();


public abstract ForumMessage createMessage(User user)
throws UnauthorizedException;


public abstract Forum getForum(long forumID)
throws ForumNotFoundException, UnauthorizedException;

public abstract Forum getForum(String name)
throws ForumNotFoundException, UnauthorizedException;


public abstract int getForumCount();


public abstract Iterator forums();


public abstract Query createQuery();


public abstract Query createQuery(Forum [] forums);


public abstract Iterator popularForums();

public abstract Iterator popularThreads();

public abstract void deleteForum(Forum forum)
throws UnauthorizedException;

public abstract void mergeForums(Forum forum1, Forum forum2)
throws UnauthorizedException;

public abstract UserManager getUserManager();

public abstract GroupManager getGroupManager();

public abstract SearchManager getSearchManager()
throws UnauthorizedException;


public abstract FilterManager getFilterManager();


public abstract WatchManager getWatchManager();

public abstract RewardManager getRewardManager();

public abstract PermissionsManager getPermissionsManager()
throws UnauthorizedException;

public abstract ForumMessageFilter [] getAvailableFilters()
throws UnauthorizedException;

public abstract void addFilterClass(String className)
throws UnauthorizedException, ClassNotFoundException,
IllegalArgumentException;

public abstract ForumPermissions getPermissions(Authorization authorization);


public abstract boolean hasPermission(int type);
}


***************介面Form****************

package com.jivesoftware.forum;

import java.util.Date;
import java.util.Iterator;
import java.util.Enumeration;

public interface Forum
{

public long getID();

public String getName();

public void setName(String name) throws UnauthorizedException,ForumAlreadyExistsException;

public String getDescription();

public void setDescription(String description) throws UnauthorizedException;

public Date getCreationDate();

public void setCreationDate(Date creationDate) throws UnauthorizedException;

public Date getModifiedDate();

public void setModifiedDate(Date modifiedDate) throws UnauthorizedException;

public int getModerationDefaultThreadValue();

public void setModerationDefaultThreadValue(int value) throws UnauthorizedException;

public int getModerationDefaultMessageValue();

public void setModerationDefaultMessageValue(int value) throws UnauthorizedException;

public int getModerationMinThreadValue();

public void setModerationMinThreadValue(int value) throws UnauthorizedException;

public int getModerationMinMessageValue();

public void setModerationMinMessageValue(int value) throws UnauthorizedException;



public String getProperty(String name);


public void setProperty(String name, String value) throws UnauthorizedException;


public void deleteProperty(String name) throws UnauthorizedException;


public Iterator propertyNames();


public ForumThread getThread(long threadID) throws ForumThreadNotFoundException;


public void addThread(ForumThread thread) throws UnauthorizedException;


public void deleteThread(ForumThread thread) throws UnauthorizedException;


public void moveThread(ForumThread thread, Forum newForum)throws UnauthorizedException, IllegalArgumentException;


public ForumThreadIterator threads();


public ForumThreadIterator threads(ResultFilter resultFilter);


public Iterator popularThreads();


public Iterator messages();


public Iterator messages(ResultFilter resultFilter);

public int getThreadCount();


public int getThreadCount(ResultFilter resultFilter);


public int getMessageCount();


public int getMessageCount(ResultFilter resultFilter);


public Query createQuery();


public FilterManager getFilterManager();


public PermissionsManager getPermissionsManager()throws UnauthorizedException;


public abstract ForumPermissions getPermissions(Authorization authorization);


public boolean hasPermission(int type);
}

請問在在*.JSP中
Forum forum = forumFactory.createForum(name, description);
PermissionsManager permManager = forum.getPermissionsManager();
是如何把引數(name,description)傳遞具體的又是那個*.class檔案接受這個引數????

相關文章