if i select a row of the personallist the show me the wrong cityname in the combobox of the city row in the formular to testing the app you need to create a database in mysql called “test” in that database execute following sql dump http://www.rudolfschmidt.com/upload/test.sql
there seems to be an implicit assumption in the code that the city ID’s start at the index 0. This is not very good, you may want to file a ticket about this to the Vaadin trac. In the meantime, you can fix this in your code by either modifying your SQL script to start the ids at 0, or change how the getCityName(int cityId) method in line 220 of DatabaseHelper.java works.
Actually, that solved my combobox problem-- but then I noticed the city names in the table weren’t right. The tutorial code In DatabaseHelper.getCityName() looks like this:
I had to decrement cityId in order to get it to work. But isn’t there a bigger problem? This seems to assume the contents of the CITYID column not only begin at zero but ARE THE SAME AS CONTAINER ITEM INDEXES. Isn’t that assuming a lot? Shouldn’t the city item be found by looking for the matching cityId’s value?
I agree, this is quick and (too) dirty code. However it should work nicely, since the city id is auto increment and does not come from any unique index (i.e. always starts at 0 or 1), and the user has no way to delete cities. So actually the city id should always correspond to the container index. Of course this should not be relied on, and I think the tutorial needs to be fixed also.
The tutorial does seem to do this in the shortest way possible and assuming it is in full control of the database - not how you would do it in a real production application.