1 2 Previous Next 18 Replies Latest reply on Jun 9, 2009 11:34 AM by Gana Prasad

    problem with dataTable in firefox3

    Gana Prasad Newbie

      Hi,

      how to adjust the number of rows in a page if last page does not contain enough rows in richfaces dataTable in firefox ?.
      In IE its working fine but in firefox it showing some empty rows because i have setted 30 rows per page and last page contains only 10 rows and remaining 10 rows it is showing empty rows.

      And i am sending the data from hashtable.

      Thanks in Advance,
      Gana.

        • 2. Re: problem with dataTable in firefox3
          Gana Prasad Newbie

          Hi,
          Please find my code below.

          dataTable.xhtml:
          -------------------

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

          <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
          xmlns:cc="http://webui.nsn.com/calypso"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:t="http://myfaces.apache.org/tomahawk"
          xmlns:c="http://java.sun.com/jstl/core"
          xmlns:rich="http://richfaces.org/rich">
          <ui:composition>

          .rich-datascr-button
          {
          background-color:#E6E6E6;
          }

          <f:view>
          <h:form>
          <rich:datascroller align="left" for="dataTable" maxPages="10"/>
          <rich:dataTable value="#{bean.data}" var="data" rows="40" id="dataTable" styleClass="tagTable" rowClasses="odd,even">
          <rich:column>
          <f:facet name="header">PERIOD_START_TIME</f:facet>
          <h:outputText value="#{data.PERIOD_START_TIME}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">TYPE</f:facet>
          <h:outputText value="#{data.TYPE}"/>
          </rich:column>

          <rich:column >
          <f:facet name="header">BTS_INT_ID</f:facet>
          <h:outputText value="#{data.BTS_INT_ID}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">BSC_INT_ID</f:facet>
          <h:outputText value="#{data.BSC_INT_ID}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">BSC_NAME</f:facet>
          <h:outputText value="#{data.BSC_NAME}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">BTS_NAME</f:facet>
          <h:outputText value="#{data.BTS_NAME}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">PERIOD_DURATION</f:facet>
          <h:outputText value="#{data.PERIOD_DURATION}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">CONNECTS</f:facet>
          <h:outputText value="#{data.CONNECTS}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">ERRORS</f:facet>
          <h:outputText value="#{data.ERRORS}"/>
          </rich:column>

          <rich:column>
          <f:facet name="header">BYTES</f:facet>
          <h:outputText value="#{data.BYTES}"/>
          </rich:column>
          </rich:dataTable>
          </h:form>
          </f:view>
          </ui:composition>



          Bean:
          -------
          package com.yourcompany.managedbeans;

          import java.sql.Connection;
          import java.sql.ResultSet;
          import java.sql.SQLException;
          import java.sql.Statement;

          import javax.naming.Context;
          import javax.naming.InitialContext;
          import javax.naming.NamingException;
          import javax.sql.DataSource;


          public class Bean {
          private TestDataModel data;
          private ResultSet demoData;
          private Connection conn;

          private Integer pk;
          private String PERIOD_START_TIME;
          private String TYPE;
          private String BTS_INT_ID;
          private String BSC_INT_ID;
          private String BSC_NAME;
          private String BTS_NAME;
          private String PERIOD_DURATION;
          private String CONNECTS;
          private String ERRORS;
          private String BYTES;

          public Bean()
          {
          conn = null;
          demoData = null;
          try {
          Context initContext = new InitialContext();
          Context envContext = (Context)initContext.lookup("java:/comp/env");
          DataSource ds = (DataSource)envContext.lookup("jdbc/derby");
          conn = ds.getConnection();
          Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
          demoData = stmt.executeQuery("select * from webscript.demodata");
          demoData.absolute(100);
          System.out.println("Gana demoData:"+demoData);

          } catch (NamingException e) {
          e.printStackTrace();
          } catch (SQLException e) {
          e.printStackTrace();
          }

          }

          public TestDataModel getData() {
          TestDataModel tdm = new TestDataModel(demoData);
          data = tdm;
          return data;
          }
          public void setData(TestDataModel data) {
          this.data = data;
          }

          public ResultSet getDemoData() {
          return demoData;
          }

          public void setDemoData(ResultSet demoData) {
          this.demoData = demoData;
          }

          public Integer getPk() {
          return pk;
          }

          public void setPk(Integer pk) {
          this.pk = pk;
          }

          public String getPERIOD_START_TIME() {
          return PERIOD_START_TIME;
          }

          public void setPERIOD_START_TIME(String period_start_time) {
          PERIOD_START_TIME = period_start_time;
          }

          public String getTYPE() {
          return TYPE;
          }

          public void setTYPE(String type) {
          TYPE = type;
          }

          public String getBTS_INT_ID() {
          return BTS_INT_ID;
          }

          public void setBTS_INT_ID(String bts_int_id) {
          BTS_INT_ID = bts_int_id;
          }

          public String getBSC_INT_ID() {
          return BSC_INT_ID;
          }

          public void setBSC_INT_ID(String bsc_int_id) {
          BSC_INT_ID = bsc_int_id;
          }

          public String getBSC_NAME() {
          return BSC_NAME;
          }

          public void setBSC_NAME(String bsc_name) {
          BSC_NAME = bsc_name;
          }

          public String getBTS_NAME() {
          return BTS_NAME;
          }

          public void setBTS_NAME(String bts_name) {
          BTS_NAME = bts_name;
          }

          public String getPERIOD_DURATION() {
          return PERIOD_DURATION;
          }

          public void setPERIOD_DURATION(String period_duration) {
          PERIOD_DURATION = period_duration;
          }

          public String getCONNECTS() {
          return CONNECTS;
          }

          public void setCONNECTS(String connects) {
          CONNECTS = connects;
          }

          public String getERRORS() {
          return ERRORS;
          }

          public void setERRORS(String errors) {
          ERRORS = errors;
          }

          public String getBYTES() {
          return BYTES;
          }

          public void setBYTES(String bytes) {
          BYTES = bytes;
          }

          public static void update() {
          // TODO Auto-generated method stub

          }

          }


          TestDataModel:
          ------------------

          package com.yourcompany.managedbeans;

          import java.io.IOException;
          import java.sql.ResultSet;
          import java.sql.ResultSetMetaData;
          import java.sql.SQLException;
          import java.util.Hashtable;


          import javax.faces.context.FacesContext;

          import org.ajax4jsf.model.DataVisitor;
          import org.ajax4jsf.model.Range;
          import org.ajax4jsf.model.SequenceRange;
          import org.ajax4jsf.model.SerializableDataModel;

          /**
          *
          * @author ias
          * This is example class that intended to demonstrate use of ExtendedDataModel and SerializableDataModel.
          * This implementation intended to be used as a request scope bean. However, it actually provides serialized
          * state, so on a post-back we do not load data from the data provider. Instead we use data that was used
          * during rendering.
          * This data model must be used together with Data Provider, which is responsible for actual data load
          * from the database using specific filtering and sorting. Normally Data Provider must be in either session, or conversation
          * scope.
          */
          @SuppressWarnings("unchecked")
          public class TestDataModel extends SerializableDataModel {
          private Integer currentPk;
          private ResultSet result;
          Hashtable hash;

          private static final long serialVersionUID = -1956179896877538628L;

          public TestDataModel(ResultSet demoData) {
          result = demoData;
          }

          /**
          * This method never called from framework.
          * (non-Javadoc)
          * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
          */
          @Override
          public Object getRowKey() {
          return currentPk;
          }
          /**
          * This method normally called by Visitor before request Data Row.
          */
          @Override
          public void setRowKey(Object key) {
          this.currentPk = (Integer) key;

          }
          /**
          * This is main part of Visitor pattern. Method called by framework many times during request processing.
          */
          @Override
          public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
          int firstRow = ((SequenceRange)range).getFirstRow();
          int numberOfRows = ((SequenceRange)range).getRows();
          for(int i = 0;i<numberOfRows;i++)
          {
          visitor.process(context,i + firstRow,argument);
          }
          }

          /**
          * This method must return actual data rows count from the Data Provider. It is used by pagination control
          * to determine total number of data items.
          */
          private Integer rowCount; // better to buffer row count locally
          @Override
          public int getRowCount() {
          try{
          int currentRow = result.getRow();
          rowCount = result.last() ? result.getRow() : 0;
          if(currentRow == 0)
          result.beforeFirst();
          else
          result.absolute(currentRow);
          }catch (SQLException e) {
          e.printStackTrace();
          }
          System.out.println("Gana getRowCount:"+rowCount.intValue());
          return rowCount.intValue();
          }

          /**
          * Unused rudiment from old JSF staff.
          */
          @Override
          public void setWrappedData(Object data) {
          throw new UnsupportedOperationException();
          }

          /**
          * This is helper method that is called by framework after model update. In must delegate actual database update to
          * Data Provider.
          */
          @Override
          public void update() {
          Bean.update();
          }

          @SuppressWarnings("unchecked")
          @Override
          public Object getRowData() {
          hash = new Hashtable();
          try{
          result.beforeFirst();
          for (int i = 0; i <=currentPk; i++, result.next());

          ResultSetMetaData rd = result.getMetaData();
          int count = rd.getColumnCount();
          for(int i=1;i<=count;i++)
          {
          hash.put(rd.getColumnName(i),result.getString(i));
          }
          System.out.println("hashTable:"+hash);
          }catch (SQLException e) {
          e.printStackTrace();
          }
          return hash;
          }
          @Override
          public int getRowIndex() {
          // TODO Auto-generated method stub
          return 0;
          }
          @Override
          public Object getWrappedData() {
          // TODO Auto-generated method stub
          return null;
          }
          @Override
          public boolean isRowAvailable() {
          // TODO Auto-generated method stub
          return currentPk != null;
          }
          @Override
          public void setRowIndex(int arg0) {
          // TODO Auto-generated method stub

          }
          }

          • 3. Re: problem with dataTable in firefox3
            Nick Belaevski Master

            How is "tagTable" class defined?

            • 4. Re: problem with dataTable in firefox3
              Gana Prasad Newbie

              Hi,

              Here is my tagtable class:


              table.tagTable
              {
              border: 1px solid #797997;
              border-collapse: separate;
              }
              table.tagTable th,
              table.tagTable th.sorted
              {
              background-color:#EEEEEE;
              border-bottom:1px solid #797997;
              border-right:1px solid #C0C0C0;
              padding:1px 3px 1px 3px;
              white-space:nowrap;
              text-align: left;
              color: #000066;
              }
              table.tagTable th.sorted
              {
              background-color:#CFCFCF;
              }
              table.tagTable td
              {
              border-right: #C0C0C0 1px solid;
              border-top: #F2F2F2 1px solid;
              border-left: #C0C0C0 0px solid;
              border-bottom: #797997 0px solid;
              color: #000000;
              padding:1px 3px 1px 3px;
              }
              table.tagTable tr.odd
              {
              background: #E6E6E6;
              }
              table.tagTable tr.even
              {
              background-color: #F2F2F2
              }

              • 6. Re: problem with dataTable in firefox3
                Nick Belaevski Master

                So, the issue is in your CSS - browsers treat empty rows/cells differently.

                • 7. Re: problem with dataTable in firefox3
                  Nick Belaevski Master

                  I assume, model returns artificial no data rows by intentional design and not because of the coding error. Why not use "lastPageMode" attribute of rich:datascroller instead?

                  • 8. Re: problem with dataTable in firefox3
                    Gana Prasad Newbie

                    Hi,
                    First of all thanks for your response.
                    And There is no problem with CSS class. I checked without my css class also it was the same case as earlier. I am sending the screenshot of my output. please find below.


                    [img]http://localhost:8080/calypso-showcase/html/tableLazyLoading/dataTable.jsf[/img]
                    [/url]

                    • 10. Re: problem with dataTable in firefox3
                      Gana Prasad Newbie

                      Hi,

                      I could not send the image. But is there any property for not showing the empty rows in richfaces dataTable. Because i have seen one property called dr-cell:show in firebug. So is there any property like this has to be set? And i am facing this problem only in firefox not in IE.


                      Thanks in Advance,
                      Gana.

                      • 11. Re: problem with dataTable in firefox3
                        Nick Belaevski Master

                        Here is what I get for both browsers using the posted code: . Both tables have empty space in the end: is it the problem you are referring to?

                        • 12. Re: problem with dataTable in firefox3
                          Gana Prasad Newbie

                          Hi,

                          Exactly same problem which i am facing. Do you have any soulution for this.?

                          Thanks in Advance,
                          Gana.

                          • 13. Re: problem with dataTable in firefox3
                            Nick Belaevski Master

                            Yes, your data model seems to be generating no data cells, that's why there's space in the end. Fix it so there are no such cells.

                            • 14. Re: problem with dataTable in firefox3
                              Gana Prasad Newbie

                              Hi,
                              I did not understand your answer.
                              Could you please tell me how will we generate the data cells in the model.

                              Thanks in Advance,
                              Gana.

                              1 2 Previous Next