Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 615:01054ddccb0f
Repaired multi parameter selection.
gnv-artifacts/trunk@685 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 12 Feb 2010 15:36:05 +0000 |
parents | e80e37b78302 |
children | 65f09139e9b3 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Fri Feb 12 15:36:05 2010 +0000 @@ -225,7 +225,7 @@ boolean valid = iv.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { - String desc = getDescriptionForInputData(tmpItem, uuid); + String[] desc = getDescriptionForInputData(tmpItem, uuid); tmpItem.setDescription(desc); this.inputData.put(tmpItem.getName(), tmpItem); } else { @@ -249,24 +249,31 @@ } - private String getDescriptionForInputData(InputData data, String uuid) { + private String[] getDescriptionForInputData(InputData data, String uuid) { // there is only one element in the list, so take the first Object obj = getDescibeData(uuid).get(0); + List descs = new ArrayList(); if (obj instanceof NamedArrayList) { NamedArrayList list = (NamedArrayList) obj; + String[] selected = data.splitValue(); int size = list.size(); + int ssize = selected.length; for (int i = 0; i < size; i++) { KeyValueDescibeData kv = (KeyValueDescibeData) list.get(i); - if (kv.getKey().equals(data.getValue())) { - return kv.getValue(); + // values are concatinated in InputData, so one InputData object can + // contain many input + for (int j = 0; j < ssize; j++) { + if (kv.getKey().equals(selected[j])) { + descs.add(kv.getValue()); + } } } } - return data.getValue(); + return (String[]) descs.toArray(new String[descs.size()]); } @@ -675,32 +682,28 @@ .getRessource(callMeta.getLanguages(), dataName, dataName)); Element choiceNode = creator.create("choices"); - /* TODO InputData can have more than 1 value if multiselect, implement a - * loop over these values - - while (resultIt.hasNext()) { - KeyValueDescibeData result = resultIt.next(); - */ - artCreator.addAttr( selectNode, "state", getID(), true ); - Element itemNode = creator.create("item"); - - creator.addAttr(itemNode, "selected", "true"); + String[] descriptions = data.getDescription(); + int size = descriptions.length; - Element choiceLableNode = creator.create("label"); - choiceLableNode.setTextContent(data.getDescription()); - itemNode.appendChild(choiceLableNode); + for (int i = 0; i < size; i++) { + Element itemNode = creator.create("item"); - Element choiceValueNode = creator.create("value"); - choiceValueNode.setTextContent(dataName); - itemNode.appendChild(choiceValueNode); - choiceNode.appendChild(itemNode); - /* + creator.addAttr(itemNode, "selected", "true"); + + Element choiceLableNode = creator.create("label"); + choiceLableNode.setTextContent(descriptions[i]); + itemNode.appendChild(choiceLableNode); + + Element choiceValueNode = creator.create("value"); + choiceValueNode.setTextContent(dataName); + itemNode.appendChild(choiceValueNode); + choiceNode.appendChild(itemNode); } - */ + selectNode.appendChild(lableNode); selectNode.appendChild(choiceNode); @@ -922,7 +925,6 @@ List<Object> data = queryDatabase(filterValues, uuid); cache.put(new net.sf.ehcache.Element(key, data)); - return data; } catch (QueryException qe) {