Adding javascript into Help Webapp [message #554495] |
Mon, 23 August 2010 11:54 |
Remo Blaser Messages: 9 Registered: August 2010 |
Junior Member |
|
|
Hi!
I am trying to add a tinymce WYSIWYG Editor into the Eclipse Webapp.
I customized Help so i can press a "edit" Button to edit the Content which is shown at the moment.
Now i get the Problem to import the .js File.
If the "edit" button is pressed, a Servlet called ChangeServlet is called, this Servlet looks like this:
package org.eclipse.help.internal.webapp.servlet;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ChangeServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// Getting the Path of the HTML File
String incomingPath = req.getParameter("path");
// Changing Path to open it
String preparedPath = incomingPath.replace(
"http://127.0.0.1:8080/help/topic", "C:/dev/java/pf51-13");
// Öffne das HTML File
File html = new File(preparedPath.replace("?path=0_11#Chapter12", "").replace("?path=0_11", ""));
FileReader fr = new FileReader(html);
BufferedReader br = new BufferedReader(fr);
String htmlString = "";
String line;
// Reading HTML File
while ((line = br.readLine()) != null) {
htmlString += line;
}
// Getting content out of the HTML File
String body = htmlString.substring(htmlString.lastIndexOf("</h1>") + 5,
htmlString.length());
// Getting title out of the HTML File
String title = htmlString.substring(htmlString.lastIndexOf("<h1>") + 4,
htmlString.indexOf("</h1>"));
// implement js and show textareas to edit
resp.getWriter()
.print("<html><head><script type='text/javascript' src='C:/dev/java/pf51-13/ch.post.pf.fp_auftragserfassung.help/tiny_mce/tiny_mce.js'></script>" +
"<script type='text/javascript'>" +
"tinyMCE.init({" +
"mode : 'textareas'," +
"theme : 'advanced'" +
"});" +
"</script></head>");
resp.getWriter()
.print("<body><form method='GET' action='/help/save'><h2>Titel</h2><br /><textarea name='title'>"
+ title
+ "</textarea><br /><br /><h2>Inhalt</h2><br /><textarea name='text'>"
+ body
+ "</textarea><input type='submit' value='Speichern' /><input type='hidden' name='html' value='"
+ htmlString
+ "' /><input type='hidden' name='path' value='"
+ incomingPath
+ "'><input type='hidden' value='"
+ title
+ "' name='oldtitle' /><input type='hidden' value='"
+ body + "' name='oldtext' /></form></body></html>");
}
}
Now i got my problem, the Webapp can't find the tiny_mce.js file, even if i copy it into the same folder and changing the path in the <style> tag.
Hope i can reach some help here.
greetings
[Updated on: Mon, 23 August 2010 13:33] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03967 seconds