<render-kit>
<description>Some replacements for the standard renderers</description>
<renderer>
<description>Replacement renderer for h:outputLabel</description>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Label</renderer-type>
<renderer-class>com.mycompany.app.webapp.jsf.LabelRenderer</renderer-class>
</renderer>
<renderer>
<description>Replacement renderer for h:panelGrid that uses lists instead of tables</description>
<component-family>javax.faces.Panel</component-family>
<renderer-type>javax.faces.Grid</renderer-type>
<renderer-class>com.mycompany.app.webapp.jsf.PanelGridRenderer</renderer-class>
</renderer>
</render-kit>
public class LabelRenderer extends Renderer {
protected final Log log = LogFactory.getLog(LabelRenderer.class);
public boolean getRendersChildren() {
return false;
}
public void encodeBegin(FacesContext context, UIComponent component)
throws java.io.IOException {
ResponseWriter writer = context.getResponseWriter();
Map attrs = component.getAttributes();
String id = (String) attrs.get("for");
UIInput input = null;
if (!StringUtils.isEmpty(id)) {
input = (UIInput) component.findComponent(id);
}
writer.startElement("label", component);
String styleClass = (String) component.getAttributes().get("styleClass");
boolean hasErrors = hasMessages(context, input);
if (styleClass != null) {
if (hasErrors) styleClass += " error";
writer.writeAttribute("class", styleClass, null);
} else if (hasErrors) {
writer.writeAttribute("class", "error", null);
}
String renderedId =
(input != null) ? input.getClientId(context)
: component.getClientId(context);
writer.writeAttribute("for", renderedId, null);
writer.write(attrs.get("value").toString());
}
public void encodeEnd(FacesContext context, UIComponent component)
throws java.io.IOException {
ResponseWriter writer = context.getResponseWriter();
Map attrs = component.getAttributes();
String id = (String) attrs.get("for");
UIInput input = null;
if (!StringUtils.isEmpty(id)) {
input = (UIInput) component.findComponent(id);
}
if ((input != null) && input.isRequired()) {
writer.write(" <span class=\"req\">*</span>");
}
writer.endElement("label");
}
private boolean hasMessages(FacesContext context, UIComponent component) {
Iterator it = context.getClientIdsWithMessages();
boolean found = false;
while (it.hasNext()) {
String id = (String) it.next();
if ((component != null) && id.equals(component.getClientId(context))) {
found = true;
break;
}
}
return found;
}
public class PanelGridRenderer extends HtmlRenderer {
private static final Log log = LogFactory.getLog(PanelGridRenderer.class);
public boolean getRendersChildren() {
return true;
}
public void encodeBegin(FacesContext facesContext, UIComponent component)
throws IOException {
// all work done in encodeEnd()
}
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException {
// all work done in encodeEnd()
}
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException {
RendererUtils.checkParamValidity(facesContext, component, UIPanel.class);
int columns;
if (component instanceof HtmlPanelGrid) {
columns = ((HtmlPanelGrid) component).getColumns();
} else {
Integer i = (Integer) component.getAttributes().get(org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr.COLUMNS_ATTR);
columns = i != null ? i.intValue() : 0;
}
if (columns <= 0) {
if (log.isErrorEnabled()) {
log.error("Wrong columns attribute for PanelGrid " + component.getClientId(facesContext) + ": " + columns);
}
columns = 1;
}
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.UL_ELEM, component);
HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.UL_PASSTHROUGH_ATTRIBUTES);
writer.flush();
renderChildren(facesContext, writer, component, columns);
writer.endElement(HTML.UL_ELEM);
}
protected void renderChildren(FacesContext context,
ResponseWriter writer,
UIComponent component,
int columns)
throws IOException {
String rowClasses;
if (component instanceof HtmlPanelGrid) {
rowClasses = ((HtmlPanelGrid) component).getRowClasses();
} else {
rowClasses = (String) component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
}
String[] rowClassesArray = (rowClasses == null)
? org.apache.myfaces.shared_tomahawk.util.ArrayUtils.EMPTY_STRING_ARRAY
: StringUtils.trim(StringUtils.splitShortString(rowClasses, ','));
int rowClassesCount = rowClassesArray.length;
int childCount = getChildCount(component);
if (childCount > 0) {
int columnIndex = 0;
int rowClassIndex = 0;
boolean rowStarted = false;
for (Iterator it = getChildren(component).iterator(); it.hasNext();) {
UIComponent child = (UIComponent) it.next();
if (child.isRendered()) {
if (columnIndex == 0) {
//start of new/next row
if (rowStarted) {
//do we have to close the last row?
writer.endElement(HTML.LI_ELEM);
HtmlRendererUtils.writePrettyLineSeparator(context);
}
writer.startElement(HTML.LI_ELEM, component);
if (rowClassIndex < rowClassesCount) {
writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null);
}
rowStarted = true;
rowClassIndex++;
if (rowClassIndex == rowClassesCount) {
rowClassIndex = 0;
}
}
RendererUtils.renderChild(context, child);
columnIndex++;
if (columnIndex >= columns) {
columnIndex = 0;
}
}
}
if (rowStarted) {
writer.endElement(HTML.LI_ELEM);
HtmlRendererUtils.writePrettyLineSeparator(context);
}
}
}
分享到:
相关推荐
自封装ESXi-6.7.0-20201004001-standard-customized.iso
标题"android_customized_component"暗示我们将讨论如何在Android平台上创建一个定制的组件,这个组件可以动态地展示资源加载的百分比。描述中的"小例子,实现动态显示资源加载百分比"进一步明确了我们的目标,即...
ESXi-6.7.0-20190504001-standard-customized-8168网卡
### LabVIEW Courseware Customization for Pre-College Learners #### Introduction Traditionally, teaching programming languages at the pre-college level has emphasized the use of graphical flow ...
ESXi-6.7.0-20191204001-standard-customized.iso
ESXi-6.7.0-20191204001-standard-customized-8111f.iso 补入驱动 net55-r8168 支持以下网卡 10ec:8168, 1186:4300 (Realtek RTL8111B / RTL8168B / RTL8111/RTL8168 / RTL8111C / RTL8111CP / RTL8111D(L) / RTL...
网卡驱动封装之离线封装,r8168网卡驱动为例net55-r8168驱动支持网卡型号(Realtek RTL8111B / RTL8168B / RTL8111/RTL8168 / RTL8111C / RTL8111CP / RTL8111D(L) / RTL8168C / RTL8111DP / RTL8111E / RTL8168E / ...
戴尔oem版vmware vsphere esxi7.0,最新 VMware-VMvisor-Installer-7.0.0-15843807.x86_64-DellEMC_Customized-A00.iso 需要的下载
VMware-VMvisor-Installer-6.7.0.update03-16316930.x86_64-DellEMC_Customized-A06.iso
ESXI6.7 合成了网卡驱动,支持的网卡型号有(Realtek RTL8111B / RTL8168B / RTL8111/RTL8168 / RTL8111C / RTL8111CP / RTL8111D(L) / RTL8168C / RTL8111DP / RTL8111E / RTL8168E / RTL8111F / RTL8411 / RTL8111G...
Linux Device Drivers Development: Develop customized drivers for embedded Linux AZW3版(kindle格式),可以用开源软件calibre-ebook(https://calibre-ebook.com/)打开,里面的图片可以用该软件还原到原本的大...
《自定义工具2:JarClassSearcher》 在IT行业中,我们经常需要处理大量的Java类库,特别是JAR文件,这些文件中包含了各种类和资源。为了方便管理和使用,有时我们需要快速查找特定类或者方法在哪个JAR文件中,这时...
制作日期:2019年12月26日,ESXi6.7标准版,加载了Realtek8111网卡驱动和sata控制器驱动,分卷1压缩包。SHA1: 92141996C6861C352FC68A519B4A406C467A4F63
ESXi-6.7.0-20191204001-standard-customized 版本,已经加载 net55-r8168 网卡
制作日期:2019年12月26日,ESXi6.7标准版,加载了Realtek8111网卡驱动和sata控制器驱动,分卷2压缩包。SHA1: 92141996C6861C352FC68A519B4A406C467A4F63 分卷1压缩包地址: ...
VMware ESXi 6.7可以在非服务器的工控机以及普通主机使用,具体安装步骤可以参照百度安装,非常适合没有服务器的朋友然后又需要虚拟化的
ESXi-whsir-6.7.0-20181104001-r8168-standard-whsir-customized
ESXi 7.0 U1安装CD的DellEMC自定义映像 ESXi 7.0 U1内部版本号:16850804 戴尔版本:A00 戴尔发布日期:2020年10月6日 VMware发布日期:2020年10月6日 重要的修复/更改 ================================= ...