我想了解這個論壇是如何實現引數傳遞????
<%@ 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檔案接受這個引數????
<%@ 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檔案接受這個引數????
相關文章
- 引數傳遞方式必須是const引用傳遞
- drf serializer 字首 get 是什麼? 如何傳遞引數?
- 引數傳遞
- 面試官問:Go 中的引數傳遞是值傳遞還是引用傳遞?面試Go
- Go語言引數傳遞是傳值?還是傳引用 ?Go
- GridView傳遞兩個引數的方法View
- Mybatis引數傳遞MyBatis
- go語言引數傳遞到底是傳值還是傳引用Go
- vue + axios 實現分頁引數傳遞,高階搜尋功能實現VueiOS
- 路由元件傳遞引數路由元件
- React事件傳遞引數React事件
- go 呼叫 shell 指令碼 如何傳遞引數Go指令碼
- ArgoWorkflow教程(六)---無縫實現步驟間引數傳遞Go
- JS的方法引數傳遞(按值傳遞)JS
- 引數的定義和引數的傳遞
- t-on-click 傳遞引數
- 請求引數的傳遞
- Shell學習【引數傳遞】
- linux中main引數傳遞LinuxAI
- 利用閉包傳遞引數
- JavaScript函式傳遞引數JavaScript函式
- out,ref,params引數傳遞
- 函式的引數傳遞函式
- 如何計算PHP函式中傳遞的引數數量PHP函式
- JAVA基礎之-引數傳遞Java
- Python怎麼傳遞不定引數Python
- 函式引數傳遞及返回函式
- C++引數的傳遞方式C++
- [Python] 傳遞引數前面的*或**Python
- 引數傳遞機制之JWTJWT
- 函式作為引數傳遞函式
- Java方法04:命令列傳遞引數、可變引數Java命令列
- dialog如何向其href指定的頁面傳遞引數?
- 從Function.length 與 Argument.length 區別談到如何傳遞任意個數引數Function
- Python的函式引數傳遞:傳值?引用?Python函式
- HttpRunner3的變數是如何傳遞的HTTP變數
- [思] 當需要傳遞多個不定引數時,該如何設計 JavaScript 函式?JavaScript函式
- mybatis 的傳入引數如何既有物件又有單個引數MyBatis物件
- Mybatis引數傳遞&註解開發MyBatis