Menu

method that replaces title tag

Help
amodg
2005-09-28
2013-04-27
  • amodg

    amodg - 2005-09-28

    Hi,
    Is there any method which will replace the title of the page with new one.
    if (node instanceof TitleTag)
    {
    TitleTag titleTag = (TitleTag) node;
    TitleTag startTitleNode = new TitleTag();
    TextNode textNode = new TextNode("Title");
    TextNode endTitleNode = new TextNode("</TITLE>");
    saveDataList.add(startTitleNode);
    saveDataList.add(textNode);
    saveDataList.add(endTitleNode);

    This code creates a new title! but the previous text tag in title remains intact...

    Please help me.
    Thanks in advance
    -Amod

     
    • Derrick Oswald

      Derrick Oswald - 2005-09-28

      I think you want:
                                                                                                                                                                  
      ...
      TitleTag titleTag = (TitleTag) node;
      titleTag.setChildren (new NodeList (new TextNode ("The New Title")));
      ...

       
    • amodg

      amodg - 2005-09-29

      Hi,
      When I tried with the above mentioed code, this is how the new title tag looks like....

      <title>The new title
      Tomcat WebDAV support
      </title>
      </head>
      <body bgcolor="#FFFFFF">
      <img SRC="tomcat.gif" height=92 width=130 align=LEFT>
      <b>

      where I want the page title to be....
      <title>The new title</title>. (i.e I want to replace the string "Tomcat WebDAV support" with "The new title".)

      Could you please help me?
      Thanks in advance!!!!!
      -Amod

       
      • Derrick Oswald

        Derrick Oswald - 2005-09-29

        The only way that you can get that combined title is if you are adding the new text to the existing children node list.
        Replacing the child list in the title tag should do it.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.