Re: Navigating Wicket DataTable's
Igor - Are you saying that your approach below is better than parsing the component path string as I was doing, for navigating up the component hierarchy? That makes sense to me. That addresses the first three questions: * What row am I in? * What column am I in? * What is the table that contains me? Is there a connection with the other questions that I'm missing? * 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? Are there others who share my interest in this functionality? It would be really helpful if it were incorporated into the Wicket distribution if so. Having the methods on the Component class would be really handy, even though they would usually not be applicable (and it could be argued that it's not a good idea for that reason). Second best is a static class as I had it. Is there a better way? I wouldn't want to subclass every Wicket component we ever use to get this functionality. Can anyone point me to a better implementation of it, to add to Igor's suggestion, or otherwise provide any helpful advice? Thanks, Keith Igor Vaynberg wrote: datatable { populateitem(item i) { int col=i.getindex(); int row=i.getparent(Item.class).getindex(); } } -igor On Thu, Nov 26, 2009 at 7:27 PM, Keith Bennett keithrbenn...@gmail.com 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: http://gist.github.com/243802 and http://gist.github.com/243800 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: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Can I Suppress Type Conversion Feedback Messages?
Igor - Thanks for the speedy responses. As I understand it, convertInput()'s main mission is to populate the convertedInput instance variable with the converted value, and overriding it as you suggest would be trivial. Just to be sure though, you don't foresee any change in Wicket internals that would make this solution obsolete, inadequate, or otherwise incorrect? Thanks, Keith On Nov 27, 2009, at 1:19 AM, Igor Vaynberg wrote: override convertinput() on that textfield and do not throw a conversion exception -igor On Thu, Nov 26, 2009 at 6:26 PM, Keith Bennett keithrbenn...@gmail.com wrote: Hi all... We have a form that has a table, and the table has a column that is populated with TextFieldInteger's. When there are nonnumeric characters in several of these fields, we get an error message in the feedback panel for each offending field. We'd rather combine them into a single message saying something like n Solicitation Number fields contained nonnumeric characters. I know how to create the combined message, but how can I suppress the individual ones? Thanks, Keith --- Keith R. Bennett Senior Software Consultant Linked In: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Adding a User Object to the Component Class
Igor Martijn - Thanks for all the information. I didn't know about the existence of metadata in the various classes; that's what I was looking for. I have a question about the metadata implementation. The javadoc indicates that the special MetaDataKey approach (rather than using a plain Map) is necessary because object identity will not work due to serializations and deserializations. However, although Object's equals() tests for identity, other classes override it for tests of logical equality. So why isn't it possible to use a regular Map and rely on the programmer to provide an appropriate equals() for custom classes? Thanks, Keith On Nov 27, 2009, at 2:55 AM, Igor Vaynberg wrote: datatable.setmetadata(mykey, myobject); .. somewhere in a component under datatable public mytype findreference() { datatable table=findparent(datatable.class); return table.getmetadata(mykey); } -igor On Thu, Nov 26, 2009 at 11:02 PM, Keith Bennett keithrbenn...@gmail.com wrote: Igor - Thanks for responding. The User solution would work where all components would share the same reference, but I need each table would have its own reference. Also, I was thinking it would be nice for each component to have its own Object. I realize I could have been clearer about that. Thanks, Keith On Nov 27, 2009, at 1:16 AM, Igor Vaynberg wrote: create your own subclass of websession that holds the user and then anywhere within a wicket request you can get to it via: ((MySession)Session.get()).getUser() -igor On Thu, Nov 26, 2009 at 6:20 PM, Keith Bennett keithrbenn...@gmail.com wrote: All - I'm coding a Wicket table and would like all the components in the table to have access to a specific reference. Another framework I worked with a very long time ago (Vermont Views, I believe) addressed this by providing a user pointer in the class that could be used for any purpose the programmer wanted. It was a void * in C; in Java it would be an Object reference. What do you think about adding this to Wicket's Component class, and maybe even others, like Page, Form, etc.? Thanks, Keith --- Keith R. Bennett Senior Software Consultant Linked In: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Getting an Application Property Without a Component
I'd like to be able to access a property in my application properties file (e.g. MyApplication.properties) during the construction of a table column (implementation of IColumn). IColumn is not a Component, so I don't have a get() method for this. Since I can get an instance of the application ((MyApplication) MyApplication.get()), I was hoping to get a property that way. I can't though; so far the only way I've been able to think of was to create a dummy component for the sole purpose of calling its get() method on the property key. Is there a better way? Thanks, Keith - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Adding a User Object to the Component Class
All - I'm coding a Wicket table and would like all the components in the table to have access to a specific reference. Another framework I worked with a very long time ago (Vermont Views, I believe) addressed this by providing a user pointer in the class that could be used for any purpose the programmer wanted. It was a void * in C; in Java it would be an Object reference. What do you think about adding this to Wicket's Component class, and maybe even others, like Page, Form, etc.? Thanks, Keith --- Keith R. Bennett Senior Software Consultant Linked In: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Navigating Wicket DataTable's
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: http://gist.github.com/243802 and http://gist.github.com/243800 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: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Adding a User Object to the Component Class
Igor - Thanks for responding. The User solution would work where all components would share the same reference, but I need each table would have its own reference. Also, I was thinking it would be nice for each component to have its own Object. I realize I could have been clearer about that. Thanks, Keith On Nov 27, 2009, at 1:16 AM, Igor Vaynberg wrote: create your own subclass of websession that holds the user and then anywhere within a wicket request you can get to it via: ((MySession)Session.get()).getUser() -igor On Thu, Nov 26, 2009 at 6:20 PM, Keith Bennett keithrbenn...@gmail.com wrote: All - I'm coding a Wicket table and would like all the components in the table to have access to a specific reference. Another framework I worked with a very long time ago (Vermont Views, I believe) addressed this by providing a user pointer in the class that could be used for any purpose the programmer wanted. It was a void * in C; in Java it would be an Object reference. What do you think about adding this to Wicket's Component class, and maybe even others, like Page, Form, etc.? Thanks, Keith --- Keith R. Bennett Senior Software Consultant Linked In: http://www.linkedin.com/in/keithrbennett Blogs: http://krbtech.wordpress.com, http://keithrbennett.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Test Methods for Querying Component Tree
Hello, all. I am relatively new to Wicket. Sometimes when I write tests I get the Wicket ID wrong, and try to figure out what the right one is. To address this, I wrote some code that gets the component tree, and either returns a List, or a string with the components' id's and classes. It can be found at http://gist.github.com/144041. Is this useful to anyone? Is there a better way for me to view the component tree at runtime/test time? Thanks, Keith - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
How to Make a Multiselect Drop Down or Check Box List Collapsible?
We would like to have a multiselect component that only takes up a single line on the page when not active. For example, something that looks and behaves like the DropDownChoice, but that allows multiple selection when activated, would be nice. Is there such a thing in Wicket? Thanks, Keith - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org