Am Dienstag, den 08.09.2009, 09:10 +1000 schrieb Chris Colman: > When my web designer guy wants control over whether he wants to place > either 10 songs or 50 songs into the 'top of the charts' panel I > consider that to be something that should definitely not be something we > have to make separate .java panel classes and markup to achieve.
Ok.. maybe you can use this: In your Panel you can use getString("EntriesInMyPanel") and convert this to Integer. You have to put a "EntriesInMyPanel=10" in you MyPanel.properties-File, so that the web designer can change this, without changing the code. > To have to get a programmer to adjust code to change the number of items > displayed in a list would be the subject of thunderous laughter in any > desktop app development environment - but yet I see that web app > development changes all the rules about what's funny and what's not =) You can not always express some changes to a display in a simple Number.. especially in desktop development this could lead to a more complex rule: show me as many songs as far the fit into the space used by this component, but show at least 3 entries full and the rest in compressed form. I did not see any simple number in this. So IMHO you have to write code for this. By the way.. maybe the best person to choose the right number is the user. > We programmer propeller heads can do all the smarts on the Java side to > use a single 'SongChartPanel' to display any number of songs from a list > based on a single parameter - so long as we can get that parameter > somehow. It's still MVC because NO code exists in the presentation layer > - only a parameter is now able to be passed in. You can pass the Parameter into the Component as Parameter or as Model. But IMHO there is no advantage for a static solution like putting it into a markup- or a propertyfile. > .. and it's something > that directly affects the presentation side that he would want control > over. That gives him power. because html is limited in a way, that this "power" is necessary sometimes. but it's not a good idea. it's more a compromise. > Without this power I have to get the programmers to create a different > panel and markup for each different song chart panel even though the > code will be exactly the same except for the terminating condition of a > for loop. why? what is different between a 10 or a 50 item song panel? the number of items? you should anyhow use a ListView which repeats the "her is the song"-block as many times as you want to.. > That's not OO and it's not reusability. It would be funny if > it wasn't true! it is not true.. so i think you did not get the picture.. or we are misunderstanding each other.. > Let's say we make > > SongChartTop10Panel and SongChartTop50Panel > > (with .java and .html markup for each) > > Now he says he wants to make a top 20 list for one page and a top 40 > list for another page... the inefficiency and non OO nature of this > approach becomes apparent. why do you make this? > If a simple parameter were able to be passed to the panel we could reuse > that panel code to show anywhere from 1 to n songs. class SongChartPanel { public SongChartPanel(String id,final int numberOfSongs) { LoadableDetachedModel<List<Song>> songs=new LoadableDetachedModel<List<Song>>() { public List<Song> load() { return Songs.getTopX(numberOfSongs); } } add(new ListView<Song>("list",songs) { public void populateItem(ListItem<Song> item) { item.add(new Label("name",item.getModelObject().getSongName())); } }); } } If you change numberOfSongs to a Model.. the User could change the number (Form, Link,.. anything). mm:) --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org