Also look at the DataTable in the dataview, it already does most of the things you want. It is also very easy to build on. -Igor
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:wicket-user- > [EMAIL PROTECTED] On Behalf Of Eelco Hillenius > Sent: Tuesday, September 27, 2005 11:07 AM > To: [email protected] > Subject: Re: [Wicket-user] a new component of PageGridView > > You can either work together with the 'competing' project, or start > one with Wicket stuff yourself. You allready had the commit rights. Do > you feel your implementation is really different, or could cooperation > be a better idea here? > > Eelco > > > On 9/27/05, wang lei <[EMAIL PROTECTED]> wrote: > > > > In most projects,the developers need a PageGridView to support data > view. > > In my opinion,i will describe the functions as the following: > > > > Core Function: > > > > Pageing: The developers can define the navigation and other > infomation,so > > the client can view data with paging and easy to naviagte between the > pages. > > > > Format: The developers can define the data format,like 2005-09-09 or > > 09/09/05 and so on. > > Server Sort: If necessary,users can sort data. > > Flexible: It must be easy to extend.Developers can define grid cell > output > > easily,for example,link of delete,edit and so on. > > > > > > Extended Function: > > > > Client Sort: sometime the function is needed,thougth i thought it's > > useless,but somebody may need it. > > StyleClass: Generaly speaking,just like, the even row has a different > color > > with the odd row. > > Mouse change color: For emphasis,the row should can change color when > the > > mouse is over the row. > > Mouse click color: For emphasis,the row should can change color when > the > > row is clicked . > > > > I analysised another discussion about PageGridView,but i feel it too > > complicated. > > So I want to design another PageGridView,in this process,i refer > valuelist > > and displaytag. > > > > The core desigh is simple,just tow classes(PageGridView and Column) and > tow > > interfaces(IPageList and GridCellRender). > > > > PageGridView acts as control mainly,it assigne the value from > > model(IPageList) to header render and cell renderer to output html. > > > > I also finish some default implemention of IPageList and > GridCellRender.And > > write a demo web application,and packaged it as a .war file.If somebody > > knows where i can upload it.I will upload it for demo and > discussion.Because > > it's under test,so i don't want to upload it to sourceforge. > > > > The following is source code of PageGridView : > > > > > > package wicket.contrib.view; > > > > import java.util.ArrayList; > > import java.util.List; > > > > import wicket.AttributeModifier; > > import wicket.contrib.view.impl.LineColumn; > > import wicket.markup.html.list.ListItem; > > import wicket.markup.html.list.ListView; > > import wicket.markup.html.list.PageableListView; > > import wicket.markup.html.navigation.paging.IPageable; > > import > > wicket.markup.html.navigation.paging.PagingNavigator; > > import wicket.markup.html.panel.Panel; > > import wicket.model.IModel; > > import wicket.model.Model; > > > > /** > > * > > * @author Lei.wang <BR> > > * <B>FUNCTION:</B> <BR> > > * This class is used for view.<BR> > > * It add some function to PageableListView<BR> > > * It support sorting,format <BR> > > * Create-time:2005-9-25 <BR> > > * <BR> > > * Rule for variable: <BR> > > * prefix of "t_" means the variable inside the body of a method > > <BR> > > * prefix of "r_" means the parameter,i like to call it > reference > > <BR> > > */ > > > > public class PageGridView extends Panel > > { > > > > private PagingNavigator headerNavigator; > > > > // The navigation for header > > > > private PagingNavigator footerNavigator; > > > > // The navigation for footer > > > > private PageableListView pageableListView; > > > > // The current paging component > > > > /** > > * > > * @param r_ID > > * @param r_PageList > > */ > > public PageGridView(String r_ID, IPageList r_PageList) > > { > > this(r_ID, new Model(r_PageList)); > > } > > > > /** > > * The parameter "r_Model" must provide a IPageList as the method of > > "getObject" is called.<BR> > > * > > * @param r_ID > > * @param r_Model > > */ > > public PageGridView(String r_ID, IModel r_Model) > > { > > super(r_ID, r_Model); > > } > > > > /** > > * This method is to control the grid header for output. > > * > > */ > > private void onRenderHeader() > > { > > final IPageList t_PageList = (IPageList) this.getModelObject(); > > > > ListView t_ListView = new ListView("header", getColumns()) > > { > > > > protected void populateItem(ListItem r_ListItem) > > { > > Column t_Column = (Column) r_ListItem.getModelObject(); > > > > > > r_ListItem.add(t_Column.getHeaderRender().getComponent("title", > > t_Column, r_ListItem, t_PageList)); > > > > } > > }; > > > > this.add(t_ListView); > > } > > > > /** > > * This method is to control the grid cell for output > > */ > > private void onRenderRows() > > { > > final IPageList t_PageList = (IPageList) this.getModelObject(); > > > > pageableListView = new PageableListView("rows", t_PageList, > > t_PageList.getRowsPerPage()) > > { > > > > protected void populateItem(final ListItem r_ListItem) > > { > > ListView t_ChildListView = new ListView("columns", getColumns()) > > { > > > > protected void populateItem(final ListItem r_ChildListItem) > > { > > Column t_Column = (Column) > > r_ChildListItem.getModelObject(); > > > > > > r_ChildListItem.add(t_Column.getCellRender().getComponent("content", > > t_Column, r_ListItem, t_PageList)); > > } > > }; > > > > r_ListItem.add(t_ChildListView); > > > > String t_Style = (String) > > t_PageList.getConfiguration().getStyleClass(r_ListItem.getIndex()); > > if (null != t_Style) > > { > > r_ListItem.add(new AttributeModifier("class", true, new > > Model(t_Style))); > > } > > // control the css style > > > > String t_MouseOut = (String) > > t_PageList.getConfiguration().getMouseOut(r_ListItem.getIndex()); > > if (null != t_MouseOut) > > { > > r_ListItem.add(new AttributeModifier("onMouseOut", true, new > > Model(t_MouseOut))); > > } > > // control the onMouseOut script > > > > String t_MouseOver = (String) > > t_PageList.getConfiguration().getMouseOver(r_ListItem.getIndex()); > > if (null != t_MouseOver) > > { > > r_ListItem.add(new AttributeModifier("onMouseOver", > > true, new Model(t_MouseOver))); > > } > > // control the onMouseOver script > > > > String t_MouseClick = (String) > > t_PageList.getConfiguration().getMouseClick(r_ListItem.getIndex()); > > if (null != t_MouseClick) > > { > > r_ListItem.add(new AttributeModifier("onClick", true, new > > Model(t_MouseClick))); > > } > > // control the onClick script > > > > } > > }; > > > > this.add(pageableListView); > > > > headerNavigator = new PagingNavigator("headerNavigator", > > this.getPageable()); > > footerNavigator = new PagingNavigator("footerNavigator", > > this.getPageable()); > > > > this.add(headerNavigator); > > this.add(footerNavigator); > > > > > > > headerNavigator.setVisible(t_PageList.getConfiguration().isShowHeaderNavig > ation()); > > > > > footerNavigator.setVisible(t_PageList.getConfiguration().isShowFooterNavig > ation()); > > // To control the header and footer navigation to be visiable or not. > > } > > > > /** > > * This method is used for providing the columns<BR> > > * If IPageList.getConfiguration().isShowLineNumber() return true,<BR> > > * This method will return a additional column to show line number.<BR> > > * > > * @return > > */ > > private List getColumns() > > { > > List t_Columns = new ArrayList(); > > > > final IPageList t_PageList = (IPageList) this.getModelObject(); > > > > if (t_PageList.getConfiguration().isShowLineNumber()) > > { > > t_Columns.add(new LineColumn()); > > } > > t_Columns.addAll(t_PageList.getColumns()); > > > > return t_Columns; > > } > > > > /** > > * This method is for external users to define navigation.<BR> > > * > > * @return > > */ > > public IPageable getPageable() > > { > > return pageableListView; > > } > > > > /* > > * (non-Javadoc) > > * > > * @see wicket.Component#onBeginRequest() > > */ > > protected void onBeginRequest() > > { > > if (this.get("rows") == null) > > { > > onRenderHeader(); > > onRenderRows(); > > } > > > > super.onBeginRequest(); > > } > > > > } > > > > > > The following is source code of IPageList: > > > > /** > > * > > */ > > > > package wicket.contrib.view; > > > > import java.io.Serializable; > > import java.util.List; > > > > /** > > * @author Lei.wang <BR> > > * <B>FUNCTION:</B> <BR> > > * This class is used as a model to provide data for paging.<BR> > > * It extneds java.util.List to be suitable for > > PageableListView.<BR> > > * Create-time:2005-9-25 <BR> > > * <BR> > > * Rule for variable: <BR> > > * prefix of "t_" means the variable inside the body of a method > > <BR> > > * prefix of "r_" means the parameter,i like to call it > reference > > <BR> > > */ > > public interface IPageList extends Lis t , Serializable > > { > > > > /** > > * provide some infomation about the view.<BR> > > * I also feel a little confused about the design<BR> > > * Because i fell it should be splited into two parts.<BR> > > * One is used for view<BR> > > * The other is used for model<BR> > > * But i think it too complicated.<BR> > > * So i just use one Configuration to store the infomation. > > * > > * @return > > */ > > public Configuration getConfiguration(); > > > > /** > > * Gets the maximum number of rows on each page. > > * > > * @return Returns the rowsPerPage. > > */ > > public int getRowsPerPage(); > > > > /** > > * Sets the maximum number of rows on each page. > > * > > * @param r_RowsPerPage > > * The rowsPerPage to set. > > */ > > public void setRowsPerPage(int r_RowsPerPage); > > > > /** > > * If the server sort is actived,<BR> > > * when the client click the asc order link.<BR> > > * the method will be called to order data on the server side.<BR> > > * > > * @param r_Column > > */ > > public void doAsc(Column r_Column); > > > > /** > > * If the server sort is actived,<BR> > > * when the client click the desc order link.<BR> > > * the method will be called to order data on the server side.<BR> > > * > > * @param r_Column > > */ > > public void doDesc(Column r_Column); > > > > /** > > * Gets the column defination for grid view.<BR> > > * > > * @return > > */ > > public List getColumns(); > > } > > > > > > The following is source code of Column: > > > > > > package wicket.contrib.view; > > > > import wicket.contrib.view.impl.DefaultGridHeaderRender; > > > > /** > > * > > * @author Lei.wang <BR> > > * <B>FUNCTION:</B> <BR> > > * It provide the necessary infomation of a column of table > header. > > <BR> > > * Create-time:2005-9-26 <BR> > > * <BR> > > * Rule for variable: <BR> > > * prefix of "t_" means the variable inside the body of a method > > <BR> > > * prefix of "r_" means the parameter,i like to call it > reference > > <BR> > > */ > > public class Column > > { > > > > public static final int ORDER_NONE = 0; > > > > // It means this column is not ordered > > > > public static final int ORDER_ASC = 4; > > > > // It menas this column is ordered asc > > > > public static final int ORDER_DESC = 8; > > > > // It menas this column is ordered desc > > > > private String title; > > > > // The title of this column > > > > private boolean allowOrder = true; > > > > // If this value is true,the grid view will show ▲ and ▼,so the client > can > > order data by the column > > > > private int orderState; > > > > // It stores the state of a column,it can be > > ORDER_NONE,ORDER_ASC,ORDER_DESC > > > > private GridCellRender headerRender = new DefaultGridHeaderRender(); > > > > private GridCellRender cellRender; > > > > /** > > * return allowOrder. <BR> > > * If the return value is true.<BR> > > * The column allows order.<BR> > > * > > * @return > > */ > > public boolean isAllowOrder() > > { > > return allowOrder; > > } > > > > /** > > * set allowOrder to control a column for order.<BR> > > * If the parameter is true.<BR> > > * It will make the column orderable.<BR> > > * > > * @param r_AllowOrder > > */ > > public void setAllowOrder(boolean r_AllowOrder) > > { > > allowOrder = r_AllowOrder; > > } > > > > /** > > * return title.<BR> > > * In default grid header render,it will be shown. > > * > > * @return > > */ > > public String getTitle() > > { > > return title; > > } > > > > /** > > * set the title for show. > > * > > * @param r_Title > > */ > > public void setTitle(String r_Title) > > { > > title = r_Title; > > } > > > > /** > > * return the state of the column's state<BR> > > * it can be ORDER_NONE,ORDER_ASC,ORDER_DESC<BR> > > * > > * @return > > */ > > public int getOrderState() > > { > > return orderState; > > } > > > > /** > > * set the state of the column's state<BR> > > * it can be ORDER_NONE,ORDER_ASC,ORDER_DESC<BR> > > * > > * @param r_OrderState > > */ > > public void setOrderState(int r_OrderState) > > { > > orderState = r_OrderState; > > } > > > > /** > > * return the cell render to output the grid cell <BR> > > * user can define it to extend grid view component.<BR> > > * > > * @return Returns the cellRender. > > */ > > public GridCellRender getCellRender() > > { > > return cellRender; > > } > > > > /** > > * At first i just want to provide a getCellRender method for > > extension.<BR> > > * But for convience,i also provide the method.<BR> > > * > > * @param r_CellRender > > * The cellRender to set. > > */ > > public void setCellRender(GridCellRender r_CellRender) > > { > > cellRender = r_CellRender; > > } > > > > /** > > * return the cell render to output the grid cell <BR> > > * user can define it to extend grid view component.<BR> > > * such as order link,icon and so on<BR> > > * > > * @return Returns the headerRender. > > */ > > public GridCellRender getHeaderRender() > > { > > return headerRender; > > } > > > > /** > > * At first i just want to provide a getHeaderRender method for > > extension.<BR> > > * But for convience,i also provide the method.<BR> > > * @param r_HeaderRender > > * The headerRender to set. > > */ > > public void setHeaderRender(GridCellRender r_HeaderRender) > > { > > headerRender = r_HeaderRender; > > } > > > > } > > > > > > The following is source code of GridCellRender: > > > > /** > > * > > */ > > > > package wicket.contrib.view; > > > > import wicket.Component; > > import wicket.markup.html.list.ListItem; > > > > /** > > * @author Lei.wang <BR> > > * <B>FUNCTION:</B> <BR> > > * This class is used to define the output info<BR> > > * <BR> > > * Create-time:2005-9-26 <BR> > > * <BR> > > * Rule for variable: <BR> > > * prefix of "t_" means the variable inside the body of a method > > <BR> > > * prefix of "r_" means the parameter,i like to call it > reference > > <BR> > > */ > > public interface GridCellRender > > { > > > > /** > > * return the defined component to provide output for a grid cell. > > * > > * @param r_ID > > * @param r_Column > > * @param r_ListItem > > * @param r_PageList > > * @return > > */ > > public Component getComponent(String r_ID, Column r_Column, ListItem > > r_ListItem, IPageList r_PageList); > > } > > > > > > ________________________________ > > 雅虎免费G邮箱-No.1的防毒防垃圾超大邮箱 > > 雅虎助手¨D搜索、杀毒、防骚扰 > > > > > NHS甸奨矚矈u迹 穵锥闑牒?閦眣鐬椎跒Zv潜瞬*暴殜嗃麞擘{{ > ⒏r墘弓葰檳啥氘f??Z'z踷共邰陏鷣槎ο?彩⒏濍?躇藏~弶啥 ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
