--
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/-/bVE-agIAe-kJ.
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.
We hit the problem while creating our libraries.Extending JavaScriptObject directly is not good because it restricts what your possibilities.So we used composition instead, giving us more power.So instead ofpublic class MyClass extends JavaScriptObject{protected MyClass(){}}maybe you should consider something likepublic class MyClass{protected JavaScriptObject nativePeer;public MyClass(){nativePeer = createNativeJsoObject();}}The the public API of MyClass will delegate to the JSO.this will give you a bit more work but the API will me more flexible and your users will thank you :).
--
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/-/GAl_l1hUSQkJ.
>> 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 post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsub...@googlegroups.com.
YUI().use('button', function (Y) {
var button1 = new Y.Button({
label: 'a simple button'
}).render(parent);
button1.on("click", function(e){
alert("clicked at x = "+e.clientX);
})
});
Java YUI Equivalent in YUIGWT:
YUI.Use(new String[]{"button"}, new YUICallback() {
@Override
public void ready(YuiContext Y) {
Widget button1 = Y.newButton(
ButtonConfig.create().label("a simple button")
).render(parent);
button1.on("click", new NodeEventCallback() {
@Override
public void call(YuiEvent e) {
Window.alert("button pressed at x ="+e.clientX());
}
});
}
});
YUI.Use(new String[]{"button"}, new YUICallback() {
@Override
public void ready(YuiContext Y) {
Widget button1 = Y.newButton(
ButtonConfig.create().label("a simple button")
).render(parent);
button1.on("click", new NodeEventCallback() {
@Override
public void call(YuiEvent e) {
Window.alert("button pressed at x ="+e.clientX());
}
});
}
}); --
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/-/CXgAf0nZgSsJ.
The main Question is do you want YUI users to use Java or do you want to bring Java Devs to YUI ?I think you will get more traction by choosing the latter.
While a zero overhead API gives you the ability to easely write YUI code in java soon you will get users request like "Why cant i extends class X to add my own functions". Overlay types dont give you.We had this problems while implementing our libraries. We started first with 1:1 match of the JS API. Until our users start complaining about the API not beeing extensible. What you would expect when using an OO language like Java.
.... code....
That looks pretty cool. Now what if i want to extend Button and override some methods ?
Nino; I very like your thoughts and I agree with them. My reply between lines:
On Monday, September 10, 2012 5:05:25 PM UTC-3, nino wrote:The main Question is do you want YUI users to use Java or do you want to bring Java Devs to YUI ?I think you will get more traction by choosing the latter.
I also thought of that. I started learning how to port JavaScript libraries to GWT with my project http://code.google.com/p/raphael4gwt/ , a vector drawing library. As such, performance was a requirement, and then a Java API using GWT overlays directly was a requirement. But now for YUIGWT I wonder if that is true. Some notes:
1) overlay types CAN be inherited, but I agre that is very unconfortable for end GWT/Java users to do this... this is a very important "issue" in my project I think...
2) I very liked your question: "do you want YUI users to use Java or do you want to bring Java Devs to YUI ? " and it is making me reflect a lot. thanks.
While a zero overhead API gives you the ability to easely write YUI code in java soon you will get users request like "Why cant i extends class X to add my own functions". Overlay types dont give you.We had this problems while implementing our libraries. We started first with 1:1 match of the JS API. Until our users start complaining about the API not beeing extensible. What you would expect when using an OO language like Java.
Well, but tell me, do you write a second Java API, with real java classes that wrapp the Js objects ? and if so, do you use your previous 1:1 Java API for writing the this second more-java-confortable API? (I sould do that) and if so, do you use some Java code generator tool for artificial create the second Java API form the first 1:1 - overlays Java API ? can this be mechanized at all?
I'm questioning my self these kind of things for my project YUIGWT. YUI has a very big API, and unlike other libraries it contains utils for doing a more structured - object oriented javascript like classes, inheritance, plugins, attributes, events, etc. All artificially and fully extensible from javascript. The big desicion I have to make is this: "the objective of YUIGWT is to bring the YUI public concrete utilities to the GWT user, like a datatable, a button, etc ". But not to support those utilities enhancing the Javascript language.
.... code....
That looks pretty cool. Now what if i want to extend Button and override some methods ?
This is the perfect example, thank you!
Currently in my YUIGWT project (very new project) I do not contemplate that. What I'm thinking can be a perfect solution for me is : to create a second Button class, that wraps all current Button methods, as you suggested in your first post. The user could override some methods, and it is his responsability to call super.(). In the constructor, they must pass me the Y object that is responsible for instantiate the "real - native" Button .
Well, a pleasure to read you, if you have any other suggestions or tips about this subject are most welcome.
--
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/-/a-U28tdEaPAJ.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.
public class ProxyObject {
protected JavaScriptObject jsObj;
protected ProxyObject() {
}
}
The we do
public class View extends ProxyObject {
public View() {
createPeer();
}
View(JavaScriptObject obj) {
jsObj = obj;
}
private List<View> children = new ArrayList<View>();
@Override
public native Point getAnchorPoint() /*-{
var jso = this.@com.emitrom.gwt4.ti.mobile.client.core.ProxyObject::getJsObj()();
var obj = jso.anchorPoint;
var toReturn = @com.emitrom.gwt4.ti.mobile.client.ui.Point::new(Lcom/google/gwt/core/client/JavaScriptObject;)(obj);
return toReturn;
}-*/;
}
We create the wrapped JSO in the constructor and delegation is done using JSNI which save the need of the explicit cast.
To call methods on the wrapped JSO we use JSNI
Hope this could help
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/pAMwpwmGowMJ.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
2012/9/13 Sebastián Gurin <sebast...@gmail.com>
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/MNdypItk-VUJ.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.