Hi,

i would like to use the "Search all fields" option of axonivy project. http://www.primefaces.org/showcase/ui/data/datatable/filter.xhtml

My data table is linked with an entity class. Does anyone knows if it is possible to made something like that ?

asked 20.02.2015 at 21:59

magictoto's gravatar image

magictoto
(suspended)
accept rate: 0%


If you have troubles in adapting the primfaces demo for your needs, there is a similiar implementation in ivy available in the JsfWorkflowUi project. You can find the project in the Engine.zip under the /projects folder (see Screenshot)alt text.

To implement the filtering over all fields of a dataClass you could iterate over all fields by reflection like this:

public class ReflectionUtil {

    public static List<Data> filter(List<Data> tableData, String filterKeyword) throws NoSuchFieldException
    {
        List<Data> filtered = new ArrayList<Data>();
        for(Data data : tableData)
        {
            for(java.lang.reflect.Field field : data.getClass().getDeclaredFields())
            {
                Object fieldValue = data.get(field.getName());
                if (fieldValue != null && 
                        fieldValue.toString().contains(filterKeyword))
                {
                    filtered.add(data);
                    break; // no need to match all fields if one matches
                }
            }
        }
        return filtered;
    }

}
link

answered 24.02.2015 at 14:14

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×51

Asked: 20.02.2015 at 21:59

Seen: 5,158 times

Last updated: 25.02.2015 at 11:16