How to make colspan with display:column

巧了我就是萌 提交于 2019-12-11 11:45:25

问题


I want to make a colspan in a display:column so I tried to do it as follows:

<display:column style="width=50% colspan=2 " title="${textResources['Exam.endDate']}"> 

but it doesn't work it seems that this property is not allowed in a display:column so how to do that?


回答1:


To add a colspan to the display column you have to create a Table Decorator extends the TableDecorator class, override the method init, in this method you need to get the header for your cell and add the colspan attribute.

package org.hannibal.utils.view.decorators;    
import java.util.List;

import javax.servlet.jsp.PageContext;

import org.displaytag.decorator.TableDecorator;
import org.displaytag.model.HeaderCell;
import org.displaytag.model.TableModel;
import org.displaytag.util.HtmlAttributeMap;

public class ColspanTableDecorator extends TableDecorator {

    @Override
    public void init(PageContext pageContext, Object decorated,
            TableModel tableModel) {
        super.init(pageContext, decorated, tableModel);
        List headersList = tableModel.getHeaderCellList(); 
        HeaderCell myHeader = (HeaderCell)headersList.get(0);
        HtmlAttributeMap map = myHeader.getHeaderAttributes();
        map.put("colSpan", "2");            
    }   
}

And in the jsp I use it so.

<display:table name="sessionScope.employees" pagesize="10" cellpadding="2" cellspacing="0"
        decorator="org.hannibal.utils.view.decorators.ColspanTableDecorator">

I hope this will help you



来源:https://stackoverflow.com/questions/20594024/how-to-make-colspan-with-displaycolumn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!