i am successful jsp page connect to fck editor.however, i didn't get fck editor's value in jsp page.
help me?
addNew.jsp
<%@taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<%@page import="getValuesFunction.*"%>
<%@page import="CheckValue.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="JavaScript" src="../js/function.js"></script>
<link rel="stylesheet" href="../css/addUser.css" type="text/css"></link>
<script type="text/javascript">
function FCKeditor_OnComplete( editorInstance )
{
// Show the editor name and description in the browser status bar.
document.getElementById('eMessage').innerHTML = 'Instance "' + editorInstance.Name + '" loaded - ' + editorInstance.Description ;
// Show this sample buttons.
document.getElementById('eButtons').style.visibil ity = '' ;
}
function InsertHTML( instanceName )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
// Check the active editing mode.
if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
{
// Insert the desired HTML.
oEditor.InsertHtml( '- This is some <a href="/Test1.html">sample<\/a> HTML -' ) ;
}
else
alert( 'You must be on WYSIWYG mode!' ) ;
}
function SetContents( instanceName )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
// Set the editor contents (replace the actual one).
oEditor.SetData( 'This is the <b>new content<\/b> I want in the editor.' ) ;
}
function GetContents(instanceName)
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
// Get the editor contents in XHTML.
alert( oEditor.GetXHTML( true ) ) ; // "true" means you want it formatted.
}
function setEditorValue( instanceName, text )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance( instanceName ) ;
// Set the editor contents.
oEditor.SetHTML( text ) ;
}
function getEditorValue( instanceName )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance( instanceName ) ;
// Get the editor contents as XHTML.
return oEditor.GetXHTML( true ) ; // "true" means you want it formatted.
}
function ExecuteCommand( commandName , instanceName)
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
// Execute the command.
oEditor.Commands.GetCommand( commandName ).Execute() ;
}
</script>
</head>
<body>
<%String valueEditNews="dalai kekekekekek";%>
<div id="editMainUser">
<div id="editTwo">
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<form action="pages/addNewsValues.jsp" method="post">
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<table width=100% cellpadding=3 cellspacing=1 border=0 bgcolor="#cccccc">
<tr valign=top>
<td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">News caption:</td>
<td bgcolor="#f5f5f5"><input type="text" name="news" id="nname" value=""> </td>
</tr>
<tr valign=top><%String top="dsadsadsa";%>
<td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">News short</td>
<td bgcolor="#f5f5f5"><FCK:editor instanceName="defaultEditor" basePath="/fckeditor/" height="250" width="800px"/>
</tr>
<tr valign=top>
<td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">News body</td>
<td bgcolor="#f5f5f5"><FCK:editor instanceName="editor" value="<%=valueEditNews%>" basePath="/fckeditor/" height="250" width="800px"/></td>
</tr>
<tr valign=top>
<td bgcolor="#666666" width=150 style="color:#FFFFFF;" id="ndate" align="right" >Register date:</td>
<td bgcolor="#f5f5f5"><%getDateTimeValue valueNews= new getDateTimeValue(); out.println(valueNews.getDateTime());%></td >
<td bgcolor="#f5f5f5"></td>
</tr>
</table>
</td>
</tr><input type="button" value="Add values" onclick="GetLength('editor')" />
<tr><td> </td></tr><in put type="button" value="Get Value" onclick="alert(getEditorValue('editor'))" />
<tr><td><input type="button" name="button" onclick="ajaxpageNew('?a=520&action=<%=top%> ;&caption='+document.getElementById('nname').value ,'editThree');return false;" value="Add"/> </td></tr>
<tr><td height=18 id="eoncmssend"></td></tr>
</table>
</form><%//ajaxpageNew('?a=520®Date=& lt;%=valueNews.getDateTime()&caption='+document.ge tElementById('nname').value
//+'&shortNews='+getEditorValue('shortEditor')
//+'&bodyNews='+getEditorValue('editor')%>
</td>
</tr>
</table>
</div>
<div id="editThree">
</div>
</div>
</body>
</html>
Wed, 12/24/2008 - 05:13
#1
Re: how to get and set value fck editor in jsp page?
Please try again.