[ECSide] ecside2如何整合struts2

itshu 2008-07-01
最好给个具体例子或做法
谢谢
cats_tiger 2008-07-06
需要整合吗?直接用就可以了吧。
nicksean 2008-07-08
我直接用出错了
cats_tiger 2008-07-08
Action中常用的方法包括:
  /**
   * ECSide读取的数据在Request中的name
   */
  public static final String EC_DATA_NAME = "items";

  /**
   * 最大行数,用于设置limit
   */
  public static final int MAX_ROWS = 10000000;
  /**
   * 得到由EcSide生成的page No.
   */
  protected int getPageNo() {
    return RequestUtils.getPageNo(getRequest());
  }

  /**
   * 得到由EcSide生成的page size
   */
  protected int getPageSize() {
    int pageSize = RequestUtils.getCurrentRowsDisplayed(getRequest());
    int[] rowStartEnd = RequestUtils.getRowStartEnd(getRequest(), MAX_ROWS,
        DaoConstants.DEFAULT_PAGE_SIZE);
    pageSize = rowStartEnd[1] - rowStartEnd[0];

    return pageSize;
  }
  /**
   * @return 返回排序字段名,如果不需要排序,则返回零长度String.
   */
  protected String getSortProperty() {
    Sort sort = getSort();
    return (sort == null) ? StringUtils.EMPTY : sort.getProperty();    
  }
  /**
   * @return 返回"asc"或"desc",如果不需要排序,则返回零长度String.
   */
  protected String getSortDir() {
    Sort sort = getSort();
    return (sort == null) ? StringUtils.EMPTY : sort.getSortOrder();    
  }
  /**
   * @return <code>Sort</code> of ec.
   */
  private Sort getSort() {
    Limit limit = RequestUtils.getLimit(getRequest(),
        TableConstants.EXTREME_COMPONENTS, MAX_ROWS,
        DaoConstants.DEFAULT_PAGE_SIZE);

    return limit.getSort();
  }
 /**
   * 将按照ECSide的要求,将分页数据放到Request中.
   * @see {@link AbstractCrudAction#restorePageData(Page)}
   */
  @Override
  protected void restorePageData(Page page) {
    RequestUtils.initLimit(getRequest(), TableConstants.EXTREME_COMPONENTS,
        page.getRows(), DaoConstants.DEFAULT_PAGE_SIZE);
    getRequest().setAttribute(EC_DATA_NAME, page.getData());
  }


前台使用的例子:
<ec:table items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
	action="index.do"
	useAjax="true" doPreload="false"
	xlsFileName="用户列表.xls" 
	maxRowsExported="10000000" 
	pageSizeList="10,20,50,100,500,1000" 
	editable="false" 
	sortable="true"	
	rowsDisplayed="10"	
	generateScript="true"	
	resizeColWidth="true"	
	classic="false"	
	width="100%" 	
	height="277px"	
	minHeight="200"  
	>
	<ec:row>
	    <ec:column width="50" property="_s" title="选择" sortable="false" style="text-align:center">
	       <input type="checkbox" name="selectedItems" id="selectedItems" value="${item.id}" class="checkbox"/>
	    </ec:column>
		<ec:column width="40" property="_0" title="序号" value="${GLOBALROWCOUNT}" sortable="false" />
		<ec:column width="80" property="loginId" title="登录名" />
		<ec:column width="120" property="email" title="电子信箱" />
		<ec:column width="70" property="status" title="状态" value="可用"/>
		<ec:column property="_0" title="角色" style="text-align:center" sortable="false">
		 <a href="#" onclick="javascript:assignRoles(${item.id})">
		       <img src="${ctx}/images/icons/role.gif" border="0" title="分配角色"/>
		   </a>
		</ec:column>
		<ec:column width="60" property="_0" title="编辑" style="text-align:center"  sortable="false">
		   <a href="edit.do?model.id=${item.id}">
		       <img src="${ctx}/images/icons/modify.gif" border="0" title="编辑"/>
		   </a>		  
		</ec:column>
	</ec:row>
	</ec:table>

够详细了吧?
haray 2009-07-17
请问基于jsp分页是怎么实现的,我的老是只能显示第一页.struts2+spring2.5+hibernate3.2
Global site tag (gtag.js) - Google Analytics