|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
DataTable: Can a Cell Know of Its Row or Row Number?Hi, all. How can a component in a DataTable cell access other components in its
row, or, alternatively, know its row number? I'm using a DataTable to display a list of objects. Some of the cells in each row contain components that are editable. I'm trying to implement a row error indicator whose visibility may change due to Ajax requests from row edits. I looked at some of the Wicket javadocs and source code but couldn't figure this out. Unfortunately, the item object passed to the column's populateItem() does not contain the row number, just the cell number within the row. Similarly, is there a way to add a row to the Ajax target, rather than keeping track of each component to be updated? Thanks for any help. - Keith Bennett --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: DataTable: Can a Cell Know of Its Row or Row Number?On Fri, Nov 6, 2009 at 5:29 PM, Keith Bennett <keithrbennett@...> wrote:
> Hi, all. How can a component in a DataTable cell access other components in its > row, or, alternatively, know its row number? > > I'm using a DataTable to display a list of objects. Some of the > cells in each row contain components that are editable. I'm trying to > implement a row error indicator whose visibility may change due to > Ajax requests from row edits. > > I looked at some of the Wicket javadocs and source code but couldn't figure > this out. Unfortunately, the item object passed to the column's populateItem() > does not contain the row number, just the cell number within the row. populateitem(item item) { int col=item.getindex(); int row=item.getparent(item.class).getindex(); } > Similarly, is there a way to add a row to the Ajax target, rather than keeping > track of each component to be updated? target.add(item.getparent(item.class)); table { newrowitem() { return super.newrowitem().setoutputmarkupid(true); }} -igor > > Thanks for any help. > > - Keith Bennett > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: DataTable: Can a Cell Know of Its Row or Row Number?Igor -
Thanks for the help. I couldn't find a getParent() on the item's class that took a class as a parameter. However, I wrote this, and it worked: /** * Returns the ancestor (Wicket component hierarchy ancestor, not class hierarchy ancestor) * of the specified component that is an instance of the specified class or one of its subclasses. */ public static Component getAncestor(Component component, Class<? extends Component> ancestorClass) { Component targetClassAncestor = null; for (Component c = component.getParent(); c != null && targetClassAncestor == null; ) { if (c.getClass().isAssignableFrom(ancestorClass)) { targetClassAncestor = c; } else { c = c.getParent(); } } return targetClassAncestor; }
|
| Free embeddable forum powered by Nabble | Forum Help |