title: how to display the data from database on a button click in java jsf
body: <pre><code>&lt;f:view&gt;
          &lt;h:form&gt;
              &lt;h:panelGrid&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;h:outputText value="Student Mark List"/&gt;
                  &lt;/f:facet&gt;
                  &lt;h:column&gt;
                      &lt;h:outputText value="Student Number : "&gt;&lt;/h:outputText&gt;
                      &lt;h:inputText value="#{stuBean.stuNumber}"/&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:commandButton id = "getStuMarkList" value="Get Mark List" action="#{stuBean.listOfMarks}" &gt;
                      &lt;/h:commandButton&gt; &lt;/h:column&gt;
              &lt;/h:panelGrid&gt;                          
              &lt;h:panelGrid  bgcolor="#9AC8E6" width="100%"&gt;
                &lt;h:dataTable id="datatable" value="#{stuBean.marksList}" var="marksList"&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText style=""value="Maths Marks" /&gt;
                          &lt;/f:facet&gt;
                          &lt;h:inputText value="#{marksList.mMarks}" &gt; &lt;/h:inputText&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText style=""value="English Marks" /&gt;
                          &lt;/f:facet&gt;
                          &lt;h:inputText value="#{marksList.eMarks}" &gt; &lt;/h:inputText&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText style=""value="Physics Marks" /&gt;
                          &lt;/f:facet&gt;
                          &lt;h:inputText value="#{marksList.pMarks}" &gt; &lt;/h:inputText&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText style=""value="Social Marks" /&gt;
                          &lt;/f:facet&gt;
                          &lt;h:inputText value="#{marksList.sMarks}" &gt; &lt;/h:inputText&gt;
                      &lt;/h:column&gt;
                  &lt;/h:dataTable&gt;
              &lt;/h:panelGrid&gt;
          &lt;/h:form&gt;
      &lt;/f:view&gt;
  </code></pre>
  
  <h2>StudentBean.java</h2>
  
  <pre><code>    //... getters and setters
  
  public String listOfMarks(){
      student.marksListFromDb(stuNum);
      return null;
  }
  
  private List marksList= new ArrayList();
  
  public List getMarksList() {       
      return marksList;
  }
  </code></pre>
  
  <p>Please check my above code where I'm trying to get the values from database on button click (listOfMarks)  and display them in the datatable.
  Using the above code it is not fetching the data.Kindly help me if I'm wrong doing wrong some where...</p>