Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:44:45+00:00 2026-05-31T02:44:45+00:00

I have a table in a database which is used for storing application configuration

  • 0

I have a table in a database which is used for storing application configuration data.

This is the table structure – it’s very simple example:

SessionTTL             MaxActiveUsers         
---------------------- ---------------------- 
30                     787                    

I want to display the table data in this way:

<table border="1">
   <tr>
     <td>SessionTTL</td>
     <td>30</td>
   </tr>
   <tr>
     <td>MaxActiveUsers</td>
     <td>787</td>
   </tr>
   <tr>
     <td>option</td>
     <td>value</td>
   </tr>
   <tr>
     <td>option</td>
     <td>value</td>
   </tr>
</table> 

I tried to display the data using this JSF code and this Java code, but the result was not what I want:

              <h:dataTable id="books"
                         columnClasses="list-column-center,
                         list-column-right, list-column-center,
                         list-column-right" headerClass="list-header"
                         rowClasses="list-row" styleClass="list-
                         background" value="#{DashboardController.getDashboardList()}" var="store">   
                <h:column>
                      <h:outputText  value="Session Timeout"/>
                      <h:outputText  value="Maximum Logged Users"/>
                </h:column>
                <h:column>                       
                      <h:outputText value="#{store.sessionTTL} minutes"/>
                      <h:outputText value="#{store.maxActiveUsers}"/>
                </h:column>

            </h:dataTable> 




public List<Dashboard> getDashboardList()throws SQLException{

        List<Dashboard> list = new ArrayList<Dashboard>();

        if(ds == null) {
                throw new SQLException("Can't get data source");
        }

        Connection conn = ds.getConnection(); 

        if(conn == null) {
                throw new SQLException("Can't get database connection");
        }

        PreparedStatement ps = conn.prepareStatement("SELECT * from GLOBALSETTINGS");

        try{
            //get data from database        
            ResultSet result = ps.executeQuery();
            while (result.next()){
                Dashboard cust = new Dashboard();
                cust.setSessionTTL(result.getString("SessionTTL"));
                cust.setMaxActiveUsers(result.getString("MaxActiveUsers"));
                list.add(cust);
            }
        }
        catch(Exception e1){
            // Log the exception.
        }
        finally{
            try{
                ps.close();
                conn.close();
            }
            catch(Exception e2){
                // Log the exception.
            }
        }
        return list; 
    }

How I can display the data the way I want?

Best wishes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:44:46+00:00Added an answer on May 31, 2026 at 2:44 am

    You must not assign the get method with the parenthesis. You must use a List attribute from your managed bean.

    value="#{DashboardController.getDashboardList()}" //WRONG!
    

    Your managed bean should look like this:

    public class DashboardController {
        private List<Dashboard> lstDashboard;
        public DashboardController() {
            try {
                lstDashboard = getDashboardList();
            } catch (Exception e) {
                //log the exception or something else...
            }
        }
        //getter and setter...
        public List<Dashboard> getLstDashboard() {
            return this.lstDashboard;
        }
        public void setLstDashboard(List<Dashboard> lstDashboard) {
            this.lstDashboard = lstDashboard;
        }
        //your other methods here...
    }
    

    Second, you set the design of every column in your table, not the design of the rows. You’re setting 1 column with 2 values and another column with the real output.

    Fixing your datatable code:

    <h:dataTable id="books"
        columnClasses="list-column-center,
            list-column-right, list-column-center,
            list-column-right" headerClass="list-header"
            rowClasses="list-row"
        styleClass="list-background"
        value="#{DashboardController.lstDashboard}"
        var="store">   
    
        <h:column>
            <f:facet name="header">
                <h:outputText value="Session Timeout" />
            </f:facet>
            <h:outputText value="#{store.sessionTTL} minutes"/>
        </h:column>
        <h:column>                       
            <f:facet name="header">
                <h:outputText value="MaxActiveUsers" />
            </f:facet>
            <h:outputText value="#{store.maxActiveUsers}"/>
        </h:column>
    
    </h:dataTable> 
    

    @BalusC is the StackOverflow JSF expert. He has a very nice example about using JSF DataTable in his blog entry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my database which stores a tree structure. Here are
I have an application which communicates with a database. Each table has a unique
I am using Delphi 2009. I have a very simple data structure, with 2
I have one database table which contains 8 columns. One of the columns is
I have a database table which link locations together; a location can be in
I have a database table which is full-text indexed and i use the CONTAINS-function
I have a table (session) in a database which has almost 72,000 rows. I
we have a table in an Oracle Database which contains a column with the
I have many tables in my database which are interrelated. I have a table
I have a database table A which stores records, A has a primary key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.