HTML tag insertion problems

I'm new here, any forum mods that have a better spot for this to go, feel free to put it there.
Ok, here's my situation. I'm trying to write a note-taking application, which displays said notes in HTML, in a JEditorPane. I figure HTML is a good way to display them, as it supports bold, italics, highlighting, links, tables, bullets, etc, all of which are very handy in notes. However, adding all those things to the notes dynamically (as one does when taking those notes) is getting very complicated. Specifically, say I want to highlight (by changing the background color) a selection of text. I can do this fine, by inserting the appropriate tags, but when it comes time to unhighlight (all or partially) things get confusing, and a LOT of edge cases pop up very quickly. Anybody have someplace I can go to where this has been done before? I'm sure I'm not the only one wanting to essentially implement a subset of Office's formatting capabilities, and apparently OpenOffice doesn't use Java to do this.
Also, would RTF format be a better alternative? I know next to nothing about how it works, but maybe it's easier to do this in it, considering it's designed to handle these sorts of things.

[Google it!|http://www.google.com/search?q=java+html+wysiwyg+editor&hl=en&sourceid=gd&rls=GGLD,GGLD:2008-06,GGLD:en&aq=t]... and take your shovel ;-)
Cheers. Keith.

Similar Messages

  • Replace HTML tags within column values

    Hi Gurus,
    I have a requirement where I have some text which has HTML tags inserted within it and I need to insert either Presentation variable or a GO URL replacing that tag. Problem is that this text is value of a column from table. It is not something which I type( because the text can change dynamically). e.g
    Column header:  Main Text
    Row1:            <<COMPANY_NAME>>
    Row2:           As of <<AF_OF_DATE>>
    instead of <<COMPANY_NAME>> and <<AS_OF_DATE>>, I need to insert amounts from another table which have this unique tags and associated amounts. Can this be done?
    I have to these columns in different places throughout the report in narrative views. e.g
    1st narrative view will have only column 1 and row 1 and row 2.. 2nd narrative view will have only column 3 and row1...
    This is really really important part of a report. So please help me out with ideas.
    Thanks,
    Dan

    I tried calling the column in a narrative view and the result looks like :
    As of <<AS_OF_DATE>>. how can I replace "<<AS_OF_DATE>>" with a value?

  • BC won't allow me to insert code (scripts) between the /body and the /html tags.

    Hi guys,
    So I have this weird problem. I'm trying to insert some codes between the </body> and the </html> tags in the page templates. It's saving it. But if you check the page, the code is showing before the </body>, not after. Here's the code that I'm trying to insert.
    <script src="http://i.simpli.fi/dpx.js?cid=1534&action=100&segment=198566&m=1"></script>
    I have also tried adding this code by downloading the templates through ftp, adding the code, then uploading it to the server. Same thing. I even added type="text/javascript" in the code. Still no go. BC wouldn't insert it between </body> and </html>. Any ideas guys?
    - Jeff

    So an update.
    I was told by Adobe chat support to try adding the script after the body via javascript.
    So I added this before </head>
    <script type="text/javascript">
    var script = document.createElement('script');
    script.src = '//i.simpli.fi/dpx.js?cid=1534&action=100&segment=198566&m=1';
    script.type = 'text/javascript';
    $("html").append(script);
    </script>
    Still not working. Any ideas guys?

  • Inserting custom HTML tags into a HTMLDocument to be displayed in a JEditor

    Does anyone know how to insert custom tags into a HTMLDocument to be displayed in a JEditorPane?
    I have tried using the following code,
    kit.insertHTML( doc,
                    jep.getCaretPosition(),
                    "<testtag>FFFF</testtag>",
                    0,
                    0,
                    new HTML.UnknownTag("testtag") );When the above code is run the handleStartTag, handleEndTag and handleText methods are called on the HTMLReader but nothing is inserted into the document model? Can anyone help?
    I have created an instance of HTML.UnknownTag,
      public static HTML.Tag testTag = new HTML.UnknownTag("testtag");I have subclassed HTMLEditorKit and overridden the getParser() method,
      protected Parser getParser(){
        DTD dtd = null;
        try {
          dtd = createDTD( DTD.getDTD("html32"), "html32" );
        } catch ( Exception e ) {
          e.printStackTrace();
        dtd.getElement( "testtag" );
        Parser p = new ParserAdaptor( new DocumentParser( dtd ) );
        return p;
      }I have subclassed HTMLDocument and HTMLDocument.HTMLReader and created a TagAction for my new tag.
    The following code works fine, the custom tag is in the document model,
        String contents =    "<html>"
                           + "<body>"
                           + "<testtag>Here is some text</testtag>"
                           + "</body>"
                           + "</html>";
        ((HTMLDocument)jep.getDocument()).setPreservesUnknownTags(true);
        jep.setText( contents );

    I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
    HTMLDocument doc = (HTMLDocument)editor.getDocument();
    int start = editor.getCaretPosition()
    int paraStart = doc.getParagraphElement(start).getStartOffset();
    int paraEnd = doc.getParagraphElement(start).getEndOffset();
    String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
    doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
    This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
    This works 'in about' but it's far from perfect.. it has the following problems:
    1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
    2. It assumes that the paragraphElement was a <p> (could have been another element too!)
    3. It's ugly
    Anybody come up with a better way to use blockquote?

  • Problem in parsing HTML tag

    Hello,
    I want to parse the text in div ..like :<div id="title">Action Result</div>
    My code is :
    public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos){
    if (t == HTML.Tag.DIV){
      String page_title = (String)a.getAttribute(HTML.Attribute.ID);
      if (page_title != null){
         System.out.println("Title : " + page_title);
      public static void main(String argv[]) {
        try {
          Reader r = new FileReader("C://test1.html");
          ParserDelegator parser = new ParserDelegator();
          HTMLEditorKit.ParserCallback callback = new ParseTest();
          parser.parse(r, callback, false);
        } catch (IOException e) {
          e.printStackTrace();
      }But it does not work. Please advise how to do this.
    Thanks in advance.

    I also want to extract the html text from the tag like-
    <div id="title">Action Result</div>
    I want to take the "Action Result" as my programs output.
    Please help me to solve this problem.

  • Problem using XSLT & HTML Tags

    Hi all,
    I'm newbie using XML and XSL and i'm facing a problem that i would need some help.
    I wrote a XML using servlet that use a XSL and transform it in a HTML output. So everything seems to work fine but when i try to use HTML tags inside my XSL it is not executed. it looks like below viewing by the browser IE6.0.
    - <html>
    - <body>
    <b>Sun Sep 14 12:27:09 BRT 2003</b>
    <i>Hello World</i>
    </body>
    </html>
    The fact is that i want my HTML tags to be executed by the XSl file and do not simple show the tags. Can someone help me? I would appreciate any help since i've been spending long time with that without any answer.
    Thanks and Regards
    Fabio

    following below the code that generate the XML. I still need help.
    I hope someone can help me in this issue
    The servlet that generate the XML.
    response.setContentType("text/xml");
    String Xml = "";
    Xml = Xml + "<?xml version=\"1.0\"?>";
    Xml = Xml + "<?xml-stylesheet href=\"/XslGravaCrit.xsl\" type=\"text/xsl\"?>";
    Xml = Xml + "<!-- Here is a sample XML file -->";
    Xml = Xml + "<page>";
    Xml = Xml + "<title>Test Page</title>";
    Xml = Xml + "<content>";
    Xml = Xml + "<paragraph>What you see is what you get!</paragraph>";
    Xml = Xml + "</content>";
    Xml = Xml + "</page>";
    try{
    TransformerFactory tFactory = TransformerFactory.newInstance();
    byte[] arr=Xml.getBytes();
    ByteArrayInputStream bytes=new ByteArrayInputStream(arr);
    Source xsl=new StreamSource("../XslGravaCrit.xsl");
    Templates template=tFactory.newTemplates(xsl);
    Transformer transformer = template.newTransformer();
    transformer.transform(new StreamSource(bytes), new StreamResult(response.getWriter()));
    }catch(Exception e){
    System.out.println("Excecao 100: " + e.getMessage() + e.getLocalizedMessage());
    The XSL XslGravaCrit.xsl
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java"
    version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:output method="html" indent="yes" version="4.0"/>
    <xsl:template match="page">
    <html>
    <body><b>
    <xsl:value-of select="java:java.util.Date.new()"/>
         </b>
    <xsl:for-each select="/page">
    <xsl:sort select="paragraph"/>
    <xsl:value-of select="paragraph"/>
    </xsl:for-each>
    <i>Hello World</i>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

  • Problem removing html tags from the text retrived

    Hi there,
    I am using jdbc to connect the database and retriving the data. In one of the columns along with the description there are some html tags in few of the recors of that column. is there a way to retrive the text only ignoring the html tags in between. Or can i retrive and then strip off the html code in the text to display only normal text.
    example of the data retrived which are pipe seperated and one of the columns has html tags in it:
    209|The euphoria |187945-2|http://www.abc/lst.jsp?mktgChannel=I86023&sku=18791-2&siteID=qpF0HYnRugA|http://www.abc.com/assets/images/product/medium/18793-2_198.jpg|Rooftop Singers: Walk Right In | abc Music proudly presents THE FOLK YEARS, an unforgettable era in music history!<BR><BR><B>Featuring:</B><BR>
    <LI>The most complete collection of folk and folk-rock songs ever put together -- 132 classics!
    <LI>Original hits by the original artists!
    Now i need to remove the tags before displaying this on the output. Is there a simple way to do this.
    Thanks...

    Did you read the documentation of the trim() method,
    where it describes which whitespace it removes?I believe his problem is that
    "Some text here  
    <blah> 
    More text"becomes
    "Some text here  
    More text"... and he wants ...
    "Some text here
    More text"So, your problem is that your regex isn't matching whitespace as well.
    See the "Trimming Whitespace" section:
    http://www.regular-expressions.info/examples.html

  • Storing HTML TAG content in StringBuffer Problem..

    respected sir...
    currently i am working with one project in that i want to put whole table content in StringBuffer that goes for image creation .....and finally image is created for whole table
    how can i put the HTML tags in imageBuffer.... i have tried with this...
    StringBuffer ImageContent=new StringBuffer();
    ImageContent.append(out.print("<table>"));
    ImageContent.append(out.print("</table>"));
    ImageContent.append(out.print("<tr>"));
    ImageContent.append(out.print("</tr>"));
    but not working is there any way to build table using StringBuffer that has whole Table Content With Data....
    thanks in advance......regards.....

    Hi.
    Some remarks (no offence though...):
    1) StringBuffer is synchronized. In case your object instance will not be used by other threads concurrently, you should use StringBuilder class instead (which offers the same methods)
    2) when posting code samples, formatting them as code makes them easier for others to read
    3) variable names are written with a lower case first letter by convention
    4) shouldn't the "tr"s be between the opening and the closing "table"-tags?
    5) it would be helpful to have an indication on what type "out" is and why you are using it...
    For your problem: why do you pass your Strings to "out.print()"? StringBuffer directly takes Strings as arguments (among others).
    Without having tried your sample, I would suggest you try somthing like the following:
    StringBuffer imageContent=new StringBuffer();
    imageContent.append("<table>");
    imageContent.append("<tr>");
    imageContent.append("</tr>");
    imageContent.append("</table>");Bye.

  • Struts portlet Instance Label problem: Appending the html tags in jsp

    I have created a struts portlet and given it a Instance Label. I have used struts-adapter-html.tld tld in my jsp which is referenced by my struts portlet. But the problem with using this taglib is that the portlet Instance Label is appended to all the html tags on the JSP as a result of which when the page is submitted, formbean will not pick any of the values as the name will not match. Has anyone has faced this kind of problem? How can I prevent the appending of the HTML tags with the portlet Instance Label?
    Please help me overcome this problem..
    Thanks in Advance ...

    1. To begin with, I would not recommend NOT to append portlet instance label to html tags. This is very much required. Take atleast 2 scenarios. If you dropped 2 instances for Same Portlet like News/Articles portlet etc on same page, you need to identify the html fields uniquely for each portlet so that backend java code works properly. Also if you have 2 different portlets assuming you did not give any name to form tag, and if you have html tags with same name, you need to identify them. Remember when portal or desktop is rendered, it is one big html file with html fragmetns from all .portlets files. So I am not sure if there is any option at all, to avoid the appending of instance label value to html tags.
    2. Coming to your usecase, I did had this problem once in 8.1 SPxx long back. All we did was, in the back end code, using BackingFile we could get the intance label value of the portlet. We can get this in pageflow also. Then pass this value and manually append this value to the html field of interest. In your case looks like you have Struts and tld tags. See somehow if you can get portlet instance label in jsp file and pass around to your tag lib code in request parameters etc. This is just one idea. I am not fully aware of your code, so try something along these lines.
    HTH
    Ravi Jegga

  • Struts bean/html tag problem

    i am writing this url_element on screen
    <bean:write name="url_element"/>
    then i got a link
    <html:link action="urlDetail.do?url=???">aaa</html:link>
    how can i transfer the url_element into ??? do i need to write something like <%...%>?

    just found the solution:
    You can't use a <bean:write> tag inside an <html:link> tag. Struts doesn't support it.
    The easiest way to fix this is to abandon use of <html:link> and just use the plain old html tags <a></a>. Then you will have no problem substituting parameters with <bean:write> tags.
    The only advantage <html:link> has over the plain html tag is that it automatically does URL rewriting (Adding of the jsessionid to the URL so that sessions may be tracked even if the user has turned cookies off). If you're not using this function anyway, as most modern websites don't, you may as well use the html tag.
    If you still want to use <html:link>, use the struts-el version of the html tags and use EL expressions instead of <bean:write> tags.

  • Insert HTML.Tag attributes?

    Hey,
    How would I insert html attributes? I am making a HTML Editor.
    The following are some valid java html attributes. How would I insert it properly?
    HTML.Tag.P, HTML.Tag.BLOCKQUOTE, HTML.Tag.CENTER,
    HTML.Tag.CITE, HTML.Tag.CODE, HTML.Tag.H1, HTML.Tag.H2,
    HTML.Tag.H3, HTML.Tag.H4, HTML.Tag.H5, HTML.Tag.H6,
    HTML.Tag.PRE
    Like for example, to make text bold, you would do
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setBold(attr, true);
    textpane.setCharacterAttributes(attr,false);
    Is there similar code like the one above to add HTML.Tags like the ones I listed above in my post?
    Thanks in advance

    Hi,
    sorry about the delay, couldn't find this thread last night.
    Useful docs:
    http://java.sun.com/products/jfc/tsc/articles/text/element_interface/index.html
    and
    http://java.sun.com/products/jfc/tsc/articles/text/attributes/
    Those methods are in javax.swing.text.html.HTMLDocument and take the form insertBeforeStart(Element, String). As I said yesterday, as soon as you have text then the caret is in a character Element and a Paragraph element. So for e.g. if you're in a P element and you want to create an H1 element, how do you do it? If the user clicks your H1 button then you create an empty heading, easy enough. But if they have some text selected then you have a choice. You could just create an empty H1 or you could assume that they have typed the H1 content and have highlighted it so that it becomes an H1. You then have to change the existing element so that is no longer has the (now H1) text in it.
    That's where the other two methods (setInnerHTML and setOuterHTML) come into play.
    The other problemette that I'm working on is reseting text back to normal after it has been formatted.
    Suppose you have a P paragraph. The user highlights a single word, clicks Bold. That's easy. Then they decide that they don't want it bold, so they click the Normal button. Taking bold off is easy, but should you. What if the paragraph element was actually an H1 element. If you turn bold off now then that word no longer matches the H1 style.
    You could check at the caret position just before the start of the element that the user has selected and see what the style is there. BUt then waht if the user has the word before perhaps underlined. Again it's unreliable.
    Also I'm finding then when I remove the bold formatting that the element isn't being reabsorbed into it's parent. In a paragraph if I go through and make each word formatted (B, i, u) and then switch the formatting off word at a time I end up with each word as an element.
    Still working on these, so I'll post a solution when I have one.
    regards
    sjl

  • How to insert row in usercreat table(useing HTML tags)in jtextPane

    hi all
    i creat userdefined table in JTextPane like this
    tableBody.toString() -- iam passeing table tags
    htmlKit.insertHTML(htmlDoc, caretPos, tableBody.toString(), 0, 0, HTML.Tag.TABLE);
    i want to insert a row in table.. i did like this
    htmlKit.insertHTML(htmlDoc, caretPos, sRow.toString(), 0, 0, HTML.Tag.TR); it working..
    but it inserting in current location.. i want to insert ending of table...
    pls help me

    Hi,
    Follow the below logic,
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0001.
      MODULE POPULATE_TABLE_CONTROL. --> Get the data from table store in 
                                                                          ITAB
      LOOP AT GT_CTRL_LP_D516 INTO GS_WA_CTRL_LP_D516
           WITH CONTROL CTRL_LP_D516
           CURSOR CTRL_LP_D516-CURRENT_LINE.
      The following module moves data to control
        MODULE MOVE_TO_CONTROL.--> Move data from ITAB to table control
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT GT_CTRL_LP_D516.
      ENDLOOP.
      MODULE EXIT AT EXIT-COMMAND.
      MODULE USER_COMMAND_0001.  --> Here you have to take out the values from table control and update database table
    Reward points if helpful.
    Thanks and regards,
    Mallareddy Rayapureddy,
    Munich, Germany.

  • Problems setting 'allow HTML snippet insertion' in Contribute 4

    I am trying to set the administrator option to allow insertion of HTML snippets (as described here). But the dialog box to change the settings does not include an "Allow HTML Snippet Insertion" checkbox.
    Any advice? Is this to do with the version of Contribute I'm using? Or is there some other administrator setting I need to set first?

    Hi ravster.
    Thanks for the suggestions. I had read the Arch NFS HowTo and did as you suggested get rcpinfo for the server machine. The Libranet NFS server is configured rather different since the NFS daemons are built into the default kernel.
    Since I needed to complete the transfer immediately, I gave up for now trying to set up NFS and used netcat (!) instead to transfer the files from the Libranet laptop to the Arch workstation. The laptop will be converted to Arch Linux soon so I think I'll be able to clear things up soon.  I haven't had any problems setting up NFS with homogeneous (i.e., all Arch or all Libranet) computer combinations.
    Thanks again.
    Win

  • Can you insert a HTML tag in mail?

    Basically I want to replace a very long and messy hyperlink with one word (DIARY) as a signature on my emails. I believe this is called a HTML tag. Anybody have any ideas on how to do this?
    Thanks

    Hi
    assuming you  create a signature in Mail-Preferences-Signatures
    then do so, using the single word (or more) -
    select/highlight the part you want as a link & ctrl-click it, choosing Link - Add Link
    ( or use the Mail-Edit-Edit Link command, or the Command-K keyboard shortcut )
    copy/paste the web address you want.

  • Html Tag Problem

    Hello, I have a web page.
    <body  class="mediawiki ns-0 ltr page-Hacker">
         <div id="globalWrapper">
              <div id="column-content">
         <div id="content">
              <a name="top" id="top"></a>
                        <h1 class="firstHeading">Hacker</h1>
              <div id="bodyContent">
         ...I want to replace the lines with new lines which are added id
    <body  id="1" class="mediawiki ns-0 ltr page-Hacker">
         <div id="globalWrapper">
              <div id="column-content">
         <div id="content">
              <a id="2"name="top" id="top"></a>
                        <h1 id="3" class="firstHeading">Hacker</h1>
              <div id="bodyContent">
         Every line must have an id in the tag, I am not familar with html.tag or parser.
    Could you please provide some hint?
    Regards!

    public class AddIds  extends HTMLEditorKit.ParserCallback{
      public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos){
        ... // write the edited line out
    }

Maybe you are looking for

  • Smartform driver program

    Hi, can u plz send me one realtime sample smartform driver program  if possible invoice from and credit form regards Siri

  • Problem with monitor driver

    Hello,congratulations for the forum ,its a great idea!!! I have a problem with my lenovo T61. I have tried to to install this: http://www-307.ibm.com/pc/support/site.wss/documen​t.do?lndocid=MIGR-62923 But i can not!!! I am going with the instruction

  • New external links in in-browser editor

    Hi, I have set up webMarketing in buisness catalyst with in-browser editing and i have watched all the videos, so i can change text and images but in my text i have external links but when i change some text how do i make new external links? thanks

  • Podcast Artwork refusing to show up in iTunes.

    I started a new podcast which is hosted by MyMac.com and was submitted into iTunes by Tim of MyMac.com. He's submitted many podcasts to iTunes and knows what he's doing. However, in the case of my podcast, the artwork is not showing. I have verified

  • IPad2 crashed, won't react at all

    Hi, My iPad2 crashed when I was watching pictures on my photostream. The Apple logo appeared, but the only thing I could do was to turn him off with both buttons pushed in for about 10 seconds. Now he doesn't react at all. Thanks for your help! Skepp