diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6272:24be0cc1c67c

Replaced the 'old school' wiki link buttons with default links.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 11 Jun 2013 12:57:51 +0200
parents 954dbb0806f3
children c28f13c80979
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Tue Jun 11 12:57:51 2013 +0200
@@ -8,6 +8,11 @@
 
 package org.dive4elements.river.client.client.ui;
 
+import com.smartgwt.client.types.FormMethod;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
 import com.smartgwt.client.widgets.grid.CellFormatter;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
@@ -37,29 +42,35 @@
         }
     }
 
-    public static String linkHTML(FLYS flys, String url, String text) {
+    public static DynamicForm linkHTML(FLYS flys, String url, String text) {
         String saml = flys.getCurrentUser().getSamlXMLBase64();
         String quotedUrl = SafeHtmlUtils.htmlEscape(url);
         String quotedText = SafeHtmlUtils.htmlEscape(text);
         if (saml != null) {
-            return "<form method=\"POST\" target=\"_blank\" action=\""
-                + quotedUrl + "\">"
-                + "<input type=\"hidden\" name=\"saml\" value=\""
-                + SafeHtmlUtils.htmlEscape(saml) + "\">"
-                + "<input type=\"submit\" value=\"" + quotedText + "\">"
-                + "</form>";
+            final DynamicForm form = new DynamicForm();
+            form.setMethod(FormMethod.POST);
+            form.setTarget("_blank");
+            form.setAction(quotedUrl);
+            form.setCanSubmit(true);
+            LinkItem item = new LinkItem("saml");
+            item.setShowTitle(false);
+            item.setLinkTitle(quotedText);
+            item.setValue(SafeHtmlUtils.htmlEscape(saml));
+            item.addClickHandler(new ClickHandler() {
+                @Override
+                public void onClick(ClickEvent event) {
+                    form.submitForm();
+                }
+            });
+            form.setFields(item);
+            return form;
         }
         else {
-            return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>";
+            DynamicForm form = new DynamicForm();
+            LinkItem item = new LinkItem(quotedText);
+            item.setShowTitle(false);
+            item.setTarget(quotedUrl);
+            return form;
         }
     }
-
-    public static CellFormatter cellFormatter(final FLYS flys) {
-        return new CellFormatter() {
-            public String format(Object value, ListGridRecord record,
-                                 int rowNum, int colNum) {
-                return linkHTML(flys, (String)value, record.getLinkText());
-            }
-        };
-    }
 }

http://dive4elements.wald.intevation.org