[PATCH] GWT client: Do not assumed there is always a SAML ticket when generating Wiki links

Wald Commits scm-commit at wald.intevation.org
Wed Sep 11 11:41:35 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1378892489 -7200
# Node ID e562a9a42495bb6f3d8556f436cea27641e6f1d9
# Parent  1faf543e267c5998f925b16f896f0a0fbfb6d549
GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.

diff -r 1faf543e267c -r e562a9a42495 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Wed Sep 11 09:59:00 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Wed Sep 11 11:41:29 2013 +0200
@@ -102,8 +102,6 @@
         DynamicForm infoLink = WikiLinks.linkDynamicForm(this.flys, wikiBaseUrl + url,
                                         MSG.gauge_river_info_link());
         infoLink.setTop(5);
-        LinkItem item = (LinkItem)infoLink.getField("saml");
-        item.setTextBoxStyle("font-size: large;");
         add(infoLink);
     }
 
diff -r 1faf543e267c -r e562a9a42495 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Wed Sep 11 09:59:00 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Wed Sep 11 11:41:29 2013 +0200
@@ -50,31 +50,32 @@
 
         if (currentUser != null) {
             String saml = currentUser.getSamlXMLBase64();
-            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;
+            if (saml != null) {
+                final DynamicForm form = new DynamicForm();
+                form.setMethod(FormMethod.POST);
+                form.setTarget("_blank");
+                form.setAction(quotedUrl);
+                form.setCanSubmit(true);
+                LinkItem item = new LinkItem("saml");
+                item.setTextBoxStyle("font-size: large;");
+                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 {
-            DynamicForm form = new DynamicForm();
-            LinkItem item = new LinkItem(quotedText);
-            item.setShowTitle(false);
-            item.setTarget(quotedUrl);
-            return form;
-        }
+        DynamicForm form = new DynamicForm();
+        LinkItem item = new LinkItem(quotedText);
+        item.setShowTitle(false);
+        item.setTarget(quotedUrl);
+        return form;
     }
 
     public static DynamicForm dynamicForm(FLYS flys, String url) {
@@ -83,26 +84,26 @@
 
         if (currentUser != null) {
             String saml = currentUser.getSamlXMLBase64();
-            saml = SafeHtmlUtils.htmlEscape(saml);
-            GWT.log("saml=" + saml);
-            DynamicForm form = new DynamicForm();
-            form.setID("wikiDynamicForm");
-            form.setMethod(FormMethod.POST);
-            form.setTarget("_blank");
-            form.setAction(quotedUrl);
-            form.setCanSubmit(true);
-            HiddenItem item = new HiddenItem("saml");
-            item.setDefaultValue(saml);
-            item.setValue(saml);
-            form.setFields(item);
-            //form.setValue("saml", saml);
-            return form;
+            if (saml != null) {
+                saml = SafeHtmlUtils.htmlEscape(saml);
+                GWT.log("saml=" + saml);
+                DynamicForm form = new DynamicForm();
+                form.setID("wikiDynamicForm");
+                form.setMethod(FormMethod.POST);
+                form.setTarget("_blank");
+                form.setAction(quotedUrl);
+                form.setCanSubmit(true);
+                HiddenItem item = new HiddenItem("saml");
+                item.setDefaultValue(saml);
+                item.setValue(saml);
+                form.setFields(item);
+                //form.setValue("saml", saml);
+                return form;
+            }
         }
-        else {
-            DynamicForm form = new DynamicForm();
-            form.setTarget("_blank");
-            form.setAction(quotedUrl);
-            return form;
-        }
+        DynamicForm form = new DynamicForm();
+        form.setTarget("_blank");
+        form.setAction(quotedUrl);
+        return form;
     }
 }


More information about the Dive4elements-commits mailing list