You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2008/01/20 01:32:59 UTC
[Tapestry Wiki] Trivial Update of "Tapestry5NamedSelectModel" by TedSteen
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by TedSteen:
http://wiki.apache.org/tapestry/Tapestry5NamedSelectModel
------------------------------------------------------------------------------
+ = Named property selection model =
+
+ === NamedSelectModel.java ===
{{{
import java.util.ArrayList;
import java.util.List;
@@ -55, +58 @@
}
}}}
+
+ == Usage ==
+ === Test.java ===
+ {{{
+ import java.util.Arrays;
+
+ import org.apache.tapestry.SelectModel;
+ import org.apache.tapestry.annotations.Persist;
+ import org.apache.tapestry.ioc.annotations.Inject;
+ import org.apache.tapestry.ioc.services.TypeCoercer;
+ import org.darkbits.medina.web.base.ShopBase;
+ import org.darkbits.medina.web.util.NamedSelectModel;
+
+ public class Test
+ {
+ @Inject
+ private TypeCoercer coercer;
+
+ @Persist
+ private String colour;
+
+ public SelectModel getSelectModel()
+ {
+ return new NamedSelectModel("Select a colour", coercer.coerce(Arrays.asList("Red","Green","Blue"), SelectModel.class));
+ }
+
+ public String getColour()
+ {
+ return colour;
+ }
+
+ public void setColour(String colour)
+ {
+ this.colour = colour;
+ }
+ }
+ }}}
+
+ === template ===
+ {{{
+ Colour: <t:select model="selectModel" value="colour" />
+ }}}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org