Mercurial > dive4elements > river
changeset 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 | 5ecc6d4d73f2 |
children | 90756201c488 |
files | gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java |
diffstat | 3 files changed, 24 insertions(+), 14 deletions(-) [+] |
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);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Thu Jul 18 13:16:33 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Thu Jul 18 13:25:29 2013 +0200 @@ -24,7 +24,7 @@ @Override protected void update() { - setContents(WikiLinks.imageLinkForm(instance, href, imgUrl)); + setContents(WikiLinks.imageLinkForm(instance, href, imgUrl, "wikiImgLink" + toString())); setWidth(width); setHeight(height); setOverflow(Overflow.VISIBLE);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Thu Jul 18 13:16:33 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Thu Jul 18 13:25:29 2013 +0200 @@ -22,7 +22,7 @@ public class WikiLinks { - public static String imageLinkForm(FLYS instance, String url, String imageUrl) { + public static String imageLinkForm(FLYS instance, String url, String imageUrl, String formName) { String saml = null; if (instance != null && instance.getCurrentUser() != null) { saml = instance.getCurrentUser().getSamlXMLBase64(); @@ -32,7 +32,7 @@ if (saml != null) { return "<form method=\"POST\" target=\"_blank\" action=\"" - + quotedUrl + "\">" + + quotedUrl + "\" " + "name=\"" + formName + "\">" + "<input type=\"hidden\" name=\"saml\" value=\"" + SafeHtmlUtils.htmlEscape(saml) + "\">" + "<input type=\"image\" src=\""+ quotedImage + "\">" @@ -86,14 +86,16 @@ 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); + //form.setValue("saml", saml); return form; } else {