Saturday 15 February 2014

java - jsf search display total results found in a datatable -


I was wondering if you can tell me in the right direction, I have a search method and it works fine But I would like to show the total results found, I was wondering how I applied something like this

  public list & lt; Testpaper & gt; Paper (String Q) throws SQLException {list & lt; Test paper & gt; Test = new arrelisted & lt; Test paper & gt; (); If (DS == empty) throw the new SQL Connection ("Can not Get Data Source"); // get the database connection connection con = ds.getConnection (); If throwing new SQLException (thieves == blank) ("Can not get database connection"); Prepared position PS = con.prepareStatement ("Choose from test where testname? Or like the topic?"); Try {ps.setString (1, "%" + q + "%"); Ps.setstring (2, "%" + q + "%"); Results Result = ps.executeQuery (); While (result.next ()) {Tested Testpaper = New Testpaper (); Testpaper.setTestname (result.getString ("testname")); Testpaper.setDescription (result.getString ("Description")); Testpaper.setDateuploaded (result.getDate ("dateuploaded")); Testpaper.setLink (result.getString ("link")); Testpaper.setYear (result.getString ("year")); Testpaper.setSubject (result.getString ("subject")); Test.add (testpaper); }} Hold (Exception E1) {} Finally {try {con.close (); } Hold (exception E2) {}} return exam; }   

JSF code

  & lt; H: DataTable value = "# {search.test}" id = "results" var = "test" sung = "# {empty search is not}" & gt; & Lt; H: column & gt; & Lt; A href = "# {test.link}" title = "download" & gt; & Lt; H3 style = "font-size: medium; font-weight: normal; color: rgb (17, 34, 204); display: block; overflow: hidden; text-overflow: alipisis; white-space: now ipod;" & Gt; & Lt; H: output text value = "# {test.testname}" /> & Lt; / H3 & gt; & Lt; / A & gt; & Lt; H: Output Text Value = "Created by: Ensley Hanson / Portmore Missionary Preparation School" /> & Lt; P style = "row-height: 1.24; direction: rtl; width: 400px;" & Gt; # {Test.description} & lt; / P & gt; & Lt; Div & gt; & Lt; H: output text value = "test year: # {test.year}" style = "color: RGB (17, 34, 204); margin-right: 10px;" /> & Lt; H: outputtext value = "uploaded date: # {test.dateuploaded}" style = "color: RGB (17, 34,); margin-right: 10px;" & Gt; & Lt; F: Convert Dedict Pattern = "MM.dd.yyyy HH: mm" /> & Lt; / H: outputText> & Lt; H: outputtext value = "subject: # {test.subject}" style = "font-weight: 100; color: RGB (17, 34, 204);" /> & Lt; / Div & gt; & Lt; / H: column & gt; & Lt; / H: datatable & gt;   

I know that this figure should be displayed outside the figure, but you should get results from mysql.

You get to get EL value in list # size () You can use the JSTL function.

  & lt; Html ... xmlns: fn = "http://java.sun.com/jsp/jstl/functions" & gt; ... & lt; P & gt; Total results: # {fn: Length (Search)}} & lt; / P & gt;    

No comments:

Post a Comment