BalusC - Pagination using h:dataTable

Hi,
I was using tr:table first but that didnt work as I had to navigate to another pagef rom the table by clicking on a hyperlink which was returned in the tr:table. The problem was that no matter which row you click the first row from the DB is displayed in the next page.
So I used h:dataTable now.
But with tr:table the advantage was that the pagination was handled by row attribute - rows="15" and if there were more than 15 rows a link would appear to browse to the next page.
How can I achieve with h:dataTable. ?

You need to add the paging logic yourself. But this can easily be achieved with a set of commandbuttons and binding the datatable with the backing bean. You can find here a code sample: [http://balusc.blogspot.com/2006/06/using-datatables.html#PagingDatatable].

Similar Messages

  • Pagination using AJAX

    i need to implement pagination in my jsp page.
    is it possible to create a table in the page and upon clicking the next page,retrieve only the sufficient data from the server using AJAX?
    my idea is to retrive data in xml format from the database and use AJAX to display it in the table.will it be possible?

    I think you can do it only using JSF DataTable instead Ajax.

  • DateField not getting copy in the matrix using Datasource & Datatable

    Hello All,
    I have tried to copy data From Purchase Order Tables to my own created User Defined Form matrix columns using DBDatasource & Datatables ,Instead of Document Date all other data are getting copied but that document date field is not
    getting the data plus it is not showing any error message as such.
    Following is the code which i have written :-
    =====================================
    oPurchase_Amend.DataSources.DataTables.Add("oMatrixDT" )
    oPurchase_Amend.DataSources.DataTables.Item("oMatrixDT" ).Clear()
    Dim sSQL As String = "SELECT T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[Price],(Select InvntryUoM From OITM Where ItemCode=T1.ItemCode) as 'UoM',T1.LineNum,T0.DocNum  as 'FrmDate' FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocNum] ='1' and T0.CardCode='C0001'
    oPurchase_Amend.DataSources.DataTables.Item("oMatrixDT" ).ExecuteQuery(sSQL)
    oMatrix = oPurchase_Amend.Items.Item("mtx_0").Specific
    oMatrix.Clear()
    Dim oDBDataSource As SAPbouiCOM.DBDataSource = oPurchase_Amend.DataSources.DBDataSources.Item("@OSL_POAMD")
    Dim oDataTable As SAPbouiCOM.DataTable = oPurchase_Amend.DataSources.DataTables.Item("oMatrixDT" )
    oDBDataSource.Clear()
    For row As Integer = 0 To oDataTable.Rows.Count - 1
    Dim offset As Integer = oDBDataSource.Size
    oDBDataSource.InsertRecord(row)
    oDBDataSource.SetValue("U_ItemCode", offset, oDataTable.GetValue("ItemCode", row).ToString())
    oDBDataSource.SetValue("U_ItemName", offset, oDataTable.GetValue("Dscription", row).ToString())
    oDBDataSource.SetValue("U_UoM", offset, oDataTable.GetValue("UoM", row).ToString())
    oDBDataSource.SetValue("U_OldQty", offset, oDataTable.GetValue("Quantity", row).ToString())
    oDBDataSource.SetValue("U_OldRate", offset, oDataTable.GetValue("Price", row).ToString())
    > Line For Copying Document Date Data to the matrix datasource
    oDBDataSource.SetValue("U_OldDate", offset, oDataTable.GetValue("FrmDate", row))
    oDBDataSource.SetValue("U_LineId", offset, oDataTable.GetValue("LineNum", row))
      Next
    '--- Rebinding the datasource to the matrix columns -
    oMatrix.Columns.Item("col_0").DataBind.SetBound(True, "@OSL_POAMD", "U_ItemCode")
    oMatrix.Columns.Item("col_1").DataBind.SetBound(True, "@OSL_POAMD", "U_ItemName")
    oMatrix.Columns.Item("col_3").DataBind.SetBound(True, "@OSL_POAMD", "U_OldQty")
    oMatrix.Columns.Item("col_5").DataBind.SetBound(True, "@OSL_POAMD", "U_OldRate")
    oMatrix.Columns.Item("col_7").DataBind.SetBound(True, "@OSL_POAMD", "U_OldDate")
    oMatrix.Columns.Item("col_9").DataBind.SetBound(True, "@OSL_POAMD", "U_LineId")
    oMatrix.LoadFromDataSource()
    But i am not able to get the document date in the column of the matrix .
    Please suggest what changes i have to meke in this code to get the desired output.
    Thanks & Regards,
    Amit
    Edited by: AmitSharma_061985 on Dec 17, 2009 12:24 PM

    Hi Michael,
    FrmDate is the Document date of the purchase order which i am fetching through sql query and trying to copy that in the matrix
    through datasource .
    Edited by: AmitSharma_061985 on Dec 18, 2009 7:07 AM

  • Using rownum in EJB-QL ..Pagination using CMP 2.1

    Hi ,
    Hope this is the right forum .. rather than JDBC .
    My requirement is to implement Pagination using EJB2.1 on weblogic with Oracle DB. This is for an application which is quite old system and is not ready yet to be migrated to EJB3.0. So we are struck with EJB2.1 at the moment.
    We are using EJB-QL to get Search result and now need to add Pagination logic in it. I can find weblogic.ejb.PreparedQuery.setMaxElements() API to specify the upper limit but what am looking for is a lower limit ..somthing like setFirstRow() ..
    Can it be done using CMP Entity Bean 2.1 .. EJBQL or someother way ?
    I have the sql for pagination but am not sucessful in translating it to EJB-QL
    select * from
    select /*+ FIRST_ROWS(n) */ a.*, ROWNUM rnum from
    (your_query_goes_here) a
    where ROWNUM <=:MAX_ROW_TO_FETCH
    where rnum >= :MIN_ROW_TO_FETCH;
    Thanks in advance ! I hope I get a solution soon ..
    Edited to get some answers !!!
    is it possible to use rownum in EJBQL ? I know rownum is specific to Oracle and my application will stay with Oracle. I get this exception
    "EJB QL compilation encountered error: [EJB:013042]The Identifier 'rownum' is neither a cmp-field nor a cmr-field. Re-examine your query."
    Edited by: user11305835 on Oct 12, 2009 10:48 PM

    Beevin
      Both two are not even validated,
      but with the first one as select max(c.id) from customer as c , in this case it is validated but while deploying it is error as , object must be return
      But when i saw  the ejb2.1 specification we can write this type of queries also ?
      Is it problem with was any thing
    Regards
    Somaraju

  • Issue While executing the Query for Pagination using ROWNUM with like

    Issue While executing the Query for Pagination using ROWNUM with like.
    Database is Oracle11G.
    Oracle Database Table contains 8-9 lakh records
    1) SQL equal (=)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920'
    Execution Time:- 0.00869245 seconds
    Returns 2 resultsets
    2) SQL like (one %)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920%'
    Execution Time:- 0.01094301 seconds
    Returns 2 resultsets
    3) SQL like (two%)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE like '%KMF22600920%'
    Execution Time:- 6.43989658 seconds
    Returns 2 resultsets
    In Pagination, we are using Modified version of SQL Query 3) with ROWNUM as mentioned below :-
    4) SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) WHERE RNUM > 0
    Execution Time:- Infinite
    ResultSets:- No as execution time is infinite
    a) Instead of like if we use = in the above query it is returning the 2 resultsets (execution time 0.02699282 seconds)
    b) Instead of two % in the above query, if use one example REFERENCE like 'KMF22600920%' it is returning the 2 resultsets (execution time 0.03313019 seconds)
    Issue:- When using two % in like in the above query i.e. REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) , it is going to infinite.
    Could you please let us know what is the issue with two % used in like and rownum
    5) Modified version of Option1 query (move out the RNUM condition AND RNUM <= 20)
    SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' ) WHERE RNUM > 0 AND RNUM <= 20
    Execution Time:- 7.41368914 seconds
    Returns 2 resultsets
    Is the above query is best optimized query which should be used for the Pagination or still can improve on this ?

    This would be easier to diagnose if there was an explain plan posted for the 'good' and 'bad' queries. Generally speaking using '%' on both sides precludes the use of any indexes.

  • Pagination Using Pages '09 4.0 (727)

    Pagination Using Pages
    I want to paginate a novel. Page one should begin at Chapter 1 while the introductory pages such as the title page, dedication page, thank you page should remain unnumbered. Can I do this? If so how?

    Menu > Insert > Section Break at the end of the page just before you want the change in Page Numbering.
    Click in the page where you want to start the numbering > Inspector > Layout > Section > Page Numbers > Start at: 1 > Configuration > uncheck User previous headers & footers
    click in the footer/header of the 2nd Section > Menu > Insert > Auto Page Numbers
    Go back to the first section and delete the page number in the footer or header, if there is any.
    Peter

  • Trouble using MyFaces dataTable and t:columns tag in JSR168 portlet

    Hi, I have a question and need some help.
    I am building a JSF portlet, and trying to use Appache MyFaces custom tags.
    I need to use t:dataTable, and t:columns tags to display a dynamic ListDataModel, since the number and content of columns will vary.
    The problem is, the dataTable will only display the first row of the ListDataModel, although the data is all there. It seems that the page only reads the first row of the ListDataModel. Anybody has similar experience, or have some work around?
    Thank you in advance.

    Thats a way I had not thought of to approach this
    problem.
    I'd like to see what your backing bean looks like in
    this instance.
    How does the binding to #{item.data} map to anything?As usual BackingBean
    TableInfoBean.contentTable is UIData. I use binding just for combobox. You can drop this binding.
    TableInfoBean.content.currentPage is any container supported by dataTable. In my case this is Collection. This Collection contains item objects. Each item can has one property with array, List, Collection etc. In my case this property is data (row.data). Each item of this data collection is some object too. In my case this objects has property data too.
    The hierarchy is
    dataTableList:Collection->itemObjectYAxis:SomeType->data:Collection->itemObjectXAxis:SomeAnotherType->properties for output.
    >
    Thanks
    -Matthew

  • Pagination using pager tag library (logical groupings)

    I'm currently trying to achieve pagination using the pager tag library provided by jsptags.com.
    Instead of the usual breaking up the records into a fix number to be displayed per page, I need to display these records by grouping per page. E.g., my records are grouped by countries, so each group varies in size.
    I would not be accessing the database directly from the JSP page, in fact, the JSP page will get a collection of the objects that I want to display per page.
    Has anyone done anything like this before? Would appreciate very much if you could share with me how you implement this.
    Thanks!

    Hi there,
    I am wondering if you found the solution for your question with paging in JSP. if so i will really appreciate if you can let me know, how you did it. I am using Pager tag lib from JSPTags as well and i used collection object to iterate through. But i have some problems. I am wondeinf if you can help me with this
    Thanks
    Vik

  • Implemented pagination using JSTL !

    Hi,
    I have implemented pagination using JSTL and uploaded the code at the following website
    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4718&lngWId=2Please send feedback on improving the code if any to [email protected]
    It can be used for doing Pagination using JSTL.
    Change the query as required in pagination.jsp
    Rows to be displayed per page can be changed by changing the variable rowsPerPage in printResult.jsp.

    Congrats! Atleast you are posting a solution.
    Rich

  • Editing selcted checkboxes in JSF when using h:dataTable

    I have a few records coming in from the Database which are displayed with checkboxes . The JSP code for them is as follows
    <h:dataTable value="#{InvestigationDefendantView.investDefsFindingsModel}" var="def" border="0" >
    <h:column>
    <h:selectManyCheckbox value="#{InvestigationDefendantView.addtype1}" disabled="false">
    <f:selectItem itemValue="Current" itemLabel="Current"/>
    <f:selectItem itemValue="Mailing" itemLabel="Mailing"/>
    <f:selectItem itemValue="Posible" itemLabel="Posible"/>
    <j4j:idProxy id="DefAddTypeProxy"/>
    </h:selectManyCheckbox>
    </h:column>
    </h:dataTable>***********************************************8
    The View class has this get method
    ======================================
    public String[] getAddtype1()
    Logger.info(this, "addtype testing", this.faddType.size());
    if (this.faddType.size() > 0 )
    ArrayList<String> alcb = new ArrayList<String>();
    for (int i = 0; i < this.faddType.size(); i++)
    alcb.add(this.faddType.get(i));
    String[] tempArr = new String[alcb.size()];
    for (int i = 0; i < alcb.size(); i++)
    tempArr[i] = alcb.get(i).intern();
    return tempArr;
    return new String[0];
    }===========================================================
    Now when i edit , It shows all the checkBoxes for a perticuler type (e.g. current ) selected even if one of them was selected while adding the record since the h:datatable runs a loop for all the records in a row and my getaddtype1 shows gets called every time and the value faddType.size() is reset every time this method is called .
    What i want to do is show only those records checked which were selected while adding . please help me in solving the issue

    You need to bind the input values of each row to the row object behind the 'var' attribute of the h:dataTable.
    Also see this article how to use datatables: [http://balusc.blogspot.com/2006/06/using-datatables.html].

  • How can i use one datatable inside the other?

    Hi all,
    i need help ... i have this page that shows information from a relational table... for example a mapped table "Countries" that has a java.util.Set inside named "Cities" and i would like 2 know how can i do this using jsf...
    The display would be like this:
    Brasil
    Rio de Janeiro
    Sao Paulo
    USA
    New York
    Washington
    New Orleans
    And Goes on... So i guess it would be a dataTable inside the other, right? but i dunno how to do it...
    Thanks for any info. cya

    this is somehow a messy example. But just focus on the var attribute of outer datatable and how value attribute of inner datatable is referencing it.
    <h:dataTable id="table1" value="#{pc_City_state.listofstates.states}" var="varstates" styleClass="dataTable">
                   <h:column id="column1">
                        <f:facet name="header">
                             <h:outputText styleClass="outputText" value="StateName" id="text2"></h:outputText>
                        </f:facet>
                        <h:outputText id="text3" value="#{varstates.stateName}" styleClass="outputText">
                        </h:outputText>
                   </h:column>
                   <h:column id="column3">
    <f:facet name="header">
    </f:facet>
              <h:dataTable id="table2" value="#{varstates.cities}" var="varcities" styleClass="dataTable">
                                       <f:facet name="footer">
                                       </f:facet>
                                       <h:column id="column4">
              <f:facet name="header">
              <h:outputText styleClass="outputText" value="CityName" id="text6"></h:outputText>
              </f:facet>
              <h:outputText id="text7" value="#{varcities.cityName}" styleClass="outputText">
              </h:outputText></h:column>
              </h:dataTable>
    </h:column>
    </h:dataTable>

  • How to use one dataTable to dynamically assign different values?

    For example, there is only one popup window that contains one dataTable. For every commandButton that calls this popup window will result in different dataTables.
    How to do that?
    Thank you.

    I wanna reuse the same popup window page to display different dataTables with values based on which button(on father window) is clicked...
    I use an html to include the popup window like this:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <frameset>
    <frame src="popupMediaType.jsf" />
    </frameset>
    </html>
    So there will be two pages for one popup window...and I call this html by javascript in the father window...
    I wanna use just two pages to do all the work for other similar popup windows...

  • Data not displayed from List using h:datatable

    hi
    iam getting the error:
    Error getting property 'cell' from bean type of java.lang.String...
    can u please tell where might i have gone wrong.....and actually what does this error mean...
    iam using jsf 1.1,netbeans 5.5 and tomcat 5.5.17
    thanks in advance

    hi.......thank you very much
    iam getting different error :Error getting property 'Cell' from bean of type org.TData1
    here iam sending necessary part of code as the code is large....can u please check where iam going wrong..
    bean class
    public class Htpg
    List data=new ArrayList();
    UIData projectTable;
    private TData1 td;
    public Htpg() { }
    public List getData()
    try {
    Element element;
    int total = 0;
    while(i.hasNext()) {
    element=(Element)i.next();
    if(element.getName().equalsIgnoreCase("tr")) {
    if(i.hasNext()){
    element = (Element)i.next();
    if(element.getName().equalsIgnoreCase("td")) {
    td=new TData1(); // has getters and setters
    td.setCell(element.getContent().toString().trim());
    element = (Element)i.next();
    td. setMade(element.getContent().toString().trim());
    element = (Element)i.next();
    total++;
    data.add(td);
    }//if
    }//if
    }//if
    }//while
    } catch (Exception e) {
    System.out.println("exception");
    return data;
    public void setData(List data)
    this.data=data;
    public UIData getProjectTable() {
    return projectTable;
    public void setProjectTable(UIData ProjectTable) {
    this.projectTable = projectTable;
    public String selectData()
    td=(TData1)projectTable.getRowData();
    return "found";
    jsp page
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <h1>JSP Page</h1>
    <f:view>
    <h:form>
    <h:dataTable value="#{htpg.data}" var="td" binding="#{htpg.projectTable}">
    <h:column>
    <f:facet name="header">
    <h:outputText value="CELL" />
    </f:facet>
    <h:outputText value= "#{td.Cell}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="MADE" />
    </f:facet>
    <h:outputText value= "#{td.Made}" />
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    getters and setters
    public class TData1 {
    private String Cell;
    private String Made;
    public TData1() {}
    public String getCell() {
    return Cell;
    public void setCell(String Cell) {
    this.Cell = Cell;
    public String getMade() {
    return Made;
    public void setMade(String Made) {
    this.Made = Made;
    faces-config.xml
    <faces-config>
    <managed-bean>
    <managed-bean-name>htpg</managed-bean-name>
    <managed-bean-class>org.Htpg</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    </navigation-rule>
    </faces-config>
    iam trying from so many days.........i have to submit this....so this is very much needed..
    thanks in advance...

  • Pagination using JSP Presentations.

    Hi,
    I have implemented a search function in my JSP presentation. The search shows an array of bpm objects in a table and I want to put them in pages with a pagination like google does. I've tried with a taglib, importing the jar in my library and modifying the web.xml of the workspace. But it doesn´t work because I don't know How to use the bpm instances inside scriplets. How can I implement this functionality, is that possible?. I know that this kind of jsp works different than in a normal web application because we use the jsp fuego taglibrary.
    Thanks for your help,
    Guillermo

    About the fuego tags and scriplets, for example, I have created a group[] of BPMObjects, then I call my BPM Object method by an invoke instruction in my jsp. This method has the query and constructs the group of BPMObjects. My problem is when I try to manage this array with Java inside an Scriplet, because the pager taglib requires it.
    I understand how to use the rownum for pagination, my doubt in this case are the parameters that I have to send to BPM from the links of my jsp. ( First _1_ _2_ _3_ _4_ _5_ Last) . Do you have an example or documentation about how to send this parameters?
    You mencioned DynamicSQL, I used it to implement the SQL script. About this, I have decide what is better to implement when I call a SELECT. I know that the DynamicSQL improves performance because it sends the statement and runs in the database server. Another option is to use a "Parametric Query" but I don't know if the performance is the same than a DynamicSQL. On the other hand, I'm implementing Stored procedures and call them from bpm to improve performance, leaving the execution of the SQL Statement to the database server. It is successful when the stored procedure is an insert or update, but when the procedure is for SELECT, I don't know how to receive the cursor from the stored procedure and stores the values inside my BPM objects group[]. Do you have any idea about this?
    Thanks Mark,
    Guillermo
    Edited by: user9241304 on 07-abr-2010 15:41

  • Reset report pagination using javascript / ajax ?

    Hiho,
    i have a page where i pull a ppr report from a different page using htmldb_get like described in Carls excellent examples. The first page also contains a textfield to set a where condition in the report, for examle to search a streetname..
    Now i need a way to reset the pagination of the report using javascript.
    Example:
    I search for street_name_1 and the report returns 100 rows, 10 rows on each page. Now i use the pagination links to switch throught report pages to page 5.
    Now i search for street_name_2 and the report returns 5 rows, so this would only be one page in the report. But the report pagination still is on page 5, so no results are shown. And no pagination buttons either.
    What can i do to reset the pagination before i pull the report without submitting the page?
    Thanks for help,
    DIrk

    I have similar problem with AJAX report pagination. When I click the pagination for next set of rows, it gives "undefined" error. I'm trying to call "get.clear('RP');" in the javascript function as susggested in above url, but doen't work. any examples are appreciated.
    thanks,
    Surya

Maybe you are looking for

  • Java publishing framework using Weblogic personalization

    Hi All, Has anyone used the Weblogic personalization server/portal or a different Weblogic product as a publishing framework. We want to design a publishing system in which we can quickly create templates for new type of content on the website, and p

  • Types of events in OOPs ABAP

    Hi all, I just wanted to know how many types of events are in OOPs ABAP

  • Free ddns with srp526?

    Hi! Last week i have bought two Cisco srp526w routers to connect my home network to the network at my company via vpn. Now i'm very disappointed to see that this router only supports two dynamic DNS provider: dyndns.org (not free anymore) and TZO.org

  • Address Book 3.1.2 excruciatingly slow

    Hello, I recently imported about 150 vcards into AB 3.1.2. Address book has always been slow but now it is extremely slow and I get the spinning rainbow wheel of horror. When I edit records and tab from one field to the next, it takes 10-15 seconds t

  • Can't access purchased season pass tv show on apple tv

    I have ATV 2 and just today for first time purchased the Breaking Bad season 5 season pass. When I go to my 'purchased' tab under tv shows (on apple tv) it just gives me a 'can't access itunes store...try again later' message. If I go to iTunes on my