Sunday, October 30, 2022

[ANN] JRS gwt-time 1.4.22/2.0.10 release

Hi,

JRS gwt-time 1.4.22/2.0.10 has been released.


Details are on https://github.com/foal/gwt-time/releases/tag/v1.4.22 and https://github.com/foal/gwt-time/releases/tag/v2.0.10

Project page - https://github.com/foal/gwt-time

Best,
Stas

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/fdbb96b7-a3b4-42f4-9a44-89a38cf54b86n%40googlegroups.com.

[ANN] JRS gwt-time 1.4.22/2.0.10 release

Hi,

JRS gwt-time 1.4.22/2.0.10 has been released.

  • TZDB  2022egtz 
  • CLDR 42
  • last updates from ThreeTen 1.6.3 release (https://github.com/ThreeTen/threetenbp) merged.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f4b98857-9607-4990-87b6-1070a1456766n%40googlegroups.com.

Friday, October 28, 2022

Re: Security Vulnerabilities with GWT

This is discussed at https://github.com/gwtproject/gwt/issues/9778 and https://github.com/gwtproject/gwt/issues/9752: this is a false positive, but still needs to be corrected. The simplest fix is probably to just stop packaging up the "I am running an old version" marker file, since the

Is there a functioning "bug bounty" tool for github? I found a few options that all seem defunct, but this seems like a good candidate for someone to either scratch their own itch and get it fixed, or fund someone else who has the time.

Regardless, as someone not actually affected by this false positive (so I can't justify the time right now to focus on it, run the verification that tools accept the output, etc), I'll put up a bounty of 100USD (via paypal/etc) to see this fixed, with a bonus 100USD for a first-time contributor. If someone has experience with a platform for setting up bounties like this, it might be helpful to formalize future issues.

On Wednesday, October 26, 2022 at 4:07:48 PM UTC-5 bsha...@qvera.com wrote:
I know that this conversation is about 2 years old.  We upgraded to GWT 2.10 in hopes that it would resolve the following vulnerabilities with protobuf-java, they are all being reports in the gwt-servlet.jar (version 2.10.0):

These are all being reported in our project by the AWS Enhanced Scanning.  It there any way to upgrade Protobuf from 2.5.0 to the latest version of 3.21.8?

Thanks in advance.
Ben

On Tuesday, June 30, 2020 at 4:16:01 AM UTC-6 priyako...@gmail.com wrote:
Thank you very much for quick responses.
Here are Vulnerabilities listed -


Gwt-dev.jar -
1.1 Vulnerable version of jetty library(current version-- 9.2.14, available version -9.2.27+ ) 
[Associated CVEs -  CVE-2017-7656,CVE-2017-7657,CVE-2017-7658,CVE-2017-9735,CVE-2018-12536]
1.2 Vulnerable version of commons-collections(current version - 3.2.1)  [ CVE-2015-6420,CVE-2017-15708,CVE-2014-3577]
1.3 Vulnerable version of org.apache.httpcomponents:httpclient(current version - 4.3.1)  [ CVE-2015-6420,CVE-2017-15708,CVE-2014-3577]
1.4 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0) [CVE-2015-5237]
1.5  Vulnerable version of htmlunit ( current version - 2.19 , available version- 2.37) [CVE-2020-5529]

Gwt-servlet.jar -
        1.1 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0) [CVE-2015-5237]


On Monday, 29 June 2020 16:27:41 UTC+5:30, Priya Kolekar wrote:

Hi All,

Security Vulnerability have been detected in gwt-dev.jar & gwt-servlet.jar(in release 2.8.2) & are reported by Dependency checker tool.

Below are the details -

Gwt-dev.jar -
1.1 Vulnerable version of jetty library(current version-- 9.2.14, available version -9.2.27+ )
1.2 Vulnerable version of commons-collections(current version - 3.2.1)
1.3 Vulnerable version of org.apache.httpcomponents:httpclient(current version - 4.3.1)
1.4 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0)
1.5  Vulnerable version of htmlunit ( current version - 2.19 , available version- 2.37)

Gwt-servlet.jar -
        1.1 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0)

Given above vulnerabilities -
1. Are those security issues addressed in latest 2.9.0 release?
2. If no, is there a plan to include them in any future release say 3.x?
3. As we know that gwt-dev.jar is used for development purpose & can be flagged as false positive, still are there any attack surfaces exists?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/1bdbe148-b8c7-41a8-bbdc-90d0dfb0ffedn%40googlegroups.com.

Wednesday, October 26, 2022

Re: Security Vulnerabilities with GWT

