Correctly emit the selected values when rendering
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/a3c3cea7 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/a3c3cea7 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/a3c3cea7 Branch: refs/heads/5.4-js-rewrite Commit: a3c3cea790224adf80b38eb7f12d16382b08cb50 Parents: c042c43 Author: Howard M. Lewis Ship <[email protected]> Authored: Wed Nov 7 11:47:23 2012 -0800 Committer: Howard M. Lewis Ship <[email protected]> Committed: Wed Nov 7 11:47:23 2012 -0800 ---------------------------------------------------------------------- .../tapestry5/corelib/components/Palette.java | 19 +++++++-------- 1 files changed, 9 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a3c3cea7/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java index e3dc476..cbf4150 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java @@ -25,8 +25,6 @@ import org.apache.tapestry5.ioc.annotations.Symbol; import org.apache.tapestry5.json.JSONArray; import java.util.Collection; -import java.util.List; -import java.util.Map; /** * Multiple selection component. Generates a UI consisting of two <select> elements configured for multiple @@ -148,13 +146,6 @@ public class Palette extends AbstractField @Property(write = false) private boolean reorder; - /** - * Used during rendering to identify the options corresponding to selected values (from the selected parameter), in - * the order they should be displayed on the page. - */ - private List<OptionModel> selectedOptions; - - private Map<Object, OptionModel> valueToOptionModel; /** * Number of rows to display. @@ -191,7 +182,15 @@ public class Palette extends AbstractField public String getInitialJSON() { - return new JSONArray().toString(compactJSON); + JSONArray array = new JSONArray(); + + for (Object o : selected) + { + String value = encoder.toClient(o); + array.put(value); + } + + return array.toString(compactJSON); }
