datatable {
 populateitem(item i) {
   int col=i.getindex();
   int row=i.getparent(Item.class).getindex();


On Thu, Nov 26, 2009 at 7:27 PM, Keith Bennett <> wrote:
> Hi, all.  I'd like some feedback as to whether my need is already addressed
> in Wicket, or, if not, if I'm on the right track with some code I've written
> to address this need.
> I've been working with a DataTable and need to be able to query it for
> things like:
> For a given component:
> * What row am I in?
> * What column am I in?
> * What is the table that contains me?
> * What are my sibling components in this row?
> * What is my sibling component in this row for the column whose property is
> "foo"?
> * What is the component in my table at column x and row y?
> * What is the component in my table at the column whose key is "foo" and row
> y?
> I need this information because I want to be able to inspect the components'
> input before the values are saved to the underlying model (data provider).
> For example, in my form validation, I want to inspect those unsaved values.
>  I can't do that in field validation because the error state depends on
> relationships between data items in several columns in the row.
> Or, I may have an error indicator icon in one column that is added to the
> Ajax target for other components in that row, and the error icon's
> visibility is dependent partly on components in that row whose data have not
> yet been saved.
> * * *
> I wrote some code that does this.  Because it was difficult to guarantee
> that all components would have access to an object, I implemented this
> functionality as static methods.
> It relies heavily on the components' page relative paths (e.g.
> "form:table:rows:1:cells:1:cell").
> One of the challenges was that the row number of the first row changes!
>  When the table is repopulated, new row numbers are assigned.  For example,
> a 5 row table will start out having its first row as #1, but later in its
> life it will be #6, and then later, #11...
> I don't think there's any hook into being notified of these changes, and
> even if there were, the static methods couldn't easily use them, so I wind
> up recalculating the row offset (1, 6, etc.) every time I need it.  This
> involves inspecting all the columns rows and calculating the minimum, and is
> a bit unfortunate.
> Because all cell components have an id of "cell", there is no way to tell
> which cell contains a "foo" field, which contains a "bar" field, etc.,
> without getting its column number and looking it up somehow.  (In some cases
> one could identify it by the class, but that wouldn't work all the time.)
>  So I made an interface:
> /**
>  * For columns that can be identified by a key name.
>  */
> public interface ColumnWithKey {
>    String getColumnKey();
> }
> Ideally, the need for a ColumnWithKey interface could be eliminated by
> adding getKey() to the IColumn interface.
> The code is at:
> and
> It uses Google Collections, a really cool generics-enabled collections
> library that brings some functional programming type goodies to Java.
> Any feedback on any of this?  Would this code be helpful to anyone?
> Thanks,
> Keith
> ---
> Keith R. Bennett
> Senior Software Consultant
> Linked In:
> Blogs:,
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to