web| Design Displaytag is a very handy table display tab, suitable for MVC mode, its homepage in http://displaytag.sourceforge.net
first, the simplest case, unused <display:column/> label
<%request.setattribute ("Test", New Reportlist (6));%>
<display:table name= "Test"/>
The tag iterates through each object in the list and displays all the properties in the object. Generally used for development when checking the integrity of object data.
property corresponds to the attributes of the object in the list (obtained by the GetXXX () method), and the title corresponds to the column name in the header of the table. There are two ways of defining columns:
A, <display:column property= "email"/>
Use the property properties in the <display:column/> tag to define
Specify the style you want to apply through the class attribute. Can be directly modified in its default style sheet (./css/screen.css)
iv. data sources for label acquisition data
There are four different ranges
Pagescope
Requestscope (default) <display:table name= "Test2" >
Sessionscope <display:table name= "sessionScope.holder.list" > Note, here to specify the range, not the default
Applicationscope
v. Create an implied object by adding an id attribute
Noting that the id attribute was added to the <display:table/>, an implied object was created in the page context, pointing to the current object in the list.
This object can be captured by (ListObject) Pagecontext.getattribute ("id"). It also creates a Id_rownum object that, similarly, can be
Captured by Pagecontext.getattribute ("Testit_rownum"), which represents only the number of rows in the current row.
With these two suppressed objects, you can access them through other tags, such as jstl:
If you want to display an object containing email and URL address, you can set the autolink= "true" directly in Display:column to connect directly
viii. use of decorative mode to convert data display (write your own decorator)
A, apply decorator to the entire table
<display:table name= "test" decorator= "Org.displaytag.sample.Wrapper" >
<display:column property= "id" title= "id"/>
<display:column property= "Email"/>
<display:column property= "status"/>
<display:column property= "Date"/>
<display:column property= "Money"/>
</display:table>
Org.displaytag.sample.Wrapper is the decorator that writes itself, it wants to inherit Tabledecorator class, look at one of its methods:
Public String Getmoney ()
{
Return This.moneyFormat.format ((ListObject) This.getcurrentrowobject ()). Getmoney ());
}
It is obvious that it obtains the current object through the Getcurrentrowobject () method of the parent class, and then ' paints ' the Getmoney () method
B, apply decorator to separate column
<display:table name= "Test" >
<display:column property= "id" title= "id"/>
<display:column property= "Email"/>
<display:column property= "status"/>
<display:column property= "Date" decorator= "Org.displaytag.sample.LongDateWrapper"/>
</display:table>
Org.displaytag.sample.LongDateWrapper to implement the Columndecorator interface, its approach:
Public final String decorate (Object columnvalue)
{
Date date = (date) Columnvalue;
return This.dateFormat.format (date);
}
Obviously, it can't get the current object (because it implements the interface), just get the object's Columnvalue, and then ' paint '
Nine, create dynamic connection
There are two ways to create a dynamic connection:
A, in <display:column/> by adding href, Paramid, paramname, Paramscope, Paramproperty properties
HREF Basic URL address
Paramid the name of the parameter after the URL address
ParamName the name of the data bean, typically null (that is, using the object in the current list)
Paramscope the range of the data bean, typically null
Paramproperty the property name of the data bean that fills the value of the parameter after the URL address
<display:table name= "Sessionscope.details" >
<display:column property= "id" title= "id" href= "details.jsp" paramid= "id"/>
<display:column property= "Email" href= "details.jsp" paramid= "action" paramname= "Testparam" paramscope= "Request" >
<display:column property= "status" href= "details.jsp" paramid= "id" paramproperty= "id"/>
</display:table>
This method is simple and straightforward, but the disadvantage is that it is not possible to produce a composite URL similar to DETAILS.JSP?ID=XX&ACTION=XX
13, export data to other formats (page overflow filter??) )
Set export= "true" in <display:table/>
Set media= in <display:column/> "CSV Excel XML PDF" determines that the field is not included in the package when it is exported to another format and is not set to contain
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.