Wicket's Repeatingview

Source: Internet
Author: User

First look at the Repeatingview:

Html:

<tr wicket:id= "Repeating" > <td><span wicket:id= "Actions" >[actions]</span></td> <td><span wicket:id= "ContactID" >[contactid]</span> </td> <td><span wicket:id= "fir Stname ">[firstname]</span></td> <td><span wicket:id=" LastName ">[lastname]</span ></td> <td><span wicket:id= "HomePhone" >[homephone]</span></td> <TD>&L T;span wicket:id= "Cellphone" >[cellphone]</span></td> </tr>

Java:

        RepeatingView repeating = new  Repeatingview ("repeating");         add (repeating);         int index = 0;         while  (Contacts.hasnext ())         {             abstractitem item = new abstractitem ( Repeating.newchildid ());             repeating.add ( Item);             contact contact =  contacts.next ();             item.add (new  actionpanel ("Actions",  new detachablecontactmodel (Contact)));             item.add(New label ("ContactID",  string.valueof (Contact.getid ())));             item.add (New label ("FirstName",  contact.getfirstname ()));             item.add (New label ("LastName",  Contact.getlastname ()));             item.add (new  label ("HomePhone",  contact.gethomephone ()));             item.add (New label ("Cellphone",  contact.getcellphone ()));              .....

If it is a regular component, it should be repeating.add (XXX), but the repeating component is the most obvious difference by creating a new item and adding subcomponents from the template to the item. At the same time, this item represents a peripheral component that you can add properties to, modify properties, and so on.

Refreshingview:

    <tr wicket:id= "View" &GT;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&LT;TD ><span wicket:id= "Itemid" >[item id]</span></td>         <td><span wicket:id= "Actions" >[actions]</span></td>         <td><span wicket:id= "ContactID" >[contactid]</span>  </td>        <td><span wicket:id= "FirstName" >[firstname]</span></td>        <td><span  wicket:id= "LastName" >[lastname]</span></td>         <td><span wicket:id= "HomePhone" >[homephone]</span></td>         <td><span wicket:id= "Cellphone" >[cellphone]</span></td >   &nBsp;</tr> 

 RefreshingView<Contact> view = new RefreshingView<Contact> ("View")          {             private static final long serialVersionUID = 1L;             /**              * return an iterator over models for items in  the view             */              @Override              protected Iterator<IModel<Contact>>  Getitemmodels ()             {           &Nbsp;     return contacts.iterator ();             }            @ override            protected void  Populateitem (Final item<contact> item)              {                 contact contact = item.getmodelobject ();                 item.add (New label ("Itemid",  item.getid ()));                 item.add (new  Actionpanel ("Actions",  item.getmodel ()));                &nbsP;item.add (New label ("ContactID",  string.valueof (Contact.getid ())));                 item.add (New label ("FirstName",  Contact.getfirstname ()));                 item.add (New label ("LastName",  contact.getlastname ()));                 item.add (New label ("HomePhone",  Contact.gethomephone ()));                 item.add (New label ("Cellphone",  contact.getcellphone ()));                 item.add (Attributemodifier.replace ("Class",  new AbstractReadOnlyModel<String> ()                  {                     private static final long serialVersionUID = 1L;                       @Override                      public string getobject ()                      {                          return  (Item.getindex ()  % 2 == 1)  ?  "even"  :  "odd";                      }                }));             }        };


Visible Refreshingview look more modular, more oo, beyond that, I do not see what the difference.


Next comes the DataView,

DataView is a basic implementation of Abstractpageableview. Data views Aim-make it very-populate your repeating view from a database by utilizing idataprovider to act as An interface between the database and the DataView.

DataView is the end of this class of branching, and the controllability and encapsulation are the appropriate implementations.


DataView above is Dataviewbase, under which the class branches are:

Gridview,datagridview, the convenience of these two classes increased, controllability decreased.

<table cellspacing= "0"  cellpadding= "2"  border= "1" >    <tr wicket:id= "Rows" >         <td wicket:id= "Cells" >             <span wicket:id= "Cell" >cell content goes here</span>         </td>    </tr></table> 
   public datagridpage ()     {         List<ICellPopulator<Contact>> columns = new ArrayList< Icellpopulator<contact>> ();         columns.add (new  Propertypopulator<contact> ("id"));         columns.add (new  Propertypopulator<contact> ("FirstName"));         columns.add (new  PropertyPopulator<Contact> ("LastName");         Columns.Add (new propertypopulator<contact> ("HomePhone"));         columns.add (new propertypopulator<contact> ("CellPhone"));         add (new datagridview<contact> ("Rows", columns, new  Sortablecontactdataprovider ()));     }

The latter two may be more suitable for the presence of the data, without the need for interaction. At the same time more light weight.

Wicket's Repeatingview

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.