Created
May 28, 2012 21:08
-
-
Save ova2/2821224 to your computer and use it in GitHub Desktop.
PickList with Filter (Java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void encodeMarkup(FacesContext context, PickList pickList) throws IOException { | |
... | |
writer.startElement("tbody", null); | |
// FILTER EXTENSION BEGIN | |
if (pickList.isShowSourceFilter() || pickList.isShowTargetFilter()) { | |
if (pickList.isShowSourceControls()) { | |
writer.startElement("td", null); | |
writer.endElement("td"); | |
} | |
writer.startElement("td", null); | |
if (pickList.isShowSourceFilter()) { | |
writer.writeAttribute("class", PickList.SOURCE_FILTER, null); | |
encodeFilter(context, pickList, true); | |
} | |
writer.endElement("td"); | |
writer.startElement("td", null); | |
writer.endElement("td"); | |
writer.startElement("td", null); | |
if (pickList.isShowTargetFilter()) { | |
writer.writeAttribute("class", PickList.TARGET_FILTER, null); | |
encodeFilter(context, pickList, false); | |
} | |
writer.endElement("td"); | |
if (pickList.isShowTargetControls()) { | |
writer.startElement("td", null); | |
writer.endElement("td"); | |
} | |
} | |
// FILTER EXTENSION END | |
writer.startElement("tr", null); | |
... | |
} | |
protected void encodeFilter(FacesContext context, PickList pickList, boolean source) throws IOException { | |
ResponseWriter writer = context.getResponseWriter(); | |
String widgetVar = pickList.resolveWidgetVar(); | |
String filterId = pickList.getClientId(context) + (source ? "_sourceFilter" : "_targetFilter"); | |
String filterFunction = widgetVar + (source ? ".filter(this, true)" : ".filter(this, false)"); | |
writer.startElement("input", null); | |
writer.writeAttribute("id", filterId, null); | |
writer.writeAttribute("name", filterId, null); | |
writer.writeAttribute("class", PickList.FILTER_INPUT, null); | |
writer.writeAttribute("value", "", null); | |
writer.writeAttribute("autocomplete", "off", null); | |
writer.writeAttribute("onkeyup", filterFunction, null); | |
writer.endElement("input"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment