Search code examples
mgwtcelllist

adding text and image each celllist cell in MGWT


Can you help me on adding of both text and image to the cell list cell in mgwt I did only for text,but failing to place both text and image.waiting for your valuable response.


Solution

  • In a cell you can use whatever markup you want to use. This is no different from GWT standard cell widgets and their cells.

    This is a basic example taken from the mgwt showcase and modified to include an img tag in the markup:

    public abstract class BasicCell<T> implements Cell<T> {
    
        private static Template TEMPLATE = GWT.create(Template.class);
    
        public interface Template extends SafeHtmlTemplates {
            @SafeHtmlTemplates.Template("<div>{0} <img src="{1}"/></div>")
            SafeHtml content(String text, String imgUrl);
    
        }
    
        @Override
        public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) {
            safeHtmlBuilder.append(TEMPLATE.content("text", "someUrl.jgp"));
    
        }
    
        public abstract String getDisplayString(T model);
    
        @Override
        public boolean canBeSelected(T model) {
            return false;
        }
    
    }