I know that this conversation is about 2 years old.  We upgraded to GWT 2.10 in hopes that it would resolve the following vulnerabilities with protobuf-java, they are all being reports in the gwt-servlet.jar (version 2.10.0):
https://nvd.nist.gov/vuln/detail/CVE-2022-3171
https://www.cve.org/CVERecord?id=CVE-2015-5237
https://github.com/advisories/GHSA-wrvw-hg22-4m67
https://github.com/advisories/GHSA-h4h5-3hr4-j3g2
https://nvd.nist.gov/vuln/detail/CVE-2021-22569

These are all being reported in our project by the AWS Enhanced Scanning.  It there any way to upgrade Protobuf from 2.5.0 to the latest version of 3.21.8?

Thanks in advance.
Ben

On Tuesday, June 30, 2020 at 4:16:01 AM UTC-6 priyako...@gmail.com wrote:
Thank you very much for quick responses.
Here are Vulnerabilities listed -


Gwt-dev.jar -
1.1 Vulnerable version of jetty library(current version-- 9.2.14, available version -9.2.27+ ) 
[Associated CVEs -  CVE-2017-7656,CVE-2017-7657,CVE-2017-7658,CVE-2017-9735,CVE-2018-12536]
1.2 Vulnerable version of commons-collections(current version - 3.2.1)  [ CVE-2015-6420,CVE-2017-15708,CVE-2014-3577]
1.3 Vulnerable version of org.apache.httpcomponents:httpclient(current version - 4.3.1)  [ CVE-2015-6420,CVE-2017-15708,CVE-2014-3577]
1.4 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0) [CVE-2015-5237]
1.5  Vulnerable version of htmlunit ( current version - 2.19 , available version- 2.37) [CVE-2020-5529]

Gwt-servlet.jar -
        1.1 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0) [CVE-2015-5237]


On Monday, 29 June 2020 16:27:41 UTC+5:30, Priya Kolekar wrote:

Hi All,

Security Vulnerability have been detected in gwt-dev.jar & gwt-servlet.jar(in release 2.8.2) & are reported by Dependency checker tool.

Below are the details -

Gwt-dev.jar -
1.1 Vulnerable version of jetty library(current version-- 9.2.14, available version -9.2.27+ )
1.2 Vulnerable version of commons-collections(current version - 3.2.1)
1.3 Vulnerable version of org.apache.httpcomponents:httpclient(current version - 4.3.1)
1.4 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0)
1.5  Vulnerable version of htmlunit ( current version - 2.19 , available version- 2.37)

Gwt-servlet.jar -
        1.1 Vulnerable version of Google Protobuf(current version - 2.5.0, available version - 3.4.0)

Given above vulnerabilities -
1. Are those security issues addressed in latest 2.9.0 release?
2. If no, is there a plan to include them in any future release say 3.x?
3. As we know that gwt-dev.jar is used for development purpose & can be flagged as false positive, still are there any attack surfaces exists?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/5ee8893c-b867-4457-87f9-0e68f1fcc26dn%40googlegroups.com.

Tuesday, October 25, 2022

Re: Modern browsers support for Copyclipboard functionality

The  doc.execCommand('copy'), while deprecated, still works.  Eg:

@UiField TextBox myTextBox;

myTextBox.setFocus(true);
myTextBox.selectAll();
boolean success = copyToClipboard();

private static native boolean copyToClipboard() /*-{
    return $doc.execCommand('copy');
}-*/;

If you run your site over HTTPS, the user grants permissions, and you jump though lots of hoops, you can also use the $wnd.clipboardData.readText() and $wnd.clipboardData.writeText(myText).

On Saturday, 22 October 2022 at 8:10:57 pm UTC+11 vas...@gmail.com wrote:
Well it's the event "copy" as in my example. You need an eventHandler and then the event is passed as argument to your handler.

Hope that helps.

