To include find dialog in primefaces data table

UI Components for JSF
Post Reply
javawarrior
Posts: 74
Joined: 01 Jul 2013, 09:26

25 Oct 2014, 19:20

I have a data table in my application built using JSF and primefaces which populates the data from database.Since it is a large data set i have implemented live scrolling to fetch rows as and when end of scrolling is reached.In this data table i have incorporated the search functionality for each column of the table as shown in the showcase .I am developing an application as part of re-platforming of one of MS access application to java web application.The customer has now changed the requirement where instead of the find text box for each column they want the find dialog similar to the one used in MS access as shown in the image below.

Image

The dialog should contain all matching criteria as shown in the image.

Can someone please suggest how to incorporate the above feature by any means.It can be either using JSF or any other front-end technologies. Thanks in advance.
JSF 2,Mojarra 2.0.11,primefaces 3.5,tomcat 6.0.29,Primefaces extensions 0.7.1

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

26 Oct 2014, 16:46

it can be done with jsf, withouth much problems, it is just that you have to manually create it... pas the fields on to a bean and use that either in your own special 'dao' or pass it on to the lazydatamodel and use it there. All nothing special, but work you have to do yourself (makes no difference if you want to do this without jsf, same issues there)

Cheers

javawarrior
Posts: 74
Joined: 01 Jul 2013, 09:26

27 Oct 2014, 15:08

Hi kukeltje,thanks for your reply.Can you please elaborate on the answer you gave.Do i need to query the database by passing the search field in DAO or data model?
JSF 2,Mojarra 2.0.11,primefaces 3.5,tomcat 6.0.29,Primefaces extensions 0.7.1

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

27 Oct 2014, 15:25

Totally depends on your implementation. Do you use a lazy datamodel with a dao or without... I cannot decide that for you

javawarrior
Posts: 74
Joined: 01 Jul 2013, 09:26

27 Oct 2014, 16:10

Hi,I am not using any Dao classes nor implementing any LazyDataModel. I am fetching rows from database into a Arraylist variable and passing this array list as parameter to normal DataModel constructor.I am pointing to this DataModel object as value attribute in p:datatable element in JSF code.

Below is the code snippet for the reference. lpinfoList is the datamodel object and workSpaceItems is the arraylist.

Code: Select all

<p:dataTable id="workSpaceList" var="data"
				value="#{workSpaceBean.lpInfoList}" ..........>

Code: Select all

workSpaceItems = new ArrayList<WorkSpaceItem>();

			while (rs.next()) {
				workSpaceItem = new WorkSpaceItem();
				workSpaceItem.setInsuredName(rs.getString("InsuredName"));
				.
				.
				.
				workSpaceItems.add(workSpaceItem);

			}
			
			lpInfoList = new WorkSpaceDataModel(workSpaceItems);

Code: Select all

public class WorkSpaceDataModel extends ListDataModel<WorkSpaceItem> implements SelectableDataModel<WorkSpaceItem>{
	

	//private WorkSpaceItem workSpaceItem;
	public WorkSpaceDataModel()
	{

	}

	public WorkSpaceDataModel(List<WorkSpaceItem>data)
	{
		
		super(data);
		
	}                                                                      


	@Override
	public WorkSpaceItem getRowData(String rowKey) {

		List<WorkSpaceItem>workSpaceItems=(List<WorkSpaceItem>)getWrappedData();

		
	
		for(WorkSpaceItem workSpaceItem : workSpaceItems) { 
			if(String.valueOf(workSpaceItem.getLpID()).equals(rowKey))
			{
				
				return workSpaceItem; 
				

			}
			
		}
	
		return null;
		

	}

	@Override
	public Object getRowKey(WorkSpaceItem workSpaceItem) {  
		return workSpaceItem.getLpID(); 
	} 
	
	
	
}
JSF 2,Mojarra 2.0.11,primefaces 3.5,tomcat 6.0.29,Primefaces extensions 0.7.1

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

27 Oct 2014, 17:26

javawarrior wrote:I am fetching rows from database into a Arraylist variable
Then implement in such a way that you can use it in the code that does the above...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests