changeset 6986:e562a9a42495

GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 11 Sep 2013 11:41:29 +0200
parents 1faf543e267c
children fc2de41ebdb8
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java
diffstat 2 files changed, 45 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- 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);
     }
 
--- 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;
     }
 }

http://dive4elements.wald.intevation.org