简体   繁体   中英

Vaadin Ordered and Unordered List

can you help me out how to add unordered list and ordered list using vaadin.

While searhing for that i have found ULElement but it is an interface, how we can create object for this one

Please help me Thanks In Advance

Created an own Java class:

public class HtmlUnorderedList {
    private List<String> listElements = new ArrayList<>();

    public void addListItem(String listItem) {
        listElements.add("<li>" + listItem + "</li>");
    }

    public String getHtml(String classNames) {
        String openingTag = "<ul>";
        if(StringUtils.isNotEmpty(classNames)) {
            openingTag = String.format("<ul class=\"%s\">", classNames);
        }
        return openingTag + StringUtils.join(listElements, "") + "</ul>";
    }
}

css:

     ul.additionalEvents {
        margin: 0;
        padding-left: 35px;
        padding-top: 10px;
        padding-bottom: 5px;
        color: gray;
        overflow: hidden;
     }

Implementation after adding list elements to (HtmlUnorderedList) component:

new Label(((HtmlUnorderedList) component).getHtml("additionalEvents"), ContentMode.HTML)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM