are you using wicket 1.2???
-igor
On Wed, Aug 6, 2008 at 7:33 AM, alex2008 <[EMAIL PROTECTED]> wrote:
>
> This is the code:
>
> ........
> public class ListProductPage extends WebPage {
>
> public ListProductPage() {
> add(new Link("createLink") {
>
> /**
> * Go to the Edit page when the link is clicked, passing an
> empty
> * Product details
> */
> public void onClick() {
> //setResponsePage(new EditProductPage(getPage(), 0));
> }
> });
>
> IColumn[] columns = new IColumn[3];
>
> /*
> * This is a composite column, created by extending
> * FilteredAbstractColumn. This column adds a UserActionsPanel as
> its
> * cell contents. It also provides the go-and-clear filter control
> * panel.
> */
> columns[0] = new FilteredAbstractColumn(new Model("Actions")) {
>
> // add the UserActionsPanel to the cell item
> public void populateItem(Item cellItem, String componentId,
> IModel model) {
> Product product = (Product) cellItem.getModelObject();
> cellItem.add(new UserActionsPanel(componentId, product));
> }
>
> // return the go-and-clear filter for the filter toolbar
> public Component getFilter(String componentId, FilterForm form)
> {
> return new GoAndClearFilter(componentId, form);
> }
> };
>
> // creates a column with a text filter
> columns[1] = new TextFilteredPropertyColumn(new
> Model("Description"),
> "description", "description");
>
> columns[2] = new TextFilteredPropertyColumn(new Model("Price"),
> "price");
>
>
> // set up data provider
> ProductDataProvider dataProvider = new ProductDataProvider(.....);
>
> // create the data table
> DefaultDataTable products = new DefaultDataTable("products",
> Arrays.asList(columns), dataProvider, 10);
>
> //products.addTopToolbar(new FilterToolbar(products, dataProvider));
> add(products);
>
> }
>
> public class ProductDataProvider extends SortableDataProvider implements
> IFilterStateLocator {
>
> /** dao that will be used to retrieve the list of Products */
> private ProductDao dao;
> /** reuse the Product entity to store filter information */
> private Product filter = new Product();
>
> public Object getFilterState() {
> return filter;
> }
>
> public void setFilterState(Object state) {
> filter = (Product) state;
> }
>
>
> public ProductDataProvider(ProductDao dao) {
> this.dao = dao;
>
> // set the default sort
> setSort("description", true);
> }
>
> /**
> * Gets an iterator for the subset of Products.
> *
> * @param first
> * offset for the first row of data to retrieve
> * @param count
> * number of rows to retrieve
> * @return iterator capable of iterating over {first, first+count}
> Products
> */
> public Iterator iterator(int first, int count) {
> QueryParam qp = null;
>
> SortParam sp = getSort();
> qp = new QueryParam(first, count, sp.getProperty(),
> sp.isAscending());
>
> return dao.find(qp, filter);
> }
>
> /**
> * Gets total number of items in the collection.
> *
> * @return total item count
> */
> public int size() {
> return dao.count(filter);
> }
>
> /**
> * Converts the object in the collection to its model representation. A
> good
> * place to wrap the object in a detachable model.
> *
> * @param object
> * The object that needs to be wrapped
> * @return The model representation of the object
> */
> public IModel model(Object object) {
> return new DetachableModelProduct((Product) object, dao);
> }
> }
>
> public class DetachableModelProduct extends LoadableDetachableModel {
> //make it transient, so that it will not get serialized.
> private transient Product product;
> private final ProductDao dao;
> private final Integer id;
>
> @Override
> public Object getObject() {
> return this.product;
> }
>
> public DetachableModelProduct(Product product, ProductDao dao) {
> this(product.getId(), dao);
> this.product = product;
> }
>
> public DetachableModelProduct(Integer id, ProductDao dao) {
> if (id == 0) {
> throw new IllegalArgumentException();
> }
> this.id = id;
> this.dao = dao;
> }
>
>
> /**
> * Returns null to indicate there is no nested model.
> * @return Null
> */
> public IModel getNestedModel() {
> return null;
> }
>
> /**
> * Uses the DAO to load the required product when the model is attatched
> to the request.
> */
> protected void onAttach() {
> product = dao.load(id);
> }
>
> /**
> * Clear the reference to the product when the model is detatched.
> */
> protected void onDetach() {
> product = null;
> }
>
> /**
> * Called after attatch to return the detatchable object.
> * @param component The component asking for the object
> * @return The detatchable object.
> */
> protected Object onGetObject(Component component) {
> return product;
> }
>
>
> @Override
> protected Object load() {
> return dao.getProductList();
> }
> }
>
> The instruction on bold is my first problem.
>
> It's two days the i find a solution. %-| :,(
> --
> View this message in context:
> http://www.nabble.com/Help-on-create-a-list-with-dataview-tp18852545p18852545.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]