diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java @ 6602:244beb29418e

Fix for SAML authentication in FLYSHeader's Info button (#702).
author Christian Lins <christian.lins@intevation.de>
date Thu, 18 Jul 2013 13:25:29 +0200
parents c949681a0ccb
children 9f3ffb218bc0
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java	Thu Jul 18 13:16:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java	Thu Jul 18 13:25:29 2013 +0200
@@ -12,6 +12,7 @@
 import com.google.gwt.i18n.client.LocaleInfo;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HTML;
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.BooleanCallback;
@@ -21,7 +22,6 @@
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.layout.HLayout;
 
 import org.dive4elements.river.client.client.Config;
@@ -136,20 +136,30 @@
         info.addClickHandler(new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
-                GWT.log("Clicked 'info' button.");
                 String wikiLink = Config.getInstance().getWikiUrl() + "/Info";
 
-                // Create a dynamic form which contains the SAML session
+                // Create a form which contains the SAML session
                 // for the user which is currently logged in
-                DynamicForm df = WikiLinks.dynamicForm(getFlys(), wikiLink);
-                info.addChild(df);    // add the form somewhere
-                df.submitForm();      // submit the form to go to the wiki
-                info.removeChild(df); // and remove the dynamic form
+                String html = WikiLinks.imageLinkForm(
+                        getFlys(), wikiLink, "", "wikiLinkForm");
+                HTML htmlObj = new HTML(html);
+                info.addChild(htmlObj);
+                fireWikiLinkSubmit();
+                htmlObj.removeFromParent();
             }
         });
         init();
     }
 
+    /**
+     * Calls the JS submit() function on the dynamically added
+     * wikiLinkForm. This is a workaround for a SmartGWT issue(?) that
+     * clears all form fields when using DynamicForm.submit() or .submitForm().
+     */
+    protected native void fireWikiLinkSubmit() /*-{
+        $doc.wikiLinkForm.submit();
+    }-*/;
+
     public void init() {
         setStyleName("header");
         setWidth100();
@@ -210,9 +220,7 @@
         right.addMember(userText);
         right.addMember(logout);
         right.addMember(language);
-        // TEMPORARILY DEACTIVATED: The info button to link in wiki.
-        // TODO (issue702)
-        //right.addMember(info);
+        right.addMember(info);
         right.addMember(bfg);
 
         addMember(left);

http://dive4elements.wald.intevation.org