Hi
have you tried my snippet ?
create a ScriptElement and set the function text setText i.e. "function
clickMe() {windows.alert('YEA')}"
http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/dom/client/ScriptElement.html#setText(java.lang.String)
<http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/dom/client/ScriptElement.html#setText%28java.lang.String%29>
Then create a ButtonElement with Document.createButtonElement()
you should get the way to add in the innerHtml onClick="clickMe()"
IT SHOULD BE the setPropertyString method
setPropertyString
public final void*setPropertyString*(java.lang.String name,
java.lang.String value)
Sets a property on this element.
*Parameters:*
|name|- the name of the property to be set
|value|- the new property value
name = onClick
value = "clickMe()"
remember that Html works as well as XML so the onClick is an
attribute.......
Il 28/10/2012 17:41, Hugues ha scritto:
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);
testButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("CLIIIICKKK ");
}
});
On Sunday, October 28, 2012 2:40:22 AM UTC-5, Fabio wrote:
Well, if it works good for you...
But if you created a ScriptElement with the function test
equal to i.e. "function clickMe { window.alert("Click")}"
and then on the ButtonElement you set the value i.e.
setValue("clickMe()") it worked as well....
anyway
you're welcome!!!!
Il 28/10/2012 01:29, Hugues ha scritto:
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
On Saturday, October 27, 2012 4:58:16 PM UTC-5, Fabio wrote:
EXACTLY
get the Document, creaate a ButtonElement from the Document.
But you must also create a ScriptElement and set the text
of the function and then call click from the ButtonElement
Il 27/10/2012 23:48, Hugues Lara ha scritto:
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
On Saturday, October 27, 2012 4:46:25 PM UTC-5, Fabio
wrote:
Hi Lara
you can not replace the element with your button
becasue your Button is a Widget
while the button that you want to put in there must
be a ButtonElement
why ?
because the Widget are used by GWT to translate that
code into javascript.
Once translated in javascript work is done.
In your case you download a web page with the Frame,
then google ALSO provides mechanism to manipulate
html page and Javascript
so your html page now must be handled by a reverse
engineering and threat that button as a ButtonElement
is that clear ?
Il 27/10/2012 23:38, Hugues Lara ha scritto:
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,
On Saturday, October 27, 2012 4:28:03 PM UTC-5,
Fabio wrote:
No you can't do that, but you have to take this
other way:
extending our target, you want to add a Widget,
because your button is a Widget, into a
Document as javascript language provides.
Infact you get a Document made by Elements.
So I think you have to use the method
appendChild where the child is a ButtonElement
see
http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/index.html?com/google/gwt/dom/client/ButtonElement.html
<http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/index.html?com/google/gwt/dom/client/ButtonElement.html>
so you have to simulate javascript.
The Button you mean is a Widget and use to
CREATE a javascript, in that case everything
has been already translated into javascript
is that clear ?
Il 27/10/2012 22:56, Hugues Lara ha scritto:
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,
On Saturday, October 27, 2012 3:38:59 PM
UTC-5, Fabio wrote:
Hi
did you add a ClickHandler ? it doesnt
seems to implements a clickHandler
bye
Il 27/10/2012 22:07, Hugues Lara ha scritto:
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"
<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
<https://groups.google.com/d/msg/google-web-toolkit/-/-_OuFX0mHJUJ>.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send
email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
<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
<https://groups.google.com/d/msg/google-web-toolkit/-/9ooi7wPMfIAJ>.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
<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/-/ThnSB9ylmsQJ
<https://groups.google.com/d/msg/google-web-toolkit/-/ThnSB9ylmsQJ>.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
<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/-/ZRNm0TfdPHMJ
<https://groups.google.com/d/msg/google-web-toolkit/-/ZRNm0TfdPHMJ>.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
<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/-/9_ZN-cin6a8J
<https://groups.google.com/d/msg/google-web-toolkit/-/9_ZN-cin6a8J>.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
<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/-/_9faTFjzfhwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.