On Sunday 26 February 2006 16:28, Andreas Bulling wrote: > Hi everybody, > > just a short question I wasn't able to find an answer to neither in the > archives nor in the online documentation:
Look at the example under the @PropertySelection component in the user guide. > > I have a PropertySelection component on my page showing a list of user > types the visitor can select from when registering himself on the page. > Instead of using the string value of the selection (the textual user type) > I want to use the Integer representation (the value of the select html > element). How can I accomplish that? I'm using a custom SelectionModel if > this is relevant ;) I made myself a component that does what I think you want below. (If you want to see more details of the usage, I have all the application on my web site. You can either browse the code - start by going to http://www.chandlerfamily.org.uk/git/?p=akcmoney.git;a=summary choose the latest commit from the shortlog - select that "commit" link and then in the resultant page select the "tree" link. That will show you the code which you can then browse either the Javasource of the WebContent Alternatively - the download page on my site has a tarball of the latest version package uk.org.chandlerfamily.akcmoney.components; /*Copyright (c) 2006 Alan Chandler, licenced under the GPL (see LICENCE.txt file in META-INF directory)*/ import org.apache.tapestry.form.IPropertySelectionModel; public class ValueSelectionModel implements IPropertySelectionModel { private String[] options; public ValueSelectionModel (String[] options) { this.options = options; } public int getOptionCount() { return options.length; } public Object getOption(int index) { return (Integer) index; } public String getLabel(int index) { return options[index]; } public String getValue(int index) { return Integer.toString(index); } public Object translateValue(String index) { return (Integer) Integer.parseInt(index); } } -- Alan Chandler http://www.chandlerfamily.org.uk Open Source. It's the difference between trust and antitrust. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
