Menu

Using displaytag to show one data bean

Emerson C
2003-12-03
2012-10-09
  • Emerson C

    Emerson C - 2003-12-03

    I'd like to display the data from a bean using the displaytag, but i wouldn't want to put it inside am collection in order to allow displaytag to render it, is it possible?

     
    • Matt Raible

      Matt Raible - 2003-12-03

      Just curious - why do you want to use the displaytag at all if you're not rendering a list of data?  If you have a collection as a property on your bean, you could use that...

       
    • Emerson C

      Emerson C - 2003-12-04

      To get the same looking of the  tables that goes under this :)

      I will show the properties of a company and it's contacts. So I'd like to have both with the same looking without having to format the first one.

       
      • Matt Raible

        Matt Raible - 2003-12-04

        The easiest way is to probably reproduce HTML that is similar to the HTML that the displaytag renders (do a view source on your existing one).  JSTL's <c:forEach> is probably a good way to do this.

         
    • Emerson C

      Emerson C - 2003-12-04

      I did a workaround : Sent a arraylist with just one bean inside it :)

       
    • Kent

      Kent - 2004-01-01

      If we can give beans to the table, why can't we get beans from the table ? None of the tags are named or id'd. We cannot iterate thru javascript.

      How do we take out from the table on a slective basis ? What if we sort the contents ?

      There is no way to use the data after ?

      Can anyone provide a solution to operate on selected data within the table ? Ideally one would like to cache it.

       
    • Anonymous

      Anonymous - 2004-01-15

      Matt,

      When you say "If you have a collection as a property on your bean" do you mean a bean (MotherBean) having a property that is a collection of childBeans ?

      I guess what I'm getting at is, does displayTag expect every row to be a bean instance?

       
      • Matt Raible

        Matt Raible - 2004-01-15

        Yes, the displaytag expects every row to be a JavaBean.

         
    • Anonymous

      Anonymous - 2004-01-15

      Matt,

      Thank you for the answer. I have another question;

      I have a design as follows;
      1) Have a rowBean.java.vm (Velocity template)
      2) User creates a SQL request and submits
      3) From resultSetMetaData the column Types and names are extracted, and used in generation of rowBean.java from template
      4) rowBean.java is compiled, instantiated with the data in the resultSet. Then these instances are filled into a resultContainer.java (like examples) instance.
      5) resultContainer is passed to displayTag and displayTag is used to display the results.

      What do you (or anyone else) think about this design?
      Is it unnecessarily complex?
      Is there better a one (that is documented)?

       
      • Matt Raible

        Matt Raible - 2004-01-15

        It definitely *sounds* too complex.  I like using iBatis and Hibernate because both of them allow you to get a List of populated beans from only a couple lines of code.

        I think you could use a RowSet and to a "toCollection()" on it, that might be easier if you want to stick with JDBC.

         
        • Ajanthan R

          Ajanthan R - 2006-12-05

          If you are using RowSet then you can use RowSetDynaclass.
          Something like this: RowSetDynaClass resultSet = new RowSetDynaClass(crs);

          see the following link for more details:
          http://displaytag.sourceforge.net/11/tut_sources.html

           

Log in to post a comment.