On Sun, Dec 6, 2015 at 12:38 PM, Grzegorz Nowak <[email protected]>
wrote:

> I've been testing JsInterop for 'export java lib to js' use case and two
> things came up:
>
> 1. Annotations have RetentionPolicy.RUNTIME which means the library I'm
> exporting must have compile time dependency on gwt-user. There are 2 ways
> to fix it: change the retention to 'source' (AutoValue does that so there
> is no need for compile time dependency on AutoValue annotations) or
> generate separate artifact with jsinterop annotations only. I guess nicer
> way to accomplish this would be the former but I'm not sure if it's
> possible. For now I'm hiding* the annotations in my base artifact.
> 2. The library I'm trying to export has several overloads of constructors
> and methods. Write now for methods I'm using @JsMethod with name to
> describe parameter types. For constructors there are 2 approaches I took so
> far. One recommended is having one @JsConstructor which is called from
> other @JsIgnored. The other approach is hiding* all constructors and
> providing single @JsConstructor Constructor(Objects...) which detects
> number of params and their types and mimics overloaded constructors. This
> generates a WARN 'unusable-by-js' which can be suppressed. Accessing such
> constructor from js works but requires wrapping of params with array: 'new
> namespace.Constructor([param1, param2, paramN]);'
>

Support for varargs will be available before RC1, so the warning will be
gone and you won't need to create an array.


>
> * by hiding I mean automatic commenting out from base source so the
> alternative artifact doesn't have them.
>
> On Friday, December 4, 2015 at 8:49:02 PM UTC+1, Goktug Gokdogan wrote:
>>
>> That's not fixed yet. Should be fixed before RC1.
>>
>> On Fri, Dec 4, 2015 at 7:23 AM, Ümit Seren <[email protected]> wrote:
>>
>>> I guess I can't  put native JsInterop classes and interfaces in Java
>>> Collections ?
>>> I get a ClassCastException and I checked the official JsInterop
>>> documentation and couldn't find anthing about that ?
>>>
>>>
>>> On Saturday, November 21, 2015 at 5:02:13 AM UTC+1, Goktug Gokdogan
>>> wrote:
>>>>
>>>> dramaix@ is writing such a tool; that's how we are planning to
>>>> generate Elemental2.
>>>>
>>>> On Fri, Nov 20, 2015 at 7:56 PM, Slava Pankov <[email protected]> wrote:
>>>>
>>>>> And it would be nice to generate java code with new jsinterop
>>>>> annotations based on typescript d.ts files. Dart team is going to 
>>>>> implement
>>>>> such tool, probably it can be adopted for GWT as well:
>>>>> https://github.com/dart-lang/sdk/issues/24874
>>>>>
>>>>>
>>>>> On Thursday, November 19, 2015 at 10:15:35 AM UTC-8, Goktug Gokdogan
>>>>> wrote:
>>>>>>
>>>>>> Instead of JsArray, you can use Object[] or JsType[] (will be ready
>>>>>> by 2.8), instead of Integer, you can Double (in 2.8 release, Double 
>>>>>> exactly
>>>>>> maps to number in javascript).
>>>>>>
>>>>>> On Thu, Nov 19, 2015 at 6:22 AM, Paul Stockley <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> We wrote our own RPC mechanism that is based entirely on JSON,
>>>>>>> mainly for performance reasons on mobile. The client works with JS 
>>>>>>> Overlay
>>>>>>> representation of the server DTO objects. We have a tool that 
>>>>>>> automatically
>>>>>>> generates the JSO's, Looking at the new interop spec's it would be 
>>>>>>> really
>>>>>>> nice for the client and server to work with the same Java DTO objects. I
>>>>>>> can see how most of it could work with the new system. However, we 
>>>>>>> handle
>>>>>>> Java object representations for ints, doubles, booleans and also
>>>>>>> enumerations by generating code in the JSO's such as :
>>>>>>>
>>>>>>> public class ContractDoJSO extends PersistentDataObjectBaseJSO {
>>>>>>>
>>>>>>>    protected ContractDoJSO() {}
>>>>>>>
>>>>>>>
>>>>>>>     public final native ContractType getContractTypeDv() /*-{
>>>>>>>
>>>>>>>                return (this.contractTypeDv == null) ? null : 
>>>>>>> @com.ocs.shared.businesslogic.contract.ContractType::valueOf(Ljava/lang/String;)(this.contractTypeDv);
>>>>>>>
>>>>>>>     }-*/;
>>>>>>>
>>>>>>>
>>>>>>>     public final native void setContractTypeDv(ContractType v) /*-{ 
>>>>>>> this.contractTypeDv = (v == null) ? null : 
>>>>>>> [email protected]::name()(); }-*/;
>>>>>>>
>>>>>>>
>>>>>>> public final native java.lang.Integer getPreferredEmployerId() /*-{
>>>>>>>
>>>>>>>           return (this.preferredEmployerId == null) ? null : 
>>>>>>> @java.lang.Integer::valueOf(I)(this.preferredEmployerId);
>>>>>>>
>>>>>>> }-*/;
>>>>>>> public final native void setPreferredEmployerId(java.lang.Integer v) 
>>>>>>> /*-{
>>>>>>>
>>>>>>>      this.preferredEmployerId = (v == null) ? null : 
>>>>>>> [email protected]::intValue()();
>>>>>>>
>>>>>>> }-*/;
>>>>>>>
>>>>>>>
>>>>>>> In addition, if the DTO's contain arrays the client code has to
>>>>>>> access them using the JsArray class rather than the java collection 
>>>>>>> API. Do
>>>>>>> you think there is some way to have a single representation using the 
>>>>>>> new
>>>>>>> Interop mechanism?
>>>>>>>
>>>>>>>
>>>>>>> On Friday, October 23, 2015 at 3:13:55 AM UTC-4, Goktug Gokdogan
>>>>>>> wrote:
>>>>>>>
>>>>>>>> As we are getting close to 2.8 release I wrote a new document that
>>>>>>>> is concentrating on jsinterop features to be released in 2.8:
>>>>>>>>
>>>>>>>> https://docs.google.com/document/d/10fmlEYIHcyead_4R1S5wKGs1t2I7Fnp_PaNaa7XTEk0/edit#
>>>>>>>>
>>>>>>>> Please share your feedback.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Goktug
>>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "GWT Contributors" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to
>>>>>>> [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/1155c295-ecd1-4cdd-86a2-ddf3cffb618c%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/1155c295-ecd1-4cdd-86a2-ddf3cffb618c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "GWT Contributors" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to
>>>>> [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/44c98d88-8d67-4f17-b942-4f7202aeac3b%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/44c98d88-8d67-4f17-b942-4f7202aeac3b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "GWT Contributors" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected]
>>> .
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/cd869b99-e7c5-4caa-b105-ce1e533ff8a8%40googlegroups.com
>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/cd869b99-e7c5-4caa-b105-ce1e533ff8a8%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit-contributors/e63f9a61-7f1c-415e-8a5e-34b0f1b04679%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/e63f9a61-7f1c-415e-8a5e-34b0f1b04679%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA2xgdUpA_zP1MaOxG1k2NMwAuMETidBtc1MC%3DDhRo%2BK1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to