On Thu, Oct 20, 2022 at 7:47 PM Pramod Patil <patil.p...@gmail.com> wrote:
Thanks again,
In below method - how to get "event " ?  so as to use event.clipboard.setData("text/plain", data), if I can get event handle then I may achieve desired results. 
public static native String setClipboardData(String data)/*-{

if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-

On Thu, Oct 20, 2022 at 5:17 PM Vassilis Virvilis <vas...@gmail.com> wrote:
I believe I did

It's this snippet for copy

event.clipboardData.setData("text/plain", data);

On Thu, Oct 20, 2022 at 1:52 PM Pramod Patil <patil.p...@gmail.com> wrote:
Thank you again, I understand security implications but objective is to make it work for Edge, I have control over native methods, getClipBoardata and setClipboardData(String data)  which are native methods in java. The code which I have pasted above is working fine with IE browser, but not with modern browsers. So can you help me with the code/pointers which can replace above code and work for Edge,Chrome. Thanks.

On Thursday, 20 October 2022 at 14:52:22 UTC+5:30 vas...@gmail.com wrote:
Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vas...@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f7386ec6-494b-4754-94dd-cbfbb42e8f22n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzshqm%2Bs-SUOZuuqSSH-2AR_T9nmcZ9O%2BK7Lcxoy-_R-A%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/ed7e91b1-8612-4d5a-a096-1a420191802an%40googlegroups.com.

Saturday, October 22, 2022

Re: Modern browsers support for Copyclipboard functionality

Well it's the event "copy" as in my example. You need an eventHandler and then the event is passed as argument to your handler.

Hope that helps.

On Thu, Oct 20, 2022 at 7:47 PM Pramod Patil <patil.pramod63@gmail.com> wrote:
Thanks again,
In below method - how to get "event " ?  so as to use event.clipboard.setData("text/plain", data), if I can get event handle then I may achieve desired results. 
public static native String setClipboardData(String data)/*-{

if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-

On Thu, Oct 20, 2022 at 5:17 PM Vassilis Virvilis <vasvir2@gmail.com> wrote:
I believe I did

It's this snippet for copy

event.clipboardData.setData("text/plain", data);

On Thu, Oct 20, 2022 at 1:52 PM Pramod Patil <patil.pramod63@gmail.com> wrote:
Thank you again, I understand security implications but objective is to make it work for Edge, I have control over native methods, getClipBoardata and setClipboardData(String data)  which are native methods in java. The code which I have pasted above is working fine with IE browser, but not with modern browsers. So can you help me with the code/pointers which can replace above code and work for Edge,Chrome. Thanks.

On Thursday, 20 October 2022 at 14:52:22 UTC+5:30 vas...@gmail.com wrote:
Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vas...@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f7386ec6-494b-4754-94dd-cbfbb42e8f22n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzshqm%2Bs-SUOZuuqSSH-2AR_T9nmcZ9O%2BK7Lcxoy-_R-A%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAAXS9-VcTJkn5um-JvGQDjptot2E271GQeUD0ReE6LbKLhF0AQ%40mail.gmail.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjExoU7w0L9mTxRrFCBJKZJ%3DdOLfmjrSC5qQj9scrbuxqgA%40mail.gmail.com.

Thursday, October 20, 2022

Re: Modern browsers support for Copyclipboard functionality

Thanks again,
In below method - how to get "event " ?  so as to use event.clipboard.setData("text/plain", data), if I can get event handle then I may achieve desired results. 
public static native String setClipboardData(String data)/*-{

if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-

On Thu, Oct 20, 2022 at 5:17 PM Vassilis Virvilis <vasvir2@gmail.com> wrote:
I believe I did

It's this snippet for copy

event.clipboardData.setData("text/plain", data);

On Thu, Oct 20, 2022 at 1:52 PM Pramod Patil <patil.pramod63@gmail.com> wrote:
Thank you again, I understand security implications but objective is to make it work for Edge, I have control over native methods, getClipBoardata and setClipboardData(String data)  which are native methods in java. The code which I have pasted above is working fine with IE browser, but not with modern browsers. So can you help me with the code/pointers which can replace above code and work for Edge,Chrome. Thanks.

On Thursday, 20 October 2022 at 14:52:22 UTC+5:30 vas...@gmail.com wrote:
Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vas...@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f7386ec6-494b-4754-94dd-cbfbb42e8f22n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzshqm%2Bs-SUOZuuqSSH-2AR_T9nmcZ9O%2BK7Lcxoy-_R-A%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAAXS9-VcTJkn5um-JvGQDjptot2E271GQeUD0ReE6LbKLhF0AQ%40mail.gmail.com.

Re: Modern browsers support for Copyclipboard functionality

I believe I did

It's this snippet for copy

event.clipboardData.setData("text/plain", data);

On Thu, Oct 20, 2022 at 1:52 PM Pramod Patil <patil.pramod63@gmail.com> wrote:
Thank you again, I understand security implications but objective is to make it work for Edge, I have control over native methods, getClipBoardata and setClipboardData(String data)  which are native methods in java. The code which I have pasted above is working fine with IE browser, but not with modern browsers. So can you help me with the code/pointers which can replace above code and work for Edge,Chrome. Thanks.

On Thursday, 20 October 2022 at 14:52:22 UTC+5:30 vas...@gmail.com wrote:
Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vas...@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f7386ec6-494b-4754-94dd-cbfbb42e8f22n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzshqm%2Bs-SUOZuuqSSH-2AR_T9nmcZ9O%2BK7Lcxoy-_R-A%40mail.gmail.com.

Re: Modern browsers support for Copyclipboard functionality

Thank you again, I understand security implications but objective is to make it work for Edge, I have control over native methods, getClipBoardata and setClipboardData(String data)  which are native methods in java. The code which I have pasted above is working fine with IE browser, but not with modern browsers. So can you help me with the code/pointers which can replace above code and work for Edge,Chrome. Thanks.

On Thursday, 20 October 2022 at 14:52:22 UTC+5:30 vas...@gmail.com wrote:
Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vas...@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.p...@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f7386ec6-494b-4754-94dd-cbfbb42e8f22n%40googlegroups.com.

Re: Can anyone help me to copy the text to clipboard in a simple way and which works on all browsers

Hi, Did you get solution for your problem?

On Monday, 21 March 2016 at 19:16:23 UTC+5:30 Dhinakar wrote:
Can anyone help me to copy the text to clipboard in a simple way and which works on all browsers especially on Safari, Chrome and IE and with out the need of flash or any other apps. Thanks in advance

        public static native void copyFrom(com.google.gwt.user.client.Element element) /*-{
  $wnd.window.clipboardData.setData('text', element.innerText);
}-*/;
public static native void pasteTo(com.google.gwt.user.client.Element element) /*-{
  $wnd.window.clipboardData.getData(element);
}-*/;
This code only works on IE and returns an exception on Chrome.

