Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery and jqueryui #76

Closed
ssatguru opened this issue Feb 21, 2016 · 14 comments
Closed

jquery and jqueryui #76

ssatguru opened this issue Feb 21, 2016 · 14 comments
Labels
Milestone

Comments

@ssatguru
Copy link

Trying to use the jquery and jqueryui candy

I haven;t been able to get it working.

Something like
$("#myMenu).menu();
does not work

Might have something to do with the way JQuery class has been defined

In JQuery candy, class "JQuery" has been defined as
def.jquery.JQuery

in JQueryUi candy it has been defined as
def,jqueryui,JQuery

@lgrignon
Copy link
Collaborator

Hello ssatguru, I will take a look at it. Do you use the Eclipse plugin or the maven plugin?

Thanks for your help

@lgrignon
Copy link
Collaborator

I finally fixed this issue, see PR #77

I installed my branch of jsweet locally and the following example runs without any problem :)
https://github.com/lgrignon/jsweet-jqueryui-example

Now we juste have to wait for @renaudpawlak to integrate the PR and deploy the Jar on maven ;)

Regards.

@ssatguru
Copy link
Author

Hi Igrignon,

Thanks for fixing this. I will check it out when it is available.
As a workaround I am doing the following now :)

        Object obj = $("#myMenu");
        JQuery jq = (JQuery) obj;
        jq.menu();

As far as Eclipse or Maven Plugin , I normally use Maven Plugin.
I do use eclipse as my IDE though.

Thanks

@renaudpawlak renaudpawlak added this to the 1.1.0 milestone Feb 21, 2016
@renaudpawlak
Copy link
Contributor

Hi! I have merged the PR. Thanks a lot. Tell us if it works now.

@ssatguru
Copy link
Author

Is the fix available in the maven repo?

@renaudpawlak
Copy link
Contributor

Hi Satguru,

I think that we have not been clear enough about the issue. In theory, the candies are fine, so the fix was only in the transpiler (version 1.1.0-SNAPSHOT), not in the candies.

JSweet defines the notion of a mixin. Your case is typically a mixin. The class def,jqueryui,JQuery actually mixins to def.jquery.JQuery (see the annotation in the source code), which means that the transpiler processes the bytecode to mix together the two JQuery classes with a bytecode manipulation tool called Javassist (created by Chiba).

There was a bug in mixins in the case of JQuery plugins. In theory, it was fixed by Louis. That said, I am in vacation and did not have the occasion to actually test it. If you don't really have time to test it, just proceed with your workaround, and I will test it ASAP.

@ssatguru
Copy link
Author

1.1.0-SNAPSHOT did not work for me.
I also tested by building the transpiler myself but that didn't help either.
But that's fine.
The workaround is pretty straightforward.
So I will continue using that for now.
Apart from this issue both jquery and jqueryui are working out great :)

@lgrignon
Copy link
Collaborator

Thanks @renaudpawlak for the explanation.

@ssatguru

  1. Are you sure you forced the transpiler artifact to be updated?
    You could check the version and build time with verbose option enabled, search for
    INFO JSweetTranspiler:206 - creating transpiler version
    in your logs. Your build date should be something like today :)

  2. Are you sure your candies where properly cleaned?
    Indeed, candies are not reevaluated if neither the artifact list nor their versions change between two build. I recommand that you use mvn jsweet:clean before building.

Please tell us if the problem persists. It could reveal something wrong.
I hope it will work.

@ssatguru
Copy link
Author

Ok, I see what's happening.
The Transpiler does not complain.
It is the Eclipse Editor which complains.
If marks "$("#myMenu).menu();" in red with error message
"The method menu() is undefined for the type JQuery().
The Java compiler doesnot like it.

@renaudpawlak
Copy link
Contributor

I am still working on some side effects of this issue, but it actually should be already working for your case.

Since you are not using the Eclipse plugin (well, it is not that stable yet ;)), it means that you have to manually tell Eclipse where to find the processed mixins so that it can compile your project right. It is fairly easy to do.

  1. Add the .jsweet/candies/processed directory to you build path.
  2. In the "order and export" tab of the build path dialog, make sure that the .jsweet/candies/processed appears at the top of the list (or at least before the Maven dependencies)

This should solve your compilation problem in Eclipse (and it would be similar for other IDEs).

@renaudpawlak
Copy link
Contributor

To configure the build path: right-click on the project > Build path > Configure build path... > Libraries (tab) > Add class folder (button)

@ssatguru
Copy link
Author

Yes, that did the trick :)
I think we should be able to accomplish this with maven pom, using the maven , eclipse m2e, lifecycle-mapping artifact.
I will look into that and report if I find something.

@renaudpawlak
Copy link
Contributor

That would be a good trick indeed. Tell us if you find something. For information, I enhanced the documentation thanks to your feedback: https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#bridging-to-external-javascript-elements.

Thanks :D

@ssatguru
Copy link
Author

That's great. Documentation always welcome.
One correction might be required
Per document
"Note that ambient classes constructors cannot have a body."
But int the example you provided the constructor has a body.
Also I was able to transpile successfully with an empty constructor body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants