Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Onclick event for a div to show a popup window

    Hi

    I want to add onclick function for a div in tile grid so that when i click on that div a new pop window will appear . When i tried to append onclick function using string bulider the follwing error occures .

    *********************** The method append(Object) in the type StringBuilder is not applicable for the arguments (void)****************

    Is their any other way to add onclick function for a div.How can I over come this issue . Iam including the code which appends the various div elements in a tile grid cell.



    final StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("<div class='articleTile'>");
    {
    stringBuilder.append("<div class='context'>");
    {
    stringBuilder.append("<div class='icon-product'>").append("<div class='icon ").append(getProductTypeClass(record)).append("'></div>").append("</div>");
    stringBuilder.append("<div class='divider'>|</div>");

    if (record.getAttributeAsInt("letid") == 0) {
    stringBuilder.append("<div class='icon-star'>");
    } else {
    stringBuilder.append("<div class='icon-star icon-star-gold'>");
    }

    stringBuilder.append("<i class='fa fa-star'></i></div>");
    stringBuilder.append("<div class='Ceoname'>").append(defaultIfNullAttribute("source", record)).append("</div>");

    final String author = record.getAttribute("author");

    if (author != null && author.trim().length() > 0) {
    stringBuilder.append("<div class='divider'>|</div>");
    stringBuilder.append("<div class='ownerName'>").append(record.getAttribute("author")).append("</div>");
    }

    stringBuilder.append("<div class='divider'>|</div>");
    stringBuilder.append("<div class='crtdDate'>").append(DateUtil.format(record.getAttributeAsDate("harvesttime"), "d-MMM-YYYY")).append("</div>");

    stringBuilder.append("<div class='divider'>|</div>");
    stringBuilder.append("<div class=''>").append("<i class='sample-copy' title='Syndicates'></i> ").append(record.getAttributeAsInt("Count"));
    stringBuilder.append("</div>");

    stringBuilder.append("<div class='abst_ind_article' align=right> <a onclick=").append(modelwindow.show()).append("></a>+ Add to name list</div>");
    }
    stringBuilder.append("</div>");

    stringBuilder.append("<div class='headline'><a target='_blank' href='").append(record.getAttribute("eurl")).append("'>").append(defaultIfNullAttribute("headline", record)).append("</a></div>");
    stringBuilder.append("<div class='content'>").append(getContent(record)).append("</div>");
    }
    stringBuilder.append("</div>");

    return stringBuilder.toString();
    }



    *****I have to add onclick for div class='abst_ind_article'.


    Thanks

    #2
    StringBuilder is a core JDK class, not something provided by SmartGWT. It looks like one of your calls to append() is passing the result of a method that returns void, so this is just a basic Java coding problem..

    We should also mention, this code looks circa 2001 - you definitely do not want to be writing code in this style, as it exposes you to all the HTML and CSS inconsistencies between browsers. Use SmartGWT components instead.

    Comment

    Working...
    X