HTML splitting with java

I'm currently working on a program that fetches posts from a blog and then presents these posts on a webpage using wicket. The webpage cannot require any user interaction and all content must be visible on the same page (without the use of autoscroll etc.) To be able to fit two or three posts on the same page I have to show only the beginning of each post (and whoever wants to read further will have to go to the blog). I want to split the posts using the following method:
public void insertPosts(int visiblePosts, int visibleChars);where visiblePosts represents the number of visible posts and visibleChars is the visible characters per post.
Each post is a html formatted string and I am a little lost on how to get started with this. For instance, characters inside a tag should not be counted, all opened tags must be closed, paragraph tags that does not add any characters, but still consumes space on the page etc. Can anyone get me started? Maybe something similar already exists?

AndrewThompson64: This will not be a concern. The webserver runs locally on a single computer where we can adjust the numbers of visible post and characters to fit the screen resolution.
sztyopek: This might be the way to go, although i cannot add JEditorPanes. It must be strings. They are inserted into the document like this:
Index.java
page.add(new Label(("content", post.getContent()).setEscapeModelStrings(false)if setEscapeModelStrings is true the html tags is interpreted as part of the content and the whole string is printed to the page as is.
Index.html
<div wicket:id="content" />I'll have a look at HTMLDocument. If anyone else has any other suggestions or want to elaborate more on this, please do so! :)

Similar Messages

  • How to create dom treeof html page with java

    hi, all
    i met with a problem how to create dom tree of html page wih jave, that is, given a html page, how to create a dom tree of this page with java?
    thanks in advance.
    regards
    richard

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • Get html data with java

    Ok say I want to get some kind of data from a html page? How could it be done? Is this possible with java, or do I have to use some kind of scripting language?

    It looks like what you might be looking for is a method of getting HTTP, not HTML, data. HTML is simply text and can therefore be retrieved any way that a File could be retrieved (using a FileReader/FileWriter). HTTP, on the other hand, is the protocol that we use the most when viewing websites.
    If you're looking to make HTTP request, you may want to look into something like java.net.HttpURLConnection. Try searching these forums for HTTP, not html.

  • ERROR USING HTML textarea with Java String

    I have a form in HTML that has a textarea for input messages.
    When user press submit, a java servlet gets the information and stores it in a Database as a String.
    Later, I have a JSP thata retrieves that information from the database and put it as the value propertie of another textarea in the page so user can modify it if wanted, but I am having a hard time finding how to do so , because when I do the line:
    <textarea .....bla bla.... value=
    <%=some_string%>
    .....bla >
    and the some_string has more than one line ( e.g "\n" or "\r" caracteres ), I got an error when displaying the page. Can anyone help me with that please ???
    Thanks.

    here's my codes again for reference. hope it helps to rectify the matter
    // edit.jsp
    String search = (String)request.getParameter("txtSearch");
    String parameter = (String)"%"+search+"%";
    String sSQL = "select * from tblArticle where Title LIKE '"+parameter+"'";
    <%
    try {
    while(Rs.next()) {
    %>
    <tr>
    <td width="16%" height="157" align="center">Article:</td>
    <td width="88%" height="157"><textarea rows="15" name="txtArt" cols="86" value="<%= txtArt %>"></textarea></td>
    </tr>
    </table>
    <%
    // .....

  • How to reduce size of html files with JAVA?

    We have html files full of tab char, carriage return, blank space between tags etc. We need to reduce the size of this files.
    HTML files are automatic generated by an engine and we cannot operate on it.
    Those files are in a solaris environment and we need to launch or to schedule something that can clean the files in this environment. The only tools we found are for Win environment so we toughth to make some java classes that parse HTML and clean the files.
    Does anyone know how some tool or the way to clean a file in java?
    Thank You

    Something like this can reduce the number of spaces between tags in the body of the file:public static final String readTextFromFile (File f)
            StringBuffer fileText = new StringBuffer();
            if (f != null && f.exists() && f.isFile())
                try
                    FileReader fr = new FileReader(f);
                    BufferedReader br = new BufferedReader(fr);
                    String s;
                    char c;
                    boolean inTag = false;
                    boolean lastWasSpace = false; // so we don't have a million spaces in a row
                    boolean inBody = false;
                    while ((s = br.readLine()) != null)
                        s += " ";
                        s = searchReplace(s, " ", " ");
                        if (!inBody)
                            int bodyStartPos = s.indexOf("<body");
                            // if not in body yet, reloop
                            if (bodyStartPos == -1)
                                continue;
                            // start it off
                            else
                                inBody = true;
                                s = s.substring(bodyStartPos);
                        for (int i = 0; i < s.length(); i++)
                            c = s.charAt(i);
                            if (c == '>')
                                inTag = false;
                            else if (c == '<')
                                inTag = true;
                            else if (!inTag)
                                if (!(c == ' ' && lastWasSpace))
                                    fileText.append(c);
                                if (c == ' ')
                                    lastWasSpace = true;
                                else
                                    lastWasSpace = false;
                    if (br != null)
                        br.close();
                    if (fr != null)
                        fr.close();
                catch (Exception e)
                    System.err.println(f + ": Error reading file");
            return fileText.toString();
        }

  • Cannot render special HTML character with Java

    I'm pretty sure this is a general Swing issue, please don't ignore this because I reference JavaHelp. When using JavaHelp and French as the displayed language, I'm having problems displaying the &#156; character (HTML entity &# 156;). Below I've included a sample HTML file, based on what my actual files looks like, which should demonstrate the problem. If I use a browser, or even Notepad, to open this file, the character displays just fine. However, in my JavaHelp popup (which uses Swings HTML renderer under the covers if I am not mistaken), all I get is a box. I've tried using the actual character and the HTML entity, but to no avail. Comments/suggestions/pointers would be greatly welcome!
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
            <style>
                li {padding-bottom: 6px; padding-top: 6px;}
                body {font-family: Helvetica, Arial, sans-serif; } td {font-size: smaller;}
            </style>
        </head>
        <body alink="#ff0000" bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#800080">
            &#156;
        </body>
    </html>Thanks,
    Jamie

    all I get is a boxSo JavaHelp is rendering it as a single character and not as the six characters &, #, 1, 5, 6, and semicolon. So far, so good. But it appears that the font JavaHelp is using is unable to render that character correctly, so you get a box.
    Can you control the fonts that JavaHelp uses? If so, try using a font that can render the &#156; character.
    PC&#178;

  • Printing HTML Docs with JPS ???

    Hello!
    How can I print a HTML-File with Java Printing Service (not the source, but the view of it) ???
    Some experience???
    kind regards
    pedros25

    I'm currently trying to do just that. My problem is
    that in order to get a lengthy HTML document to
    print, you have to have an object that
    implements the Pageable interface. The two methods
    I'm having trouble with are
    getNumberOfPages()
    This returns the number of pages in the Print job.
    How do I calculate the number of pages in an HTML
    document?
    getPrintable(int pageIndex)
    For this part, I just rerturn a reference to the JScrollPane which contains the JEditorPane. However,
    I also have to get it to scroll to the appropriate
    page. Right now I'm using the following:
    public void goPage(int pageIndex)
    int block = pane.getScrollableBlockIncrement(scroller.getViewport().getViewRect() ,SwingConstants.VERTICAL,1);
    int newVal = block*pageIndex;
    //scroller.getVerticalScrollBar().setValue(newVal);
    scroller.getViewport().scrollRectToVisible(new Rectangle(0,newVal,this.getSize().width,block));
    But this seems to be causing a few lines to be skipped
    between each page. Any ideas on how to implement the
    pageable interface for a JScrollPane that contains a
    JEditorPane which contains an HTMLDocument?

  • A tree-view in HTML page with nodes generated with java script in run time is not visible in the UI Automation Tree. Need Help

    I have a HTML page with an IFrame. Inside the Iframe there is a table with a tree view
    <iframe>
    <table>
    <tr>
    <td>
    <treeview id="tv1"></treeview>
    </td>
    </tr>
    </table>
    </iframe>
    In UIA, i am able to traverse till the tree view but not able to see it.
    I have used the TreeWalker.RawViewWalker Field to traverse the node from the desktop Automation.RootElement. 
    I tried to use AutomationElement.FromPoint method to check whether i am able to get that element. Fortunately i was able to get the automation element. 
    i tried to get the path to root element from the node element using the TreeWalker.RawViewWalker. I was able to get the parent path to the root element.
    But trying the reverse way like navigating from root element to tree node, was not getting the element for me. 
    Please help me with suggestions or inputs to resolve this issue. 

    Thanks Bernard,
    It works fine with JInitiator but not working with
    the JPI. For JPI what settings I need to do ??hi TKARIM and Bernard, i am having similar problem even with the Bernard's recommended setup. could you post the webutiljini.htm (i presume you are using config=test) ?
    i am actually using jinitiator 1.3.1.28 with Oracle HTTP Server of OAS 10gR2) calling Forms Server 6i (f60cgi). After setting up according to Bernard's recommended setup steps, the java console showed that it loaded the icon jar file when it could not read the form, but it skipped the loading of the icon jar file once it read and started the form. How do we specify in the form to pick up the icon from the jar file instead from a directory ? Or do we need to specify ? Any ideas ?
    Thx and Regards
    dkklau

  • Sample Java  Code to send an HTML mail with embeded image

    Hello,
    Please can I get a sample Java code on sending an HTML mail with embeded image.
    The HTML message and relevant input parameters withhbe supplied from a PL/SQL that will call the class , the class will embed the image and send the mail to the recepient.

    tev wrote:
    Please can I get a sample Java codeNo. This is a forum, not a code mill.
    Recommended reading: How to ask questions the smart way
    db

  • Populate html combo with database

    Hi all, I´m trying to use that example of Multi-select-Combobox , but i must populate the options of the combo with the database select result, not static values,..
    that is the code for the options i´m using at the moment:
    <div class="examples">
    <label class="examples">Second Example of MultiSelect (with width options)</label>
    <select id="methods" name="methods" multiple="multiple" size="4" title="Four" class="arc90_multiselect fieldwidth-20em valuewidth-600px">
         <option value="flex">OPTION1</option>
         <option value="ajax">OPTION2</option>
         <option value="iframes">OPTION3</option>
    </select>
    </div>     
    how can I populate this with my table values?
    that is the site where i get the multiselect - if anyone need it. http://lab.arc90.com/tools/multiselect/
    tnks for help.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="generator" content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" />
    <title></title>
    <title>arc90 lab | tools: MultiSelect</title>
    <style type="text/css">
    /*<![CDATA[*/
                            @import "http://lab.arc90.com/tools/c/css/tool_global.css";     /* Style for this page */
                            .a9multiselect {
                                    width: 9.9em;
                                    font-family: Arial, Helvetica, sans-serif;
                                    position: relative;
                                    height: 22px;
                                    padding: 0;
                                    margin: -.05em 0 1em 0;
                                    border: 0;
                            .a9multiselect .expcol-click, .a9multiselect .expcol-click-open {
                                    background-color: #fff;
                                    border: 1px solid #999;
                                    padding: 0;
                                    margin: 0;
                                    cursor: default;
                                    min-width: 9.8em;
                            .a9multiselect div.expcol-click {
                                    position: absolute;
                                    z-index: 104;
                                    height: 20px;
                            .a9multiselect div.expcol-click-open {
                                    border-bottom: 1px solid #fff;
                            .a9multiselect .title {
                                    font-size: .8em;
                                    height: 1.3em;
                                    line-height: 1.2em;
                                    overflow: hidden;
                                    padding: .3em 1.1em .1em .5em;
                                    background: white url(images/multiselect.gif) no-repeat top right;
                            .a9multiselect .title:hover {
                                    background: white url(images/multiselect-hover.gif) no-repeat top right;
                            .expcol-body {
                                    position: absolute;
                                    z-index: 106;
                                    min-height: 1em;
                                    background: #e9f3f8;
                                    padding: .1em;
                                    display: block;
                                    font-size: 75%;
                                    display: none;
                                    margin-top: -1px;
                                    border: 1px solid #999;
                            .expcol-body ul {
                                    overflow: auto;
                                    min-height: 1em;
                                    min-width: 20em;
                                    margin: 0;
                                    padding: 0;
                            .expcol-body li { margin: 0 0 .2em 0; list-style:none; }
                            .expcol-body li:hover {
                                    background: #ddd;
                            .arc90_multiselect {
                                    width: 12.5em;
                                    height: 1.35em;
                                    visibility: hidden;
                            .a9selectall {
                                    border-bottom: 1px solid #ccc;
                            /* Styles for page layout */
                            DIV.examples {
                                    margin: 0 0 2em 0;
                                    width: 17em;
                                    border: 1px solid #e9e9e9;
                                    padding: .3em;
                            DIV.examples LABEL.examples {
                                    display: block;
                                    margin: 0 0 .2em 0;
                    /*]]>*/
    </style>
    </head>
    <body>That is the .js file: ---------------------------------------------------------
    var a$ = {}; // arc90 namespace functions
    a$.c = 0;
    a$.openSelect = null;
    a$.NO_SELECTION     = 'No selection';
    a$.SELECTED          = 'Options selected';
    a$.SELECT_ALL     = 'Select All';
    a$.SelectAllMin     = 6;
    a$.WhenToUse     = 'class'; // class: based on class arc90_multiselect existing | multiple: based on multiple attributte exists | all: both single and multiple
    a$.msSeparator     = '|';
    a$.appName = navigator.appVersion.toLowerCase();
    a$.isIE = document.all && a$.appName.indexOf('msie') >= 0;
    a$.isSafari = a$.appName.indexOf('safari') >= 0;
    a$.msBodyTimer = null;
    a$.multiSelectCreate = function(o) {
    // can be called directly with the id or object passed in as the first argument
    //  or if a$.WhenToUse is set to class or multiple
         var S = null;
         if (o != null)
              S = [a$.isString(o)? a$.e(o): o];
         else
              S = document.getElementsByTagName('select');
         for (var i = 0, l = 1; i < l; i++) { //S.length
              var s = S;
              if (s != null && ((a$.WhenToUse == 'class' && s.className.indexOf('arc90_multiselect') >= 0) || (a$.WhenToUse == 'multiple' && s.multiple) || (a$.WhenToUse == 'all'))) {
                   var title = s.title, id = s.id, name = s.name;
                   var div = a$.newNode('div', 'a9multiselect-'+ id, 'a9multiselect');
                   var span = a$.newNode('div', 'a9multiselect-'+ id +'-title', 'title');
                   span.setAttribute('title', title);
                   var expcol = a$.newNode('div', 'a9multiselect-click-'+ id, 'expcol-click', '', span, div);
                   var ul = a$.newNode('ul');
                   if (a$.isIE)
                        ul.style.width = '20em';
                   var expbody = a$.newNode('div', 'a9multiselect-body-'+ id, 'expcol-body', '', ul);
                   expbody.style.display = 'none';
                   // Timer Events to auto-close the drop-down when not being used
                   a$.newEvent(div, 'mouseout', function(event) { a$.msBodyTimer = setTimeout('a$.closeSelect("'+ id +'")', 1500); });
                   a$.newEvent(div, 'mouseover', function(event) { clearTimeout(a$.msBodyTimer); a$.msBodyTimer = null; });
                   a$.newEvent(expbody, 'mouseout', function(event) { a$.msBodyTimer = setTimeout('a$.closeSelect("'+ id +'")', 1500); });
                   a$.newEvent(expbody, 'mouseover', function(event) { clearTimeout(a$.msBodyTimer); a$.msBodyTimer = null; });
                   a$.newEvent(ul, 'mouseout', function(event) { clearTimeout(a$.msBodyTimer); a$.msBodyTimer = null; });
                   a$.newEvent(ul, 'mouseover', function(event) { clearTimeout(a$.msBodyTimer); a$.msBodyTimer = null; });
                   if (a$.isIE)
                        var hidden = a$.newNode('<input type="hidden" name="'+ name +'" title="'+ title +'" />', name, '', '', null, div);
                   else {
                        var hidden = a$.newNode('input', name, '', '', null, div);
                        hidden.setAttribute('type', 'hidden');
                        hidden.setAttribute('name', name);
                        hidden.setAttribute('title', title);
                   // insert select all option
                   var m = s.options.length;
                   if (s.multiple && m >= a$.SelectAllMin) {
                        var alli = a$.newNode('li', 'a9selectall-'+ id, 'a9selectall', '', null, ul);
                        if (a$.isIE) {
                             var allbx = a$.newNode('<input type="checkbox" name="a$-'+ a$.c +'" id="a$-'+ a$.c +'" alt="'+ id +'" />', 'a$-'+ (a$.c++), '', '', null, alli);
                             var allbl = a$.newNode('<label for="'+ allbx.id +'" />', '', '', a$.SELECT_ALL, null, alli);
                        } else {
                             var allbx = a$.newNode('input', 'a$-'+ a$.c++, '', '', null, alli);
                             allbx.setAttribute('type', 'checkbox');
                             allbx.setAttribute('alt', id);     
                             var allbl = a$.newNode('label', '', '', a$.SELECT_ALL, null, alli);
                             allbl.setAttribute('for', allbx.id);
                        // call to function to get every checkbox under 'a9multiselect-'+ id a$.T('input', a$.e('a9multiselect-'+ id))
                        eval("a$.newEvent(allbx, 'click', function () { a$.selectAll(a$.e('"+ allbx.id +"')); a$.chk(a$.e('"+ allbx.id +"')); });");
                   var sel = 0;
                   for (var j = 0; j < m; j++) {
                        var value = s.options[j].value, text = s.options[j].text;
                        var li = a$.newNode('li', 'a9-li-'+ a$.c, '', '', null, ul);
                        var d = a$.newNode('div', '', '', '', null, li);
                        var chkType = s.multiple? 'checkbox': 'radio';
                        if (a$.isIE) {
                             var checked = '', onclick = '';
                             if (s.options[j].selected == true) {
                                  checked = ' checked="checked"';
                                  // needed to allow checked entries to be imeadiately activated, but won't work when actually clicked
                                  onclick = " onclick=\"a$.multiSelect(this, '"+ value +"', 'a9multiselect-"+ id +"');\"";
                                  sel++;
                             var chkbx = a$.newNode('<input title="'+ s.options[j].text +'" name="a9multiselect-options-'+ id +'" alt="'+ id +'" type="'+ chkType +'"'+ checked + onclick +' value="'+ value +'" />', 'a$-'+ a$.c++, '_a9checkbox', '', null, li);
                        } else {
                             var chkbx = a$.newNode('input', 'a$-'+ a$.c++, '_a9checkbox', '', null, li);
                             chkbx.setAttribute('type', chkType);
                             chkbx.setAttribute('value', value);
                             chkbx.setAttribute('alt', id);
                             chkbx.setAttribute('title', s.options[j].text);
                             chkbx.setAttribute('name', 'a9multiselect-options-'+ id);
                             if (s.options[j].selected == true) {
                                  chkbx.checked = true;
                                  // needed to allow checked entries to be imeadiately activated, but won't work when actually clicked
                                  chkbx.onclick = "a$.multiSelect(this, '"+ value +"', 'a9multiselect-"+ id +"');";
                                  sel++;
                        a$.newEvent(chkbx, 'click', function(event) {
                             a$.cancelbubble(event); // cancel so li event doesn't get activated
                             if (a$.isIE) // IE has trouble with 'this' being used here
                                  var t = a$.e(document.activeElement.id);
                             else
                                  var t = this;
                             a$.multiSelect(t, t.value, 'a9multiselect-'+ t.alt);
                             a$.chk(t);
                             // uncheck the select all
                             allbx = a$.t('input', a$.e('a9selectall-'+ t.alt));
                             if (allbx) a$.chk(allbx, (allbx.checked = false));
                        a$.newEvent(li, 'click', function() {
                             var t = a$.e('a$-'+ this.id.slice('a9-li-'.length));
                             t.checked = !t.checked;
                             a$.multiSelect(t, t.title, 'a9multiselect-'+ t.alt);
                             a$.chk(t);
                        if (a$.isIE)
                             var label = a$.newNode('<label onclick="a$.cancelbubble(event);" for="'+ chkbx.id +'" />', '', '', text, null, li);
                        else {
                             var label = a$.newNode('label', '', '', text, null, li);
                             label.setAttribute('for', chkbx.id);
                             a$.newEvent(label, 'click', function(event) { a$.cancelbubble(event); }); // cancel so li event doesn't get activated
                        // Hide Radio Buttons for Firefox
                        if (chkType == 'radio' && !a$.isIE) {
                             chkbx.style.visibility = 'hidden';
                             label.style.marginLeft = '-18px';
                   if (sel == m && allbx != null)
                        allbx.setAttribute('checked', true);
                   else if (sel == 0)
                        span.innerHTML = a$.NO_SELECTION;
                   var bs = a$.node_before(s);
                   bs.appendChild(div);
                   bs.appendChild(expbody);
                   // check the className of s to look for fieldwidth- and valuewidth-
                   // if a value is specified without format it's default is pixels
                   // options are value: dynamic, 30, 30px, 30em, etc...
                   // dynamic will only have a min-width value set
                   // if valuewidth is missing, then it's min-width is set to fieldswidths (either default or specified using a$.getStyle)
                   var fieldwidth = s.className.toLowerCase().indexOf('fieldwidth-');
                   var valuewidth = s.className.toLowerCase().indexOf('valuewidth-');
                   if (fieldwidth >= 0) {
                        var q = s.className.slice(fieldwidth);
                        fieldwidth = (q.slice(0, q.indexOf(' ') < 0? q.length: q.indexOf(' '))).slice('fieldwidth-'.length);
                        fieldwidth = parseFloat(fieldwidth) == fieldwidth? fieldwidth+'px': fieldwidth;
                   } else fieldwidth = '';
                   if (valuewidth >= 0) {
                        var q = s.className.slice(valuewidth);
                        valuewidth = (q.slice(0, q.indexOf(' ') < 0? q.length: q.indexOf(' '))).slice('valuewidth-'.length);
                        valuewidth = parseFloat(valuewidth) == valuewidth? valuewidth+'px': valuewidth;
                   } else valuewidth = '';
                   if (fieldwidth != 'dynamic') {
                        expcol.style.width = fieldwidth;
                        div.style.width = fieldwidth;
                   if (valuewidth != 'dynamic')
                        expbody.style.width = valuewidth;
                   expbody.style.minWidth = a$.getStyle(expcol, 'width');
                   if (a$.isIE || a$.isSafari)
                        expbody.style.marginTop = '-1.4em';
                   // remove original select
                   s.parentNode.removeChild(s);
                   // when done perform prep functions
                   a$.expcol(div);
                   a$.multiSelectPrep(div);
    a$.selectAll = function(o) {
         var I = a$.T('input', a$.e('a9multiselect-body-'+ o.getAttribute('alt')));
         for (var i = 0, m = I.length; i < m; i++) {
              var c = I[i];
              if (c.type == 'checkbox' && c.className == '_a9checkbox') {
                   c.checked = o.checked;
                   a$.multiSelect(c.id, c.value, 'a9multiselect-'+ c.getAttribute('alt'));
                   a$.chk(c);
    a$.multiSelect = function(chk, value, parent) {
         var pid = parent.slice('a9multiselect-'.length);
         var to = a$.e(pid);
         chk = a$.isString(chk)? a$.e(chk): chk;
         if (chk.checked) {
              chk.type == 'checkbox'? to.value += a$.msSeparator + value: to.value = value;
         } else
              eval("to.value = to.value.replace(/"+ value +"/g, '');");
         var title = a$.e(parent+'-title');
         // cleans up clogged pipes
         to.value = to.value.replace(/\|{3}/g, a$.msSeparator);
         to.value = to.value.replace(/\|{2}/g, a$.msSeparator);
         to.value = to.value.replace(/^\|(.*)/g, '$1');
         to.value = to.value.replace(/(.*)\|$/g, '$1');
         var cbs = a$.T('input', a$.e('a9multiselect-body-'+ pid)), x = '', v = a$.NO_SELECTION;
         var vals = '', c = 0;
         for (var i = 0, l = cbs.length; i < l; i++)
              if (cbs[i].className == '_a9checkbox' && cbs[i].checked) {
                   vals += cbs[i].title +' | ';
                   c++;
                   if (x == 0) {
                        v = cbs[i].title;
                   } else {
                        v = (x+1) +' '+ a$.SELECTED;
                   x++;
         vals = c > 1? vals.slice(0, vals.length-3): v;
         title.innerHTML = v;
         t = a$.e(pid).title;
         title.title = t == ''? vals: t +' : '+ vals;
    a$.multiSelectPrep = function(parent) {
         if (parent == null) parent = document;
         var pid = parent.id.slice('a9multiselect-'.length);
         var P = a$.T('input', a$.e('a9multiselect-body-'+ pid)), toObj = a$.e(parent.id.slice('a9multiselect-'.length)), to = toObj.value, newto = '';
         for (var i = 0, l = P.length; i < l; i++) {
              if (P[i].type != null && P[i].className == '_a9checkbox') {
                   a$.chk(P[i], false);
                   if (P[i].checked == true) {
                        a$.chk(P[i]);
                        // autoselect and populate the value for default checked items
                        var val = P[i].value;
                        a$.multiSelect(P[i], val, parent.id);
         if (to != '') { // remove any duplicates when reloading with firefox
              to = to.split(a$.msSeparator).sort();
              for (var i = 1, l = to.length; i < l; i++)
                   if (to[i] == to[i-1])
                        to[i-1] = null;
              to = to.toString().replace(/,,/g, ',').replace(/,/g, a$.msSeparator);
              toObj.value = to.indexOf(a$.msSeparator) == 0? to.slice(1): to.length > 1 && to.lastIndexOf(a$.msSeparator) == to.length-1? to.slice(0, to.length-1): to;
    a$.chk = function(c, force) {
         var n = a$.node_after(c);
         if (n != null && n.style) {
              if ((force != null && force) || c.checked) {
                   n.style.fontWeight = 'bold';
                   if (c.type == 'radio') {
                        var R = c.form[c.name];
                        for (var i = 0, l = R.length; i < l; i++) {
                             var r = R[i];
                             if (r.id != c.id)
                                  a$.node_after(r).style.fontWeight = 'normal';
                        a$.expcolclick('a9multiselect-click-'+ c.alt);
              } else {
                   n.style.fontWeight = 'normal';
    a$.closeSelect = function(id) {
         clearTimeout(a$.msBodyTimer);
         a$.msBodyTimer = null;
         var obj = a$.e('a9multiselect-body-'+ id);
         var vis = a$.getStyle(obj, 'display');
         if (vis == 'block') {
              //obj.style.display = 'none';
              a$.expcolclick(a$.e('a9multiselect-click-'+ id));
    a$.is_ignorable = function(nod) {
    return (nod.nodeType == 8) || // A comment node
    ((nod.nodeType == 3) && !(/[^\t\n\r ]/.test(nod.data))); // a text node, all ws
    a$.node_before = function(sib) {
         if (a$.isString(sib))
              sib = a$.e(sib);
         while ((sib = sib.previousSibling)) {
              if (!a$.is_ignorable(sib)) return sib;
         return null;
    a$.node_after = function(sib) {
         while (sib != null && (sib = sib.nextSibling)) {
              if (!a$.is_ignorable(sib)) return sib;
         return null;
    a$.expcol = function(parent) {
         var x = a$.T("div", parent);
         for (var i = 0, l = x.length; i < l; i++)
              if (x[i].className.indexOf("-click") >= 0) x[i].onclick = a$.expcolclick;
    a$.expcolclick = function(o, force) {
         var c = null;
         if (a$.isIE)
              var t = this.id? this: a$.isString(o)? a$.e(o): o;
         else
              var t = this.toString().toLowerCase().indexOf('element') >= 0? this: a$.isString(o)? a$.e(o): o;
         c = a$.e('a9multiselect-body-'+ t.id.slice('a9multiselect-click-'.length));
         c.style.position = 'absolute';
         if (c != null && c.style && c.style.display != "block") {
              if (t.className.indexOf("-open") > 0) return;
              t.className = t.className +"-open";
              c.style.display = "block";
              if (force == null || force == false) {
                   if (a$.openSelect && a$.openSelect.id != t.id)
                        a$.expcolclick(a$.openSelect, true);
                   a$.openSelect = t;
         } else if (c != null && c.style) {
              t.className = t.className.substr(0, t.className.length-5);
              c.style.display = "none";
              if (force == null || force == false) {
                   a$.openSelect = null;
    a$.isString = function(o) { return (typeof(o) == "string"); }
         tp: type (eg 'div')
         id: id
         cs: class OR style (if a : exists it is a style (color: pink; display: block;), not a class)
         tx: text to display inside the node
         cd: any child node with which to place inside
         p: parent node to attach to
    a$.newNode = function(tp, id, cs, tx, cd, p) {
         var node = document.createElement(tp);
         if (tx != null && tx != '')
              node.appendChild(document.createTextNode(tx));
         if (id != null && id != '')
              node.id = id;
         if (cs != null && cs != '' && cs.indexOf(':') < 0)
              node.className = cs;
    // inline styles removed to limit code to this specific task
    //     else if (cs != null && cs != '' && cs.indexOf(':') > 0)
    //          a$.setStyles(node, cs);
         if (cd != null)
              node.appendChild(cd);
         if (p != null && p != '')
              (a$.isString(p)? a$.e(p): p).appendChild(node);
         return node;
    // specific element via id
    a$.e = function(id, source) {
         if (source != null)
              return source.getElementById(id);
         return document.getElementById(id);
    // all elements with tag
    a$.T = function(tag, source) {
         if (source != null)
              return source.getElementsByTagName(tag);
         return document.getElementsByTagName(tag);
    // the first element with tag
    a$.t = function(tag, source) {
         if (source != null)
              var T = source.getElementsByTagName(tag);     
         else T = document.getElementsByTagName(tag);
         if (T.length > 0)
              return T[0];
    // all elements with class
    a$.C = function(classname, source) {
         if (source != null)
              return source.getElementsByClassName(classname);
         return document.getElementsByClassName(classname);
    a$.getStyle = function(obj, styleIE, styleMoz) {
         if (styleMoz == null) styleMoz = styleIE;
         if (a$.isString(obj)) obj = a$.e(obj);
         var s = '';
         if (window.getComputedStyle)
              s = document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleMoz);
         else if (obj.currentStyle)
              s = obj.currentStyle[styleIE];
         if (s == 'auto')
              switch (styleIE) {
              case 'top':          return obj.offsetTop;          break;
              case 'left':     return obj.offsetLeft;          break;
              case 'width':     return obj.offsetWidth;          break;
              case 'height':     return obj.offsetHeight;     break;
         else
              return s;
    a$.newEvent = function(e, meth, func, cap) {
         if (a$.isString(e))     e = a$.e(e);
         if (e.addEventListener){
              e.addEventListener(meth, func, cap);
         return true;
         }     else if (e.attachEvent)
              return e.attachEvent("on"+ meth, func);
         return false;
    // Start things off
    a$.newEvent(window, 'load', function () {
         var x = a$.T('select');
         for (var i = 0, l = x.length; i < l; i++) {
              a$.multiSelectCreate(x[i]);
    a$.cancelbubble = function(e) {
         if (a$.isIE) e = event;
         if (e) e.cancelBubble = true;
    function noop() {
         return null;     
    Edited by: brugo on 07/12/2009 10:47
    Edited by: brugo on 07/12/2009 10:49
    Edited by: brugo on 07/12/2009 10:50
    Edited by: brugo on 07/12/2009 10:51
    Edited by: brugo on 07/12/2009 11:03

  • Problem with java swing button and loop

    Problem with java swing button and loop
    I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
    I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
    When I click on start button it must do next:
    Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
    And when I click on stop button it must do next:
    Start button must set enabled and selected and Stop button must set disenabled.
    Field status is set to 0.
    This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
    There is java code, so you can get better picture:
    /** start button */
    public void gStart_ActionEvents() {
    try {
    ivjGStart.setEnabled(false);
    ivjGStop.setEnabled(true);
    ivjGStop.setSelected(true);
    getJTextPane1().setText("Program is running ...");
    Status = 1;
    } catch (Exception e) {}
    /** stop button */
    public void gStop_ActionEvents() {
    try {
    ivjGStart.setEnabled(true);
    ivjGStart.setSelected(true);
    ivjGStop.setEnabled(false);
    getJTextPane1().setText("Program is NOT running ...");
    Status = 0;
    } catch (Exception e) {
    /** procedure IzvajajNeprekinjeno() */
    public void IzvajajNeprekinjeno() {  //RunLoop
    try {
    int zamik = 2000; //delay
    do {
    Thread.sleep(zamik);
    PreberiDat(); //procedure
    } while (Status == 1);
    } catch (Exception e) {
    So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
    Any help will be appreciated.
    Best regards,
    Tomi

    This is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
    Since java is task-based this will happen if you do like this:
    1. Button "Start" is pressed. Thread running: GUI_Thread
    2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
    3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
    4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
    5. Call PreberiDat(). Thread running: GUI_Thread
    6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
    Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
    What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    This tutorial explains how to build a multi threaded gui.
    /Lime

  • Problem with Java Script after upgrade from BW 3.5 to BI7

    Dear Colleagues,
    We're facing the issue with Java Script after upgrade of BW 3.5 to BI7.
    Just after update we checked the basic functionality and it occured that some of web templates that use Java Script don't work. They generate seelction screen, but after selection the screen becomes blank without any error messages.
    We're currently stucked since web templates weren't converted to BI7 version so they should work exactly as before the upgrade.
    We compared the Java code with other environment that was not upgraded - it's perfectly the same.
    The only explanation that comes to my mind is that some Java Script settings on the server level were changed during the upgrade but I have no idea where I can check that.
    Thanks in advance for any suggestions,
    Andrzej Bobula

    Hi Deepu,
    Thanks, it was great to read your reply and then few minutes later talk to you live on SDN Day!
    Unfortunately, http cache clean-up did not help. But there is another funny thing I found - for exactly the same 3.5 webtemplate html code returned from WebAS 3.5 was different then from 7.0.
    Unfortunately, this editor does not allow to paste complete code, even in CODE brackets, but here are main differences:
    <b>3.5</b>
       if (navigator.appName == "Microsoft Internet Explorer")
    <frame src="/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=1&REQUEST_NO=1&CMD=GET_TEMPLATE"
    name="Content">
    and
    <b>7.0</b>
       if (navigator.appName.indexOf("Microsoft Internet Explorer")!=-1)
    <frame src="/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=8&REQUEST_NO=0&CMD=GET_TEMPLATE"
    name="Content" 0nLoad="javascript:loadTitle()">
    (I intentionaly put 0 i/o o in 0nLoad, otherwise Forum's editor does not accept the text.
    How about SAP's claim that technical upgrade from 3.x to 7.0 changes nothing?
    Regards,
    Vitaliy

  • How to submit a html form using java

    hi friends,
    i have a html form with some input fields, when ever a user submit the form the user information is stored in the database. is it possible to pass the user information in the url(url rewriting) and submit it by a java program so that the data will be stored in the database, as like as, user submit it manually.
    for eg:
    /*sample.html*/
    <form action="store.jsp" method="post">
    User Data:<input type="text" name="userdata">
    <input type="submit">
    </form>
    in my java is it possible to store the record as below:
    URL url=new URL("http://localhost:7001/webapp/store.jsp?userdata=AutomaticDatasave");
    URLConnection con=url.openConnection();
    int i=0;
    while((i=con.getInputStream().read())!=-1)
    System.out.print(i);/*it has to print the data that store.jsp is returned like information stored or error storing data(what ever)*/
    }Edited by: rajaram on Oct 27, 2007 1:01 AM

    hi Drclap,
    Thanks for your reply, which is helpful to me....
    tried what you said, what i did is modified the code like below
    con.setDoOutput(true);
    BufferedWriter br=new BufferedWriter(new InputStreamWriter(con.getOutputStream()));
    String str="userdata=AutomateDataSave\n";
    br.write(str,0,str.length());
    br.flush()But
    Iam Getting Internal Server Error
    Exception in thread "main" java.io.IOException: Server returned HTTP response code: 500 for URL
    Edited by: rajaram on Oct 27, 2007 1:24 AM

  • How to set an attribute of a HTML tag with a value in the Servlet

    I have a HTML page and a Servlet.
    The HTML page sends a request to the Servlet.
    The Servlet has to read the contents of the HTML page. When the Servlet encounters the body tag it should set the bgcolor attribute of the body tag with a string(For eg.a string called color with a value blue) in the servlet.
    After doing this the Servlet has to update the original HTML page with the changes (in the body tag).
    I need a help on this.

    Hi sangee,
    you could get what you want to do by using a Java Server Page instead of both a HTML page and a Servlet.
    I should code something like this:
    <%Strung color="yourColor"%>
    <html><head><title></title></head>
    <body bgcolor="<%=color%>
    </body>
    </html>

  • XML Publisher report failing with java.lang.outofmemoryerror.

    Hi,
    We have developed a custom Oracle report that produces an XML output file that is about 13M in size (about 18K rows from the database). When running report as concurrent request, post processing fails with java.lang.outofmemoryerror. The failure occurs when specifying output format as Excel, RTF or HTML. However, the process completes successfully when specifying output format as PDF. We have also noticed that Excel, RTF and HTML will complete successfully if the XML data file is smaller (around 3M).
    Is anyone aware of a restriction on the size of the XML data file when specifying output formats Excel, RTF or HTML? We have tried setting temp directory but that has not helped.
    Thanks.

    Hi
    I found this at metalink [Note:390968.1].. hope it helps =)
    Symptoms: When attempting to run an XML Publisher concurrent program the following error occurs:
    ERROR: Warning!!! Got out of memory exception, retrying with scalable option..
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    Oracle.apps.xdo.oa.cp.JCP4XDODataEngine
    Program exited with status 1
    Solution: To implement the solution, please execute the following steps:
    1. Login select the responsibility: System Administrator.
    2. Navigate to Concurrent > Program > Define.
    3. Query for concurrent program that is receiving the error.
    4. In the 'Options' field please enter -Xmx512M.
    5. Save the change and retest the issue.
    6. If the report still fails with the option set to -Xmx512M change the value to -Xmx1024M, save and try again
    7. Migrate the solution as appropriate to other environments.

Maybe you are looking for