I need to process this event on a button click.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/84f249f5-e548-407e-bfde-cfd42b2f5cc4n%40googlegroups.com.

Re: Modern browsers support for Copyclipboard functionality

Well if I remember correctly it is not supposed to access the clipboard directly because that would be a huge security issue.

Consider the following scenario. You copy / paste your password for your bank somewhere. Then you go to a random webpage. If the javascript of this webpage that runs on your computer/browser could access (getClipboardData()) your clipboard your bank password would be compromised.

So you can only access the clipboard from inside an event handler that handles the "copy" event aka Ctrl+C.

The necessary details to access the data differ from IE and so I have posted examples.

I do not know why your code does not compile. I think native methods are not checked so they tend to give NULL errors during runtime. If that is your case then caniuse is your friend.

    Vassilis



On Thu, Oct 20, 2022 at 11:12 AM Pramod Patil <patil.pramod63@gmail.com> wrote:
Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vasvir2@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.pramod63@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAAXS9-UatQ84dXiZeD7Q0TSXA9HT56UGZQLCzvZ4fFqbEoF23A%40mail.gmail.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjExN_EJtSr_prc-r4P0XFpietD4HVwU0ErW0e%2By5FU%3D3Wg%40mail.gmail.com.

Re: Modern browsers support for Copyclipboard functionality

Hi Thanks for your response, 
on both front at GWT and Javascript  I am at beginners level, will it be possible to have modification in below function, which will support copyclipboard functionality with Microsoft Edge. I tried navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}

On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <vasvir2@gmail.com> wrote:
For non IE browsers I have this:

            // attach event listeners
            // copy - cut - paste handlers
            ((Element) Js.cast(getElement())).addEventListener("copy", copy_li);
            ((Element) Js.cast(getElement())).addEventListener("cut", cut_li);
            ((Element) Js.cast(getElement())).addEventListener("paste", paste_li);


where (Element) is elemental2.dom.Element

copy_li is something like this:

        final elemental2.dom.EventListener copy_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                copy(event);
            }
        };

where ClipboardEvent is elemental2.dom.ClipboardEvent

I need a copy function because I reuse it in the "Cut" functionality also.

and finally copy is something like this

   private void copy(ClipboardEvent event) {
        if (!hasData()) {  // <-- hasData() is your application specific function
            return;
        }

        // do application stuff get/iterate and finally get the data in a String form somehow...
        final String data = getData();  // application specific

        event.clipboardData.setData("text/plain", data);
        event.preventDefault();
    }

Similarly the paste evenListener:

        final elemental2.dom.EventListener paste_li = new elemental2.dom.EventListener() {
            @Override
            public void handleEvent(elemental2.dom.Event evt) {
                final ClipboardEvent event = Js.cast(evt);
                final String data = event.clipboardData.getData("text/plain")
                event.preventDefault();
                if (data == null)
                    return;

                // now you need somehow to propagate data to the interesting parties (methods, classes etc)
                // I am using the EventBus from GWT
                getEventBus().fireEvent(new PasteEvent(data));
            }
        };

Hope that helps

     Vassilis

On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <patil.pramod63@gmail.com> wrote:
Hi All,
In our GWT application we are using Java native method call for Copytoclipboard functionality. Please refer below code

public static native String getClipboardData()/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.getData('Text');
}
}
}-*/ 
public static native String setClipboardData(String data)/*-{
if($wnd.clipboardData && clipboardData.setData){
return $wnd.clipboardData.setData('Text',Data);
}
}
}-*/ 

So above code is working fine with IE browser but not working with modern browser. I know this is not GWT specific question, but I don't have much knowledge with Javascript, so anyone who knows Javascript, please help here.



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com.


--
Thanks and regards,
 Pramod Patil
 Contact +91-8975432800

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAAXS9-UatQ84dXiZeD7Q0TSXA9HT56UGZQLCzvZ4fFqbEoF23A%40mail.gmail.com.