0

One column in my PrimeFaces table has a drop down filter. The data from the database for that column is a character field rather than a string, I'd like the information displayed in the drop down filter to be different from the information used. So instead of having "W" on the list, the drop down says "warning"; but when the filter is applied it searches for "W".

Is there an easy way to do that with PrimeFaces (modifying f:selectItems maybe?), or will I have to do some sort of custom filter method?

    <p:column filterBy="#{hbel.logFlag}" headerText="Log Flag" filterMatchMode="exact">
        <f:facet name="filter">
            <p:selectOneMenu onchange="PF('widgetTable').filter()" >
                <f:selectItem itemLabel="Choose" itemValue="#{null}" noSelectionOption="true" />
                <f:selectItems value="#{homeController.flags}" />
            </p:selectOneMenu>
        </f:facet>
        <h:outputText value="#{hbel.logFlag}" />
    </p:column>

which points to the following in the homeController.java class

private final static String[] flags;
static
{
  flags = new String[4];
  flags[0] = "B";
  flags[1] = "R";
  flags[2] = "T";
  flags[3] = "W";
}
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Where do you try to show 'warning' in the select? I only see a values attribute and the label is identical to the key then. So If your question is how to show a different label then look at the PrimeFaces showcase (or one of the plain jsf selectOneMenu since the solution is the same for both) – Kukeltje Jul 20 '16 at 10:59
  • 1
    Duplicate http://stackoverflow.com/questions/3141716/how-to-get-both-label-and-value-from-fselectitems? (at least the answer shows the solution, the question is not identical) – Kukeltje Jul 20 '16 at 11:01
  • @Kukeltje the [basic example](http://stackoverflow.com/tags/selectonemenu/info) on the wiki worked just fine! I also had to add the onchange assignment to the p: selectOneMenu. – inappropriateCode Jul 20 '16 at 13:03

0 Answers0