Customizing table filter and show inline error message for numeric field in ADF table
When you create a table with filter in ADF and the filter is based on Numeric value then when you enter some string value in filter and press enter it will throw error message in a popup.
But what if we need to show it at filter level only.
It is very simple. When you open the code of your corresponding column you will see the following code.
<af:column sortProperty="EmployeeId" filterable="true" sortable="true"
headerText="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
id="c2">
<af:outputText value="#{row.EmployeeId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.EmployeesVO1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
Now go to your column and add column facet filter. and then add input text in the filter facet and put the EL for the value as shown below. Then put the converter = "oracle.adf.rich.Number".
<af:column sortProperty="EmployeeId" filterable="true" sortable="true"
headerText="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
id="c2" width="105">
<af:outputText value="#{row.EmployeeId}" id="ot2"/>
<f:facet name="filter">
<af:inputText label="Label 1" id="it1" simple="true"
value="#{vs.filterCriteria.EmployeeId}"
converter="oracle.adf.rich.Number"/>
</f:facet>
</af:column>
But what if we need to show it at filter level only.
It is very simple. When you open the code of your corresponding column you will see the following code.
<af:column sortProperty="EmployeeId" filterable="true" sortable="true"
headerText="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
id="c2">
<af:outputText value="#{row.EmployeeId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.EmployeesVO1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
Now go to your column and add column facet filter. and then add input text in the filter facet and put the EL for the value as shown below. Then put the converter = "oracle.adf.rich.Number".
<af:column sortProperty="EmployeeId" filterable="true" sortable="true"
headerText="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
id="c2" width="105">
<af:outputText value="#{row.EmployeeId}" id="ot2"/>
<f:facet name="filter">
<af:inputText label="Label 1" id="it1" simple="true"
value="#{vs.filterCriteria.EmployeeId}"
converter="oracle.adf.rich.Number"/>
</f:facet>
</af:column>
could u please elaborate(explain) on this...pleasee
ReplyDeletecould u please elaborate(explain) on this .......how..why it happens....
ReplyDeleteDear Kamal,
DeleteWhen you create the adf table then by default filter facet will not be there. So when you enter the string value in filter of a column based on Numeric value it will throw you a error related to ClassCastException. This exception will be catches by ADF framework and it will show you a error message in a popup.
But Suppose if you have a need where you have to show the inline error message then only you can do the above implementation.
Showing the error message inline was one of requirement by our client in one of our project. So I did these thing.
Hope this answered your question.
Thanks and Regards
Kunal Kumar
Huh, what about ">100" filter value?
ReplyDelete