練功房推薦書單

  • 猛虎出柙雙劍合璧版--最新 OCA / OCP Java SE 7 Programmer 專業認證 (電子書)
  • 流浪教師存零股存到3000萬(全新增修版)(書+DVD)
  • 開始在關西自助旅行(京都‧大阪‧神戶‧奈良)(全新增訂版)
  • 不敗教主的300張股票存股術

In forums/list.., i want show last post title, how can i do ?? RSS feed
討論區首頁 » JForum中文社群 JForum Chinese Users Community
發表人 內容
newbiejforum

九級學員

註冊時間: 2011/4/22
文章: 10
離線
my english is bad
Hi andowson and everybody, i like jforum, i using jforum 2.1.9, but this version not show last post title in .../forums/list.. , and I did the following:

In file \WEB-INF\config\database\generic\generic_queries.sql, i edit
ForumModel.lastPostInfo = SELECT post_time, p.topic_id, t.topic_replies, post_id, u.user_id, username, t.topic_title \
FROM jforum_posts p, jforum_users u, jforum_topics t, jforum_forums f \
WHERE t.forum_id = f.forum_id \
AND t.topic_id = p.topic_id \
AND f.forum_last_post_id = t.topic_last_post_id \
AND t.topic_last_post_id = p.post_id \
AND p.forum_id = ? \
AND p.user_id = u.user_id \
AND p.need_moderate = 0


In file \net\jforum\dao\generic\GenericForumDAO.java, i edit it and compile to class file

if (rs.next()) {
lpi.setUsername(rs.getString("username"));
lpi.setUserId(rs.getInt("user_id"));

final SimpleDateFormat sdf = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT), Locale.getDefault());
lpi.setPostDate(sdf.format(rs.getTimestamp("post_time")));
lpi.setPostId(rs.getInt("post_id"));
lpi.setTopicId(rs.getInt("topic_id"));
lpi.setPostTimeMillis(rs.getTimestamp("post_time").getTime());
lpi.setTopicReplies(rs.getInt("topic_replies"));
lpi.setTitle(rs.getString("topic_title"));
lpi.setHasInfo(true);


// Check if the topic is consistent
TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO();
Topic topic = topicDao.selectById(lpi.getTopicId());

if (topic.getId() == 0) {
// Hm, that's not good. Try to fix it
topicDao.fixFirstLastPostId(lpi.getTopicId());
}

tryFix = false;
}


In file \net\jforum\entities\LastPostInfo.java, i edit it and compile to class file:

/**
* @return Returns the title.
*/
public String getTitle() {
return this.topicTitle;
}

/**
* @param title The title to set.
*/
public void setTitle(final String title) {
this.topicTitle = title;
}


In the forum_list.htm, :

<#assign url = JForumContext.encodeURL("/posts/list/${startPage}${lpi.topicId}") + "#p" + lpi.postId/>
<a href="${url}" class="last_title"><img src="${contextPath}/templates/${templateName}/images/icon_latest_reply.gif" border="0" alt="[Latest Reply]" />${lpi.title}</a>


I restart tomcat, and it show title smilie , but, when i post a new topic, it show old title smilie(, when i restart tomcat, it show new title,

I need your help, thank you very much :">
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 711
來自: 台北
離線
Hi newbiejforum,
You can check out the latest code of JForum 2.2.1 from http://jforum2.googlecode.com/ and start from net.jforum.view.forum.PostAction.java#insertSave() method, and find the line:

ForumRepository.reloadForum(post.getForumId());


see http://code.google.com/p/jforum2/source/detail?r=56 and you can find the answer.

分享經驗 累積智慧
[WWW]
newbiejforum

九級學員

註冊時間: 2011/4/22
文章: 10
離線
Hi andowson,
When i add this line in the PostAction.java, and compline to class, i get an error:

PostAction.java:1052: cannot find symbol
symbol : variable StringUtils
location: class net.jforum.view.forum.PostAction
if (StringUtils.isBlank(p.getSubject())) {
^
PostAction.java:1437: cannot access javax.servlet.ServletOutputStream
class file for javax.servlet.ServletOutputStream not found
os = response.getOutputStream();


I find in WEB-INF\lib ( all .jar file), but this file javax/servlet/ServletOutpitStream.class not found,
How can i do next step ??
thank you very much !!
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 711
來自: 台北
離線
Hi newbiejforum,
Did you check out the JForum 2.2.1 code?
There is a line of import at the top of PostAction.java:

import org.apache.commons.lang.StringUtils;


And you'll need to add commons-lang-2.5.jar in your CLASSPATH to compile it.
Also you'll need to add servlet-api.jar to your CLASSPATH, too.

分享經驗 累積智慧
[WWW]
newbiejforum

九級學員

註冊時間: 2011/4/22
文章: 10
離線
newbiejforum wrote:Hi andowson,
When i add this line in the PostAction.java, and compline to class, i get an error:

PostAction.java:1052: cannot find symbol
symbol : variable StringUtils
location: class net.jforum.view.forum.PostAction
if (StringUtils.isBlank(p.getSubject())) {
^
PostAction.java:1437: cannot access javax.servlet.ServletOutputStream
class file for javax.servlet.ServletOutputStream not found
os = response.getOutputStream();


I find in WEB-INF\lib ( all .jar file), but this file javax/servlet/ServletOutpitStream.class not found,
How can i do next step ??
thank you very much !!



It is not show new last post title too smilie
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 711
來自: 台北
離線
Hi newbiejforum,

My suggestion is that you can download jforum-2.2.1.war and install it.

Here is the download page:
http://code.google.com/p/jforum2/downloads/list

And see if JForum 2.2.1 works for you.

If it works, then you can start your customization on JForum 2.2.1's codebase.

分享經驗 累積智慧
[WWW]
newbiejforum

九級學員

註冊時間: 2011/4/22
文章: 10
離線
Thank you very much, andowson !! smilie
 
討論區首頁 » JForum中文社群 JForum Chinese Users Community
前往:   
行動版