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

  • Home
  • SEARCH
  • 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 4610030
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:04:25+00:00 2026-05-22T01:04:25+00:00

I am unable to get table values by using h:dataTable. Please reply? Bean class:-

  • 0

I am unable to get table values by using h:dataTable.

Please reply?

Bean class:-

 public class Employee implements Serializable{
        private int eId;
        private String eName; 
        private ResultSet viewEmployee;
    public Connection getVConnection() throws Exception{
            String driver = "oracle.jdbc.driver.OracleDriver";
            String url = "jdbc:oracle:thin:@localhost:1521:globldb3";
            String username = "scott";
            String password = "tiger";
            Class.forName(driver);
            Connection conn = DriverManager.getConnection(url, username, password);
            return conn;
          }

public ResultSet getViewEmployee()  throws Exception{
            Connection conn = null;
            PreparedStatement pstmt = null;
            try {
              conn = getVConnection();
              String query = "select * from employee where e_id>?";
              pstmt = conn.prepareStatement(query); // create a statement
              pstmt.setInt(1,this.eId); // set input parameter
              result = pstmt.executeQuery();
                return result;
            }finally {
              try {
                result.close();
                pstmt.close();
                conn.close();
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
        }
    public String v2(){
        try{
            getViewEmployee();
            return "view-employee-p.xhtml";
        }catch(Exception e){
            e.printStackTrace();
            return "home.xhtml";
         }
    }

JSF page 1:-

<h:panelGrid columns="3" cellpadding="2" border="2" styleClass="panelGridColums">           Id   
<h:inputText id="id" label="&#160;"  value="#{employee.eId}" 
    required="true" requiredMessage="Field cannot be left blank"
    converterMessage="Not a valid id, id must be betwenn 1 and 9999." maxlength="4">
    <f:convertNumber/>      
</h:inputText>      
 <h:message for="id" styleClass="errorMessages" showDetail="false" showSummary="true"/>
 </h:panelGrid>
<h:commandButton value="View" action="view-page.xhtml"/>

view-page.xhtml:

      <h:dataTable value="#{employee.viewEmployee}" var="e">
<h:column>
    <f:facet name="header">Employee id</f:facet>
    #{e.E_ID};
</h:column>

<h:column>
    <f:facet name="header">Employee id</f:facet>
    #{e.E_Name};
</h:column>
</h:dataTable>

Thanks in advance.

  • 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-22T01:04:25+00:00Added an answer on May 22, 2026 at 1:04 am

    You need to provide normal getter and setter methods. EL won’t access properties by fields, it will access them by getters only and mutate them by setters only. If you’re lazy in typing, you can even let your IDE (such as Eclipse/Netbeans/IntelliJ) autogenerate them.

    public class Employee {
    
        private Integer id;
        private String name;
    
        public Integer getId() {
            return id;
        }
    
        public void setId(Integer id) {
            this.id = id;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
    }
    

    With

    <h:inputText value="#{employee.id}" />
    

    and

    <h:dataTable value="#{bean.employees}" var="employee">
        <h:column>#{employee.id}</h:column>
        <h:column>#{employee.name}</h:column>
    </h:dataTable>
    

    Please note that it is case sensitive and should follow Javabeans spec rules. The #{employee.id} expects a public Object getId() method (where Object is whatever type you want it to be). In your example you have #{employee.eId} which can impossibly be valid. If the first two chars of the identifier public Object getEId() are uppercased, you should access it by #{employee.EId}. But after all, using Hungarian or prefix notations makes no sense. Just get rid of the e prefix. It makes code also more self-documenting.

    Don’t forget to alter your JDBC code accordingly

    preparedStatement.setInt(1, employee.getId());
    

    and

    Employee employee = new Employee();
    employee.setId(resultSet.getInt("id"));
    employee.setName(resultSet.getString("name"));
    

    Note that passing ResultSet around as method return value is a bad idea. Once you close it before returning, you cannot get values from it anymore. And when you don’t close it, then you’re leaking resources. You need to process it inside the very same method block as where you’ve opened and closed it. In the above example, just do return employee;.

    To learn how to get started with basic DAO, check this article.

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

Sidebar

Related Questions

I am unable to get the correct title for this, please change the title
I renamed the class classBattle to Game and not I get Unable to load
Using MongoDB C# driver ( http://github.com/samus/mongodb-csharp ), seems that I'm unable to get the
I am unable to get a highcharts plugin to render a chart in a
I'm unable to get this jquery statement to work on page load but it
I have a seemingly simple problem though i am unable to get my head
I have the following code and I am still unable to get Hibernate to
I get a crazy error and I am unable to see why it happens.
Why do I get the error: Unable to create a constant value of type
I'm able to get cells to format as Dates, but I've been unable to

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.