Step 1: Install jforum. Check my other article "jforum Open Source Forum installation ".
Step 2: analyze the configuration file in the jforum framework
1. Common Chinese characters displayed on the configuration page in the zh_cn.properties file. Run native2ascii-reverse zh_cn.properties. the Properties command deserializes constants. developers can configure the required page to display constant information, edit and save the information, and then use native2ascii. properties zh_cn.properties is encoded back to ASCII.
2. The modulesmapping. properties file describes the correspondence between the module name and the Java class that implements the module functions.
3. The locales. properties file is configured and loaded in the systemglobals. properties file. The locales. properties file configures languages supported by various countries. The locales. properties file is read in configaction. java.
4. Configure the database query statement in the webapps/jforum/WEB-INF/config/database/generic/generic_queries. SQL file and the SQL file is configured to be loaded in the systemglobals. properties file. The variable information configured in the systemglobals. properties file is configured with the corresponding constant string in the configkeys. Java class file. You can use string q = systemglobals. getsql ("XXX") to obtain the configured SQL statement. I18n. getmessage ("XXX") can be used to obtain the Chinese constants configured in the zh_cn.properties configuration file on the page or in the class.
5. The templatesmapping. properties configuration file corresponds to the page. The variable information configured in the templatesmapping. properties file is configured with the corresponding constant string in the templatekeys. Java class file.
6. The jforum-custom.conf configuration file is a file about the database information, which can be modified manually, which is generated when jforum is installed automatically.
7. The urlpattern. properties configuration file is the relevant action configuration parameter.
Step 3: Develop common packages
1. The net. jforum. View. Admin directory and the net. jforum. View. Forum directory are the stored action files. The action file calls the method corresponding to the DaO interface.
2. Files in the net. jforum. Dao directory are database operation interface files.
3. files under the net. jforum. Dao. Generic Directory are class files that interact with the database, that is, the specific implementation of interfaces.
4. files under the net. jforum. util. preferences directory are several important constant configuration classes and Configuration File Reading classes.
5. The files in the net. jforum. Entities directory are the object objects in the Forum.
Step 4: important classes
1. The configloader. Java class file loads various configuration files.
2. Configure the variable information in the systemglobals. properties file in the configkeys. Java class file.
3. templatekeys. configure templatesmapping in the Java class file. the corresponding page information in the properties file is called through this. settemplatename (XX) to achieve the jump, through this. context. the put ("message", message) method is used to set object information for page calling.
4. The systemglobals. Java class file is a help class that reads configuration information from the configuration file.
5. The dataaccessdriver. Java class file is an abstract class for creating Dao entities. The Dao object is instantiated using xxxdao um = dataaccessdriver. getinstance (). newxxxdao.
6. The genericdataaccessdriver. Java class file is the specific implementation class of the dataaccessdriver abstract class file, and the class of the DaO object is created to interact with the database.
7. jforumexecutioncontext. getconnection (). preparestatement (string SQL) creates a preparedstatement object in Dao in this way. Then, the object performs database operations to obtain the results.
Step 5: test the demo
1. Add a module by modifying the modulesmapping. properties class. You can add your own test Demo module and add the following code mytest = net. jforum. Test. mytestaction at the end of the configuration file. As the processing class of this module.
2. In the templatesmapping. properties file, add: mytest. addtest = mytest_add.htm mytest. listtest = mytest_list.htm. This file maps the relationship between action and result templates, indicating the page to jump after execution.
3. In urlpattern. properties, add: mytest. add.0 = mytest. list.0 = this file to set each action parameter. We have no parameter for this action.
4. modify net. jforum. util. preferences. templatekeys class, add: public static final string mytest_add = "mytest. add "; public static final string mytest_list =" mytest. list "; the String constant corresponding to the quotation marks must be templatesmapping.
The properties file defines the properties of the corresponding page to maintain consistency. By defining this information, you can set the corresponding jump page information in the action.
5. Follow the prompts in step 2, section 1st, to modify the. properties file, edit and save the file, and then use native2ascii A. properties zh_cn.properties to encode the file back to the ASCII file format.
6. Add the following code to edit the header.htm page and add the "My tests" Super connection.
& nbsp;
<A id = "latest2" class = "mainmenu" href = "$ {jforumcontext. encodeurl
("/Mytest/addlist")} ">$ {i18n. getmessage (" mytest ")} </a> & nbsp;
7. The above section shows a normal test of the test demo jump. If you want to interact with the database, you need to follow the steps below:
A) add a test table to the database for testing.
B) modify zh_cn.properties to add the Chinese information of the test table field to be displayed on the page. (Procedure omitted)
C. jforum. add a test Dao interface file testdao under the DaO directory. java and net. jforum. dao. the test interface implementation class generictestdao under the Generic Directory. java implements a series of methods for interacting with the database of the test object.
D) add the JavaBean file of the Test Question object in the net. jforum. Entities directory.
E), add the database script for testing the physical database interaction in the WEB-INF/config/database/generic/generic_queries. SQL file.
F) complete the list method in mytestaction. java files. Internally implement the corresponding query method and return the result object to the page.
PS: if you are using an Oracle database, you only need to modify the jforum-custom.conf to paste an Oracle configuration
# Installation specific configuration options
# Mon Mar 12 12:54:53 CST 2007
Dao. Driver = net. jforum. Dao. Oracle. oracledataaccessdriver
Database. Connection. dbname = zjport
Database. Connection. Driver = oracle. JDBC. oracledriver
Database. Connection. Host = 192.168.180.25
Database. Connection. Implementation = net. jforum. pooledconnection
Database. Connection. Password = action
Database. Connection. Pool. max = 50
Database. Connection. Pool. min = 5
Database. Connection. Pool. Timeout = 120
Database. Connection. Port = 1521
Database. Connection. String =$ {database. Connection. string_thin}
Database. connection. string_local = JDBC/: Oracle/: OCI/: $ {database. connection. username}/$ {database. connection. password }@$ {database. connection. dbname}
Database. connection. string_thin = JDBC/: Oracle/: thin/:$ {database. connection. username}/$ {database. connection. password }@$ {database. connection. host}/: $ {database. connection. port}/: $ {database. connection. dbname}
Database. Connection. Username = operation
Database. Driver. Name = Oracle
Database. Support. autokeys = false
Database. Support. subqueries = true
Dbencoding = UTF-8
Forum. Link = http/: // localhost/: 8080/jforum. T/
Homepage. Link = http/: // localhost/: 8080
I18n. Board. Default = zh_cn
Installed = true
Search. indexing. Enabled = true
User. Hash. Sequence = 348032218c3b45d92e8075662f8b1614
V