facebook

Faces – not getting data from DB after following MYE example

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #278886 Reply

    Peter Bennett
    Participant

    I have been following the JSF example shown at: –
    http://www.myeclipseide.com/images/tutorials/demos/community_one_2007/community_one_2007.htm
    And I have created a web module with a mapping of a VAT table (vatid, rate and description columns) and added the getAllVat() method to the Vat managed bean, just like the getAllPosts() method in the example. I then created the vatlist.jsp file using the JSF template, with the right tag libraries included, the snippet of the loop in the JSP to display the table contents is below: –

    vatlist.jsp (faces) fragment: –

    <body>
      <f:view>
        <h1>VAT Rates</h1>
        <hr/>
        <c:forEach var="vat" items="#{vat.allVat}" >
          <strong>
            <h:outputText id="id" value="#{vat.vatid}"></h:outputText>
          </strong>
          <br/>
          <h:outputText id="rate" value="#{vat.rate}"></h:outputText>
          <hr />
          <h:outputText id="description" value="#{vat.description}"></h:outputText>
        </c:forEach>
      </f:view>
    </body>

    VAT Managed bean excerpt (net.dsps.cmWeb.Vat.java): –

    public List<Vat> getAllVat() 
    {
      logger.info("VAT About to call the findAll.");
      return new VatDAO().findAll();
    }

    faces-config.xml extract: –

    <managed-bean>
      <managed-bean-name>vat</managed-bean-name>
      <managed-bean-class>net.dsps.cmWeb.Vat</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

    And the following in the web.xml file as well (partly to test another way of
    accessing the database with a very naughty SQL tag library, which works)

    <resource-ref>
      <description>DB2ProjectConnection</description>
      <res-ref-name>jdbc/project</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>

    However, when I run the JSP shown above, I get the log4j entries: –
    2007-11-20 20:52:34 [INFO ] [http-8080-1] [net.dsps.cmWeb.Vat] [2535765] [] – VAT zero argument Constructor called
    2007-11-20 20:52:34 [INFO ] [http-8080-1] [net.dsps.cmWeb.CmwebFilter] [2535890] [] – Request for /cmWeb/vatList.faces took : 6.187 seconds.
    So, the Vat managed bean does get the constructor called, but the JSP doesn’t list any objects, and there is no log4j output from the getAllVat() method.
    The managed bean was derived from the table through the database explorer, just as per the example, but when I deploy it to either the MyEclipse Tomcat, or an external Tomcat 6.0.14 instance, I just get no data returned and the log4j output shown above.
    What (apart from a handful of IQ points) am I missing?

    Peter Bennett
    DSPS

    #279093 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

    #279144 Reply

    toniko
    Member

    This message has not been recovered.

    #279148 Reply

    Peter Bennett
    Participant

    This message has not been recovered.

    #279149 Reply

    Peter Bennett
    Participant

    This message has not been recovered.

    #279203 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

    #279247 Reply

    Peter Bennett
    Participant

    This message has not been recovered.

    #279266 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

    #279369 Reply

    Peter Bennett
    Participant

    This message has not been recovered.

    #279370 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Faces – not getting data from DB after following MYE example

You must be logged in to post in the forum log in