I changed it to just look like:
item.add(new GridView("name", provider)
{
};
Whereas before, I was creating the GridView, *then* adding it to the top-level ListView in two separate steps.
I'm sure my hierarchy before was right because I can simply change what I show above to
GridView gv = new GridView("name", provider)
{
};
item.add(gv);
...and, I get the hierarchy exception!
I'd be fine w/ the "fix" I came up w/, however, I can't get more than one row to appear.
I did this:
item.add(new GridView("name", provider)
{
}.setRows(3).setColumns(3));
...however, I only get one row no matter how many items there are. If I switch back to the old ListView I was using, sure enough, all 5 items show up in a single row.
any ideas?
On Mon, 2006-05-22 at 15:52 -0700, Igor Vaynberg wrote:
where is the populateEmptyItem you are supposed to implement for the gridview? this method populate left over cells and is probably what is causing the hierarchy mismatch.
also here is how to implement detachable idataprovider:
class mydataprovider implemetns IDataProvider, IDetachable {
private transient List list;
public void detach() { list=null; }
public iterator iterateor(int first, int last) {
return getlist().listiterator(first);
}
public int size() {
return getlist().size();
}
private List getlist() {
if (list==null) {
list=...load list here
}
return list;
}
}
-Igor
On 5/22/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:
Yeah, that's what I figured given the example, however that's where my
problem lies. The items I'm adding in populateItem in the GridView
can't be found, I'm getting the hierarchy problem exception.
Here's what I'm doing in the page as an overview:
1. List Product Categories (ListView)
2. for each Category, retrieve and display Products (GridView)
3. Display 3-column table w/ Product details ("cols" in GridView)
Here's the code:
//add ListView object to page w/ data
add(new ListView("categoryView", categoryModel)
{
protected void populateItem(ListItem item)
{
//get catagory item
final ProductCategory category = (ProductCategory)item.getModelObject();
//add category label
item.add(new Label("category", category.getName()));
//STILL DON'T UNDERSTAND HOW TO PASS THIS INTO GRIDVIEW
IModel productModel = new LoadableDetachableModel()
{
protected Object load()
{
return ProductProxy.getProducts (category);
}
};
IDataProvider provider = new
ProductDataProvider(ProductProxy.getProducts(category)); //HARDCODED,
NOT DETACHED! SEE DETACHED MODEL ABOVE!
GridView productView = new GridView("productView", provider)
{
protected void populateItem(Item item)
{
//get product item
final Product product = (Product)item.getModelObject();
//create thumbnail link w/ event
Link thumbnailLink = new Link("thumbnailLink")
{
public void onClick()
{
setResponsePage(new ProductDetail(product));
}
};
//add attribute modifier
thumbnailLink.add(wmc);
//add thumbnail link
item.add(thumbnailLink);
.....
You'll notice I've got a detached model in there...right now it's not
being used since I haven't figured out how to send detached data from
this page into the IDataProvider derived class (another issue, not to
get off track, sorry!)
Here's my HTML, I'm sure it's fantastically wrong but I need to see it
rendered to decide if it looks right:
...............
<tr wicket:id="categoryView">
<td>
<span wicket:id="category" class="titleSmall">category</span>
<hr width="100%" size="1" />
<br />
<table width="200" align="left" wicket:id="productView">
<tr>
<td wicket:id="cols">
<table width="200" align="left">
<tr>
<td>
<a href="" wicket:id="thumbnailLink">
<img src="" wicket:id="thumnailImg" width="200"
height="134" border="0" />
</a>
</td>
</tr>
................
Here's the exception I'm getting, it's not finding the thumbnailLink
control above:
WicketMessage: Unable to find component with id 'thumbnailLink' in
[MarkupContainer [Component id = 4, page =
com.myapp.ui.ProductCatalog, path =
2:categoryView:0:productView:1:cols:4.Item, isVisible = true,
isVersioned = true]]. This means that you declared
wicket:id=thumbnailLink in your markup, but that you either did not
add the component to your page at all, or that the hierarchy does not
match.[markup =
file:/C:/Program%20Files/jboss-4.0.4.GA/server/default/tmp/deploy/tmp37375MyAppEAR.ear-contents/MyApp-exp.war/WEB-INF/classes/com/myapp/ui/ProductCatalog.html,
index = 29, current = '<a href="" wicket:id="thumbnailLink">' (line
61, column 15)]
I must just be missing something obvious....I thought I set it up
correctly per the wicket-examples GridViewPage example.
On 5/22/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> cols objects are generated by the gridview, whatever components you add to
> the gridview in populate have to go inside the cols
>
> -Igor
>
>
> On 5/22/06, VGJ <[EMAIL PROTECTED]> wrote:
> >
> >
> > The code in examples looks screwy to me too, since it defines
> wicket:id="rows" for the GridView control and wicket:id="cols" as the
> columns...yet in the class there is no mention of "cols" anywhere. Is this
> some built-in object?
> >
> > I'm obviously getting an exception because I've setup "rows" and "cols"
> but there is no "cols" - every widget I've nested inside of "cols" is
> causing my hierarchy to be incorrect.
> >
> >
> > On Mon, 2006-05-22 at 10:02 -0700, Igor Vaynberg wrote:
> >
> >
> >
> >
> > On 5/22/06, VGJ < [EMAIL PROTECTED]> wrote:
> >
> > Ok, this makes more sense than the example in wicket-examples. However,
> what if the List I'm passing in is actually wrapped in a
> LoadableDetachableModel?
> >
> > that should be ok because dataview will check if the idataprovider impl
> you passed in also implements IDetachable and call detach on it at the end
> of request.
> >
> > so class MyDataProvider extends ListDataProvider implements IDetachable
> {....}
> >
> >
> >
> >
> >
> > Congrats on the baby, by the way!!
> >
> > thank you :)
> >
> > -Igor
> >
> >
> >
>
>
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user