I would also use the index parameter in the exception message. This way it is easier to track when something goes wrong.
And what is exactly wrong with a ClassCastException? The argument in this function is not illegal, but the state of the application is. Either 'IllegalStateException' or 'ClassCastException' should be used. Martijn -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Johan Compagner Verzonden: woensdag 1 december 2004 12:01 Aan: Wicket Developer List Onderwerp: [Wicket-develop] ClassCast exception not handled right in ListView we have these 2 methods: protected ListItem newItem(final int index) { Object model = getListObject(index); if (!(model instanceof Serializable)) { throw new IllegalArgumentException("ListView and ListItem model data must be serializable"); } return new ListItem(index, this); } protected Serializable getListObject(final int index) { return (Serializable) getList().get(index); } But the first with the check for instanceof will never be reached because the getListObject already tries to cast it i would vote to change it this way: protected ListItem newItem(final int index) { Object model = getListObject(index); return new ListItem(index, this); } protected Serializable getListObject(final int index) { Object object = getList().get(index); if (!(object instanceof Serializable)) { throw new IllegalArgumentException("ListView and ListItem model data must be serializable, data: " + object ); } return (Serializable) object; } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Wicket-develop mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/wicket-develop ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Wicket-develop mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/wicket-develop
