Hi,
I am actually migrate a web application to GWT. In order to reuse the existing page i put them in frame. However i have to develop a new popup for one of them and i would like to let this popup attached to the main module.Before i was parsing the html to get the element and with RootPanel attach a button. I can't do that anymore because it's in an Iframe.So i try to fire an event on click inside the iFrame to get the current element and if it's the right button show the popup ...
The ONLOAD event work pretty well but the ONCLICK don't work at all
my code sample :
package com.exp.client;
import com.google.gwt.user.client.DOM;import com.google.gwt.user.client.Event;import com.google.gwt.user.client.ui.Frame;import com.google.gwt.user.client.Window;
public class CustomFrame extends Frame {public CustomFrame(){sinkEvents(Event.ONCLICK);sinkEvents(Event.ONLOAD);setUrl("http://www.google.com");setSize("900px","900px");}public void onBrowserEvent(Event event){super.onBrowserEvent(event);switch (DOM.eventGetType(event)){case Event.ONCLICK:Window.alert("ONCLICK : "+ event.getEventTarget().toString() );DOM.eventPreventDefault(event);break;case Event.ONLOAD:Window.alert("ONLOAD");DOM.eventPreventDefault(event);break;}}}
Thanks for your help--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/-_OuFX0mHJUJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Hi,
My goal is to set gwt button inside my iFrame. If I do a RootPanel.get("my id").add(myButton) , it don't work because the id is inside the iFrame.I find out how get the Document of the iframe and get the Div Element but i still don't know how set a button on this div.
Thanks,
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/9ooi7wPMfIAJ.
To be honest i don't get it at all ...An other idea was to get the Document of the Iframe. That i got it , i even find the element i want by parsing the html.But i dunno how replace this Element by a GWT button attached to my main module ( I think it's necessary to show my popup ).
Thanks,
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/ThnSB9ylmsQJ.
So i should get my Document of my iframe. After i get my div element and to this div element i add a child and this child is a ButtonElement ...I can try that
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/ZRNm0TfdPHMJ.
Just to let you know i tried something like that :The wrap work perfectly with an element of the current dom but with an element i get from the iframe it does not work
Code sample :
IFrameElement iframe = IFrameElement.as(this.getElement());Document iframeDocument = iframe.getContentDocument();Element el = (Element) iframeDocument.getElementById("myhrefElement");Anchor testButton = Anchor.wrap(el);testButton.addClickHandler(new ClickHandler() {public void onClick(ClickEvent event) {Window.alert("CLIIIICKKK ");}});
By the way , thanks for your help
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/9_ZN-cin6a8J.
public final void setPropertyString(java.lang.String name,
java.lang.String value)
name -
the name of the property to be setvalue -
the new property valuename = onClick
value = "clickMe()"
Ok i see why , look at the source code of anchor :public static Anchor wrap(Element element) {// Assert that the element is attached.assert Document.get().getBody().isOrHasChild(element);
This element is not a child of the main Document .... So this wrap can't work
On Sunday, October 28, 2012 11:37:15 AM UTC-5, Hugues wrote:In fact it does not work :-/
I don't understand. In my debug i see the correct element but the wrap fail. I suppose the wrap fail because the element is not attached to the main DOM.Is it possible in gwt to wrap an element from an iframe as widget attached to the main module ?
Element currentElement = this.getElement();IFrameElement iframe = IFrameElement.as(currentElement);Document iframeDocument = iframe.getContentDocument();Element el= (Element) iframeDocument.getElementById("testiframe");final Anchor testButton = Anchor.wrap(el);
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/_9faTFjzfhwJ.