1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| package org.zaozaool.ui;
import org.jmesa.core.CoreContext; import org.jmesa.view.html.HtmlUtils; import org.jmesa.view.html.toolbar.AbstractItemRenderer; import org.jmesa.view.html.toolbar.HtmlToolbar; import org.jmesa.view.html.toolbar.ImageItem; import org.jmesa.view.html.toolbar.MaxRowsItem; import org.jmesa.view.html.toolbar.ToolbarItem; import org.jmesa.view.html.toolbar.ToolbarItemRenderer; import org.jmesa.view.html.toolbar.ToolbarItemType; import org.jmesa.web.WebContext;
* * @author zaozaool */ public class TestListToolbar extends HtmlToolbar {
@Override public String render() { ImageItem item = new ImageItem(); item.setCode("Search"); item.setTooltip("Search"); item.setImage(getImage("out/search_.jpg", getWebContext(), getCoreContext())); item.setOnmouseout("$(this).attr('src','" + getImage("out/search_.jpg", getWebContext(), getCoreContext()) + "')"); item.setOnmouseover("$(this).attr('src','" + getImage("search.jpg", getWebContext(), getCoreContext()) + "')"); item.setAlt("Search"); item.setAction("javascript:queryMember()"); ToolbarItemRenderer renderer = new Render(item, getCoreContext()); item.setToolbarItemRenderer(renderer); addToolbarItem(item);
addToolbarItem(ToolbarItemType.FIRST_PAGE_ITEM); addToolbarItem(ToolbarItemType.PREV_PAGE_ITEM); addToolbarItem(ToolbarItemType.NEXT_PAGE_ITEM); addToolbarItem(ToolbarItemType.LAST_PAGE_ITEM);
addToolbarItem(ToolbarItemType.PAGE_NUMBER_ITEMS);
MaxRowsItem maxRowsItem = (MaxRowsItem) addToolbarItem(ToolbarItemType.MAX_ROWS_ITEM); if (getMaxRowsIncrements() != null) { maxRowsItem.setIncrements(getMaxRowsIncrements()); }
return super.render();
}
private static String getImage(String image, WebContext webContext, CoreContext coreContext) { String imagesPath = HtmlUtils.imagesPath(webContext, coreContext); return imagesPath + image; }
private static class Render extends AbstractItemRenderer {
public Render(ToolbarItem item, CoreContext coreContext) { setToolbarItem(item); setCoreContext(coreContext); }
public String render() { ToolbarItem item = getToolbarItem(); return item.enabled(); } }
}
|