Author: nbelaevski
Date: 2007-11-29 11:48:04 -0500 (Thu, 29 Nov 2007)
New Revision: 4353
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
Log:
listShuttle: check for duplicate keys added
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-11-29
16:20:06 UTC (rev 4352)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-11-29
16:48:04 UTC (rev 4353)
@@ -212,8 +212,42 @@
}
public void setSubmittedStrings(String[] submittedStrings) {
- //TODO check for parameters correlation
this.submittedValueHolder = new SubmittedValue(submittedStrings);
+ final Map sourceTranslationTable =
this.submittedValueHolder.getSourceTranslationTable();
+ final Map targetTranslationTable =
this.submittedValueHolder.getTargetTranslationTable();
+
+ if (sourceTranslationTable != null && targetTranslationTable != null) {
+ sourceTranslationTable.entrySet().removeAll(targetTranslationTable.entrySet());
+ } else {
+ ListShuttleDataModel dataModel = (ListShuttleDataModel) getExtendedDataModel();
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ try {
+ if (sourceTranslationTable != null) {
+ dataModel.walkTarget(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ sourceTranslationTable.entrySet().remove(rowKey);
+ }
+
+ }, null, null);
+ } else if (targetTranslationTable != null) {
+ dataModel.walkSource(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ targetTranslationTable.entrySet().remove(rowKey);
+ }
+
+ }, null, null);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e.getLocalizedMessage(), e);
+ }
+ }
}
protected Object saveIterationSubmittedState() {
Show replies by date