wood burning stoves 2.0*
The moose likes JForum and the fly likes Everything works except Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Everything works except "Preview" any problem on previewMessage() function?" Watch "Everything works except "Preview" any problem on previewMessage() function?" New topic
Author

Everything works except "Preview" any problem on previewMessage() function?

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi,

I have newly installed JForum to my server: RedHat 4.0 JDK 1.6 Apache2.0. All the configuration including DB, Backend Jar files are fine, all the basic functionality, post comments, edit, attach images are working.

However, "Preview" does not work.

Seems like, the click invoking "previewMessage()" function in post.js file.
I've double checked there is jquery.js file, also.

No error found in Firebug or IE, it seems like sending HTTP async request to my server, but screen does not refreshed. Since I don't change HTML code at all, there is a <span> tag called "previewMessage".

Does anybody have idea?

Any comment is appreciated.

Thank you.

// Depends of jquery.js
function previewMessage()
{
var f = document.post;

var p = {
text:f.message.value,
subject:f.subject.value,
html:!f.disable_html.checked,
bbcode:!f.disable_bbcode.checked,
smilies:!f.disable_smilies.checked
};

$.ajax({
type:"POST",
url:CONTEXTPATH + "/jforum" + SERVLET_EXTENSION + "?module=ajax&action=previewPost",
data:p,
dataType:"script",
global:false
});
}

[originally posted on jforum.net by npc]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
No luck? I appreciate any comments.
Still struggling.
[originally posted on jforum.net by npc]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
So far, I can't resolve this problem yet, but here's what I've found.

1) Click "Preview"

2) ajax_preview_post.js is invoked.

3) In the first line
$("#previewSubject").html("${post.subject?html}");

${post.subject?html} cannot be resolved. And internally called this error:


$("#previewSubject").html("
Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
The problematic instruction:
----------
==> ${post.subject?html} [on line 1, column 28 in default/ajax_preview_post.js]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at net.jforum.JForum.processCommand(JForum.java:233)
at net.jforum.JForum.service(JForum.java:200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.npc.session.SessionFilter.doFilter(SessionFilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)



Other pages, such as search result page, are using similar parameter, but somehow only this call does not work.

Please give me a help. Thank you.

[originally posted on jforum.net by npc]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Nothing comes to mind... are there any other error messages in the Tomcat logs? Often Freemarker errors are the end result of an error that is logged there.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thank you for the comment.

Yes, there is a Tomcat error logged when this "Preview" button clicked.
It says, "post.subject" is not defined.

I don't know why this occurs only in this page, although there are other pages which are using the same or similar variables without problem.

Please let me know if you know any workaround.


*** Error Log ***


2008-12-01 23:03:50,936 ERROR [http-8080-Processor8] freemarker.runtime error -

Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
The problematic instruction:
----------
==> ${post.subject?html} [on line 1, column 28 in default/ajax_preview_post.js]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at net.jforum.JForum.processCommand(JForum.java:233)
at net.jforum.JForum.service(JForum.java:200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.npc.session.SessionFilter.doFilter(SessionFilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
2008-12-01 23:03:50,938 ERROR [http-8080-Processor8] jforum.exceptions.ExceptionWriter handleExceptionData -
Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
The problematic instruction:
----------
==> ${post.subject?html} [on line 1, column 28 in default/ajax_preview_post.js]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression post.subject is undefined on line 1, column 30 in default/ajax_preview_post.js.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at net.jforum.JForum.processCommand(JForum.java:233)
at net.jforum.JForum.service(JForum.java:200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.npc.session.SessionFilter.doFilter(SessionFilter.java:57)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)

URL is: /staging/jforum.page?module=ajax&action=previewPost

[originally posted on jforum.net by npc]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hmm, I was walking thru the code and the most likely cause might be browser related and not the actual code.

What browser have you been testing this with? Have you tried more than one?

The reason I think this is that the ajax_preview_post.js code gets called via a jQuery Ajax post that sets all the needed data from the current form. This is all done via Javascript running on the browser and not in the server side code. (See posts.js:previewMessage() ). The AjaxAction.previewPost method just copies that information into the FreeMarker template "context". So, somewhere in the Javascript processing it seems the subject is being dropped or not set.


[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thank you.
I've verified it occurs both in IE7 and FF3.


[originally posted on jforum.net by npc]
 
wood burning stoves
 
subject: Everything works except "Preview" any problem on previewMessage() function?