protected void setProperties(UIComponent component) { super.setProperties(component); // FacesContext context = getFacesContext(); TagUtil.setInteger(component, "height", height); TagUtil.setInteger(component, "width", width); TagUtil.setInteger(component, "wait", wait); TagUtil.setInteger(component, "elapsed", elapsed); TagUtil.setString(component, "expireScript", expireScript); }
@Override public void doTag() throws JspException { boolean testValue; try { testValue = Convert.toBooleanValue(test, false); } catch (TypeConversionException ignore) { testValue = false; } if (testValue == true) { TagUtil.invokeBody(getJspBody()); } }
public static void addModifierTooltips(ItemStack stack, List<String> tooltips) { NBTTagList tagList = TagUtil.getModifiersTagList(stack); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = tagList.getCompoundTagAt(i); ModifierNBT data = ModifierNBT.readTag(tag); // get matching modifier IModifier modifier = TinkerRegistry.getModifier(data.identifier); if (modifier == null || modifier.isHidden()) { continue; } tooltips.add(data.getColorString() + modifier.getTooltip(tag, false)); } }
public void setProperties(UIComponent component) { super.setProperties(component); if (component == null) { return; } TagUtil.setInteger(component, "showpages", showpages); TagUtil.setString(component, "dataTableId", dataTableId); TagUtil.setString(component, "controlId", controlId); TagUtil.setString(component, "styleClass", styleClass); TagUtil.setString(component, "selectedStyleClass", selectedStyleClass); TagUtil.setBoolean(component, "showLinks", showLinks); }
public TooltipBuilder addModifierInfo() { NBTTagList tagList = TagUtil.getModifiersTagList(stack); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = tagList.getCompoundTagAt(i); ModifierNBT data = ModifierNBT.readTag(tag); // get matching modifier IModifier modifier = TinkerRegistry.getModifier(data.identifier); if (modifier == null || modifier.isHidden()) { continue; } for (String string : modifier.getExtraInfo(stack, tag)) { if (!string.isEmpty()) { tips.add(data.getColorString() + string); } } } return this; }
/** goStartTag will be called when we see the "a" tag */ public int doStartTag() throws JspException { // this link could be part of a menu or not WallMenu menu = (WallMenu) findAncestorWithClass(this, WallMenu.class); if (menu != null) { inside_menu = true; } // WallDocument document = (WallDocument) findAncestorWithClass(this, // WallDocument.class); WallDocument document = (WallDocument) pageContext.getAttribute("wall-document", PageContext.REQUEST_SCOPE); try { ObjectsManager objectsManager = WurflServletInit.getObjectsManager(); cm = objectsManager.getCapabilityMatrixInstance(); uam = objectsManager.getUAManagerInstance(); request = (HttpServletRequest) pageContext.getRequest(); // Check the capability string warning = TagUtil.checkCapability("preferred_markup"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent UA = TagUtil.getUA(this.request); device_id = uam.getDeviceIDFromUALoose(UA); mark_up = cm.getCapabilityForDevice(device_id, "preferred_markup"); mark_up = TagUtil.getWallMarkup(mark_up); if (inside_menu) { // XHTML first if (mark_up.startsWith("xhtmlmp")) { fancy_ok = menu.colorize && menu.menu_css_tag && menu.table_and_css_background; // if the user wants to do it fancy and the device allows for it if (fancy_ok) { try { JspWriter out = pageContext.getOut(); String bgcolorstyle = menu.getBGColor(); out.print("<tr>"); out.print(" <td class=\"" + bgcolorstyle + "\">"); String an = ""; // autonumber if (menu.getAutonumber()) { an = menu.getAutonumber_index(); out.print(" " + an); out.print(" <a accesskey=\"" + an + "\""); } else { // maybe mark-up defines it's own if (!accesskey.equals("")) { out.print(" " + accesskey + " <a accesskey=\"" + accesskey + "\""); } else { out.print("<a"); } } // tel number scheme: warning = TagUtil.checkCapability("xhtml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "xhtml_make_phone_call_string"); out.print(" href=\"" + telnum + tel + "\">"); } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } else { // for whatever reason, no fancy XHTML menus try { JspWriter out = pageContext.getOut(); out.print("<li>"); // generate icon? if (document != null && !opwv_icon.equals("")) { if (document.getUseXHTMLExtensions()) { out.print("<img localsrc=\"" + opwv_icon + "\" src=\"\" alt=\"\"/> "); } } String an = ""; // autonumber if (menu.getAutonumber()) { an = menu.getAutonumber_index(); out.print("<a accesskey=\"" + an + "\""); } else { // maybe mark-up defines it's own if (!accesskey.equals("")) { out.print("<a accesskey=\"" + accesskey + "\""); } else { out.print("<a"); } } // tel number scheme: warning = TagUtil.checkCapability("xhtml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "xhtml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\">"); } else { out.print(" href=\"#\">" + alt); } } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } } // CHTML if (mark_up.startsWith("chtml")) { try { JspWriter out = pageContext.getOut(); String an = ""; // autonumber if (menu.getAutonumber()) { an = menu.getAutonumber_index(); String emoji = getEmoji(an); out.print(emoji + " <a acceskey=\"" + an + "\""); } else { // maybe mark-up defines it's own if (!accesskey.equals("")) { String emoji = getEmoji(accesskey); out.print(emoji + " <a accesskey=\"" + accesskey + "\""); } else { out.print("<a"); } } // tel number scheme: warning = TagUtil.checkCapability("chtml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "chtml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\""); // cti if (!cti.equals("")) { out.print(" cti=\"" + cti + "\""); } out.print(">"); } else { out.print(" href=\"#\">" + alt); } } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } // WML if (mark_up.startsWith("wml")) { try { JspWriter out = pageContext.getOut(); // If possible, do menus with select/option/onpick warning = TagUtil.checkCapability("menu_with_select_element_recommended"); if (warning.length() > 0) { throw new JspException(warning); } wml_menu_with_select = cm.getCapabilityForDevice(device_id, "menu_with_select_element_recommended"); if (wml_menu_with_select.equals("true")) { // tel number scheme: warning = TagUtil.checkCapability("wml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "wml_make_phone_call_string"); if (!telnum.equals("none")) { out.print("<option onpick=\"" + telnum + tel + "\">"); } else { out.print("<option onpick=\"#\">" + alt); } // generate icon? if (document != null && !opwv_icon.equals("")) { if (document.getUseWMLExtensions()) { out.print("<img localsrc=\"" + opwv_icon + "\" src=\"\" alt=\"\"/>"); } } } else { // Render with Hyperlinks. extra check for WML. accesskey support warning = TagUtil.checkCapability("access_key_support"); if (warning.length() > 0) { throw new JspException(warning); } accesskey_ok_str = cm.getCapabilityForDevice(device_id, "access_key_support"); if (accesskey_ok_str.equals("true")) { accesskey_ok = true; } @SuppressWarnings("unused") String an = ""; // autonumber // accesskey for WML is tricky: extra check accesskey support by // WML browser // SECOND THOUGHT: I get problems with GATEWAY. removing accesskey // for WML for the time being if (menu.getAutonumber() && accesskey_ok) { an = menu.getAutonumber_index(); out.print("<a"); // out.print("<a accesskey=\""+an+"\""); } if (!menu.getAutonumber() && accesskey_ok) { // maybe mark-up defines it's own if (!accesskey.equals("")) { out.print("<a"); // out.print("<a accesskey=\""+accesskey+"\""); } else { out.print("<a"); } } if (!accesskey_ok) { out.print("<a"); } // tel number scheme: warning = TagUtil.checkCapability("wml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "wml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\">"); } else { out.print(" href=\"#\">" + alt); } } } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } } else { // ************ NOT inside a menu! PLAIN LINK!******************** if (mark_up.startsWith("xhtmlmp")) { try { JspWriter out = pageContext.getOut(); // accesskey? if (!accesskey.equals("")) { out.print("<a accesskey=\"" + accesskey + "\""); } else { out.print("<a"); } // tel number scheme: warning = TagUtil.checkCapability("xhtml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "xhtml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\">"); } else { out.print(" href=\"#\">" + alt); } } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } // end XHTML // CHTML if (mark_up.startsWith("chtml")) { try { JspWriter out = pageContext.getOut(); if (!accesskey.equals("")) { out.print("<a accesskey=\"" + accesskey + "\""); } else { out.print("<a"); } // tel number scheme: warning = TagUtil.checkCapability("chtml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "chtml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\""); // cti if (!cti.equals("")) { out.print(" cti=\"" + cti + "\""); } out.print(">"); } else { out.print(" href=\"#\">" + alt); } } catch (IOException ioe) { System.out.println("Error in a tag <a>: " + ioe); } return (EVAL_BODY_INCLUDE); } // WML if (mark_up.startsWith("wml")) { try { JspWriter out = pageContext.getOut(); if (accesskey_ok) { // maybe mark-up defines it's own if (!accesskey.equals("")) { out.print("<a"); // Accesskey interferes with gateways and WML 1.1 DTD // out.print("<a accesskey=\""+accesskey+"\""); } else { out.print("<a"); } } if (!accesskey_ok) { out.print("<a"); } // tel number scheme: warning = TagUtil.checkCapability("wml_make_phone_call_string"); if (warning.length() > 0) { throw new JspException(warning); } // get the user agent String telnum = cm.getCapabilityForDevice(device_id, "wml_make_phone_call_string"); if (!telnum.equals("none")) { out.print(" href=\"" + telnum + tel + "\">"); } else { out.print(" href=\"#\">" + alt); } } catch (IOException ioe) { System.out.println("Error in a tag <caller>: " + ioe); } return (EVAL_BODY_INCLUDE); } } } catch (Exception e) { System.out.println("Error in WALL tag 'caller': " + e.getMessage()); System.out.println("Error: " + e.toString()); } return (SKIP_BODY); }
public int doStartTag() throws JspException { try { this.pages = ((Pages) TagUtil.getInstance().lookup(this.pageContext, this.name, this.scope)); JspWriter out = this.pageContext.getOut(); out.println("<div class=\"text-center\">"); out.println("<script>"); out.println( "function trunPage(value){document.formPage.currentPage.value = value;document.formPage.submit();}"); out.println("</script>"); out.println( "<form name=\"formPage\" action=\"" + this.action + "\" method=\"" + this.method + "\"> "); out.println( "<input type=\"hidden\" name=\"currentPage\" id=\"currentPage\" value=\"" + this.pages.getPage() + "\">"); out.println( "<input type=\"hidden\" name=\"pageSize\" id=\"pageSize\" value=\"" + this.getPageSize() + "\">"); out.println("<ul id=\"visible-pages-example\" class=\"pagination\">"); // out.println("<li><i>Showing "+this.pages.getFirstItemIndex()+" to // "+this.pages.getLastItemIndex()+" of "+this.pages.getReCount()+" entries</i></li>"); if (this.pages.getPage() != 1) { out.println("<li class=\"first\"><a href=\"" + getHref(1) + "\">第一页</a></li>"); out.println( "<li class=\"prev\"><a href=\"" + getHref(this.pages.getPage() - 1) + "\">上一页</a></li>"); } else { out.println("<li class=\"first disabled\"><a href='javascript:void(0)'>第一页</a></li>"); out.println("<li class=\"prev disabled\"><a href='javascript:void(0)'>上一页</a></li>"); } // out.println("<li><ol>"); int startpage; // 页面中的起始页 int endpage; // 页面中的结束页 int _showPage = Integer.parseInt(this.showPage); if (this.pages.getRePages() < _showPage) { startpage = 1; // 页面中起始页就是1 endpage = this.pages.getRePages(); // 页面中的最终页就是总页数 } else { /** else中是总页数大于4的情况 */ /** 首先当前页的值是否小于等于4 */ if (this.pages.getPage() <= _showPage) { startpage = 1; // endpage = this.pages.getPage() + 2; endpage = _showPage; /** 判断页面的最终页是否大于总页数 */ if (endpage >= this.pages.getRePages()) { endpage = this.pages.getRePages(); } } else { startpage = this.pages.getPage() - 2; endpage = this.pages.getPage() + _showPage - 3; if (endpage >= this.pages.getRePages()) { endpage = this.pages.getRePages(); if (this.pages.getRePages() < _showPage) { startpage = 1; } else { startpage = endpage - _showPage + 1; } } } } for (int i = startpage; i <= endpage; i++) { if (i == this.pages.getPage()) { out.println("<li class=\"page active\"><a>" + i + "</a></li>"); } else { out.println("<li class=\"page\"><a href=\"" + getHref(i) + "\">" + i + "</a></li>"); } } // out.println("</ol></li>"); if (this.pages.getPage() < this.pages.getRePages()) { out.println( "<li class=\"next\"><a href=\"" + getHref(this.pages.getPage() + 1) + "\">下一页</a></li>"); out.println( "<li class=\"last\"><a href=\"" + getHref(this.pages.getRePages()) + "\">最后一页</a></li>"); } else { out.println("<li class=\"next disabled\"><a href='javascript:void(0)'>下一页</a></li>"); out.println("<li class=\"last disabled\"><a href='javascript:void(0)'>最后一页</a></li>"); } /* out.println("<li> 每页<select name=\"pageSize\" id=\"pageSize\" style=\"width:80px;\" onchange='trunPage("+this.pages.getPage()+")'>" + "<option value=\"10\" "+(this.pages.getPageSize()==10?"selected='selected'":"")+">10</option>" + "<option value=\"20\" "+(this.pages.getPageSize()==20?"selected='selected'":"")+">20</option>" + "<option value=\"50\" "+(this.pages.getPageSize()==50?"selected='selected'":"")+">50</option>" + "<option value=\"100\" "+(this.pages.getPageSize()==100?"selected='selected'":"")+">100</option>" + "</select>条</li>");*/ out.println( "<li style=\"line-height:30px;padding-left:20px;color:red;\">合计:" + this.pages.getReCount() + "条记录, 共" + this.pages.getRePages() + "页.</li>"); out.println("</ul>"); out.println("</div>"); // out.println("<script>"); // out.println("function pageFormSetPageSize(form,value){ var p1 = /^\\d{1,}$/; // if(!p1.test(value)){alert(\"分页只能是数字!\");return ; } form.submit();}"); // out.println("function pageFormGo(form,value){ form.Pg.value = value; form.submit();}"); // out.println("function pageFormSetPg(form,value){ var p1 = /^\\d{1,}$/; // if(!p1.test(value)){alert(\"分页只能是数字!\");return ; } form.Pg.value = value;form.submit();}"); // out.println("</script>"); // out.println("<form name=\"formPage\" action=\"" + this.action // + "\" method=\"" + this.method + "\"> "); // // out.println("每页显示<input name=\"pageSize\" // onblur=\"pageFormSetPageSize(this.form,this.value)\" value=\"" // + this.pages.getPageSize() // + "\" type=\"text\" id=\"pageSize\" style=\"width:20px; border:solid #CCC 1px\"/>"); // out.println("条 | 共<font color=\"red\">" // + this.pages.getRePages() + "</font>页 , <font color=\"red\">" // + this.pages.getReCount() + "</font>条数据"); // // out.println(" | "); // // out.println("<input type=\"button\" " // + (this.pages.getPage() == 1 ? "disabled=\"disabled\"" : "") // + " onclick=\"pageFormGo(this.form,1)\" name=\"button\" id=\"button\" value=\"首页\" // style=\"background:#FFF ; border:none; cursor:pointer\"/> "); // out.println("<input type=\"button\" " // + (this.pages.getPage() == 1 ? "disabled=\"disabled\"" : "") // + " onclick=\"pageFormGo(this.form," // + (this.pages.getPage() - 1) // + ")\" name=\"button\" id=\"button\" value=\"上一页\" style=\"background:#FFF ; // border:none; cursor:pointer\"/> "); // // out.println("<input type=\"button\" " // + (this.pages.getPage() >= this.pages.getRePages() ? "disabled=\"disabled\"" // : "") // + " onclick=\"pageFormGo(this.form," // + (this.pages.getPage() + 1) // + ")\" name=\"button\" id=\"button\" value=\"下一页\" style=\"background:#FFF ; // border:none; cursor:pointer\"/> "); // out.println("<input type=\"button\" " // + (this.pages.getPage() >= this.pages.getRePages() ? "disabled=\"disabled\"" // : "") // + " onclick=\"pageFormGo(this.form," // + this.pages.getRePages() // + ")\" name=\"button\" id=\"button\" value=\"尾页\" style=\"background:#FFF ; // border:none; cursor:pointer\"/> "); // // out.println(" | 第<input name=\"Pg\" // onblur=\"pageFormSetPg(this.form,this.value)\" value=\"" // + this.pages.getPage() // + "\" type=\"text\" id=\"Pg\" style=\"width:20px; border:solid #CCC 1px\"/>页"); } catch (Exception e) { throw new JspException("分页标签出错了..." + e); } return 6; }