Results 1 to 6 of 6

Thread: rich text editor displaying back from database

  1. #1
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rich text editor displaying back from database

    RICH TEXT EDITOR
    http://www.dynamicdrive.com/dynamici...itor/index.htm


    hello i just tried the RTE and it's really a nice script and it works great for me except for one thing:

    if i type and format some text and then save it into a longtext field in my database everything works, but when i open again the page with the editor and the text is retrieved from the DB, the html tags are not translated back into bold or anything else.
    i see <STRONG> and the other tags.
    i know this is how the editor works but shouldn't these tags be translated back when retrieving back saved text? what am i doing wrong?
    thanks in advance,
    tool

  2. #2
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    could u post a link to ur problematic page?
    Please don't mind me. I am just posting a lot of nonsense.

  3. #3
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    actually i cannot give the link because it is inside a reserved area for (that)system administrators.
    i can paste the code of the jsp hoping it helps:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <%@ include file="/inc/init.jsp" %>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
    <head>
    
    <script language="JavaScript" type="text/javascript" src="richtext_compressed.js"></script>
    <script language='JavaScript' src="/gest_ag_ut/JS/agenzie.js"></script>
    
    
    	<title>Note per <c:out value='${requestScope.codice}'/></title>
    	<meta http-equiv="Expires" content="-1" />
    	<meta http-equiv="Pragma" content="no-cache" />
    	<meta http-equiv="Cache-Control" content="no-cache" />
    	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    
    </head>
    
    
        <body bgcolor="#E5EDBA">
    
         <table width="100%" align="center">
             <tr><td>
             
         <form name="form_editnote" action="/gest_ag_ut/Note" method="POST" onsubmit="return submitForm();">       
             
     <script language="JavaScript" type="text/javascript">             
    function submitForm() {
    	//make sure hidden and iframe values are in sync before submitting form
    	//to sync only 1 rte, use updateRTE(rte)
    	//to sync all rtes, use updateRTEs
    	updateRTE('note');
    	//updateRTEs();
    	//alert("note = " + document.RTEDemo.rte1.value);
    	
    	//change the following line to true to submit form
    	return true;
    }
    
    //Usage: initRTE(imagesPath, includesPath, cssFile)
    initRTE("images/", "", "rte.css");
    //
    </script>                             
            <input type="hidden" name="richiesta" value="salva">
            <input type="hidden" name="codice" value="<c:out value='${requestScope.codice}'/>">
            
               <script language="JavaScript" type="text/javascript">
                    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
                    writeRichText('note', '<c:out value="${requestScope.note}"/>', 400, 450, true, false);
                    </script>
            <input type="submit" name="submit" value="Salva">
            </table>
                <script language="JavaScript" type="text/javascript">      
    
                </script>
         </form> 
        
         <c:if test="${requestScope.esito=='ERRORE'}">
            <c:out value='${requestScope.esito}'/>:&nbsp;<c:out value='${requestScope.errore}'/>
         </c:if>
         
        <c:if test="${requestScope.esito=='ok'}">
            <script language="JavaScript">
                window.close();
            </script>
        </c:if>        
        
             </td></tr>
             </table>
    
        </body>
    </html>
    and in the jsp's directory i put insert_table.htm, palette.htm, blank.htm, rte.css, richtext_compressed.js .

    thanks again,
    tool

  4. #4
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i found the reason.
    in the database hello is correctly stored as <STRONG>hello</STRONG> and it's retrieved back in the right way until it is passed to the browser (IE 6),
    than the browser (or maybe javascript?!... wait wait, i think it's the JSTL library that do that!) do some urlencode so that < and > become &lt; and gt; .
    that is why it is not translated.
    how could i prevent that?

    thanks!
    tool

  5. #5
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    again i finally did it.
    there's a non-required attribute in the <c: out> tag of JSTL which is called escapeXml.
    it's default value is true, it is enought to specify it to false and the trick is done!

    thanks dudes!

  6. #6
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks dudes!
    ur welcome, dude
    Please don't mind me. I am just posting a lot of nonsense.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •