Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java @ 9369:1a4d2ce77423
radio choice fix
author | gernotbelger |
---|---|
date | Thu, 02 Aug 2018 17:39:13 +0200 |
parents | c7e5285d434f |
children |
comparison
equal
deleted
inserted
replaced
9366:3d006afee054 | 9369:1a4d2ce77423 |
---|---|
26 public abstract class RadioSelect extends DefaultState { | 26 public abstract class RadioSelect extends DefaultState { |
27 | 27 |
28 private static final long serialVersionUID = 1L; | 28 private static final long serialVersionUID = 1L; |
29 private Artifact artifact; | 29 private Artifact artifact; |
30 | 30 |
31 public RadioSelect() { | 31 protected abstract String getDatakey(); |
32 | 32 |
33 } | 33 @Override |
34 protected abstract String getUIProvider(); // force override in subs! | |
35 // { | |
36 // return "radio_panel"; //no generic radiopanel | |
37 // } | |
34 | 38 |
35 protected abstract LinkedHashMap<String, String> makeEntries(CallMeta meta, Artifact artifact); // AUSNAHMSWEISE EXPLIZITER TYP, damit Reihenfolge nicht | 39 protected abstract LinkedHashMap<String, String> makeEntries(CallMeta meta, Artifact artifact); // AUSNAHMSWEISE EXPLIZITER TYP, damit Reihenfolge nicht |
36 // verrutscht | 40 // verrutscht |
37 | 41 |
38 @Override | 42 @Override |
39 protected String getUIProvider() { | |
40 return "radio_panel"; | |
41 } | |
42 | |
43 @Override | |
44 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { | 43 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { |
45 | 44 |
46 // REMEBER: we need it for getLabelFor later | 45 // REMEBER: we need it for getLabelFor later |
47 this.artifact = artifact; | |
48 | 46 |
49 final CallMeta meta = context.getMeta(); | 47 if (name.equals(getDatakey())) { |
50 final Map<String, String> entries = makeEntries(meta, artifact); | 48 this.artifact = artifact; |
51 | 49 |
52 final Element[] elements = new Element[entries.size()]; | 50 final CallMeta meta = context.getMeta(); |
53 int i = 0; | 51 final Map<String, String> entries = makeEntries(meta, artifact); |
54 for (final String key : entries.keySet()) { | 52 |
55 final String label = entries.get(key); | 53 final Element[] elements = new Element[entries.size()]; |
56 final String labelToSet = label != null ? label : Resources.getMsg(meta, key); | 54 int i = 0; |
57 elements[i] = createItem(ec, new String[] { labelToSet, key }); | 55 for (final String key : entries.keySet()) { |
58 i++; | 56 final String label = entries.get(key); |
57 final String labelToSet = label != null ? label : Resources.getMsg(meta, key); | |
58 elements[i] = createItem(ec, new String[] { labelToSet, key }); | |
59 i++; | |
60 } | |
61 return elements; | |
59 } | 62 } |
60 return elements; | 63 return super.createItems(ec, artifact, name, context); |
61 } | 64 } |
62 | 65 |
63 @Override | 66 @Override |
64 protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) { | 67 protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) { |
65 // artifacts must be set in "createItems" -> createItems has to be called first | 68 // artifacts must be set in "createItems" -> createItems has to be called first |