Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:54:07+00:00 2026-06-12T09:54:07+00:00

I got a question when trying to wrap some Javascript APIs with JSNI of

  • 0

I got a question when trying to wrap some Javascript APIs with JSNI of Google Web Toolkit. The javascript API is provided by Parse.com, a cloud based server. My code is like this:

public class MMParseComm {

  private MMProject project = new MMProject();//MMProject has a member: String projectName.

  private String _projectName;

  private native void _retrieveCurrentProject_step1(int projectId) /*-{
    var ProjectList = $wnd.Parse.Object.extend("ProjectList");
    var query = new $wnd.Parse.Query(ProjectList);
    query.equalTo("projectId", projectId);
    query.find({
        success: function(results) {
            //Questions here: In this function, I can access "_projectName" by 
            //this.@net.myname.myproject.myapi.client.MMParseComm::_projectName, 
            //but cannot access "project.projectName" using the same syntax.
            //Also, I have searched around but cannot find a way 
            //that can write out a JSON data retrieved in "results" 
            //as a JSONObject in Java.
        },
        error: function(error) {
                $wnd.alert("Error");
        }
    });
  }-*/;
}

As shown on the code above, the questions are in the commented part of the code.
I’m not sure how can I write a string in array results out into project.projectName? Also, how can I wrap a JSON data retrieved from results in javascript to be a JSONObject in Java?

Thanks in advance!

Weibin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:54:08+00:00Added an answer on June 12, 2026 at 9:54 am

    I don’t think the JSNI external call syntax supports chain invocation which is why you can’t access project.projectName.

    I assume you have a external JavaScript prototype of type Project. You would be better off here creating a overlay type than using the JSONObject API to parse it – it’s more efficient and simpler to work with. I’ll get you started..

    public class MMProject extends JavaScriptObject
    {
        protected MMProject () { }
    
        public final native String getProjectId() /*-{
            return this.projectId;
        }-*/; 
    }
    

    Then utilize the wrapper with your success callback.

    I suspect that results is probably an array type so your implementation might look like this:

    public class MMParseComm
    {
        private JsArray<MMProject> projects = null;
    
        private native void _retrieveCurrentProject_step1(int projectId) /*-{
            var ProjectList = $wnd.Parse.Object.extend("ProjectList");
            var query = new $wnd.Parse.Query(ProjectList);
            query.equalTo("projectId", projectId);
            query.find({
                success: function(results) {
                    this.@net.myname.myproject.myapi.client.MMParseComm::projects = results;
                },
                error: function(error) {
                    $wnd.alert("Error");
                }
            });
        }-*/;
    }
    

    Without knowing the specifics of your object model this is the best I can advise you. If you need further clarity I can assist you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: I'm trying out to convert this here: http://support.microsoft.com/kb/828736 to VB.net I got it
I've got a newbie question. I'm trying to parse a xml message with pattern
I'm here agan. I got another question about google maps in android. I'm trying
Got a question, I'm trying to return to a previous view and share some
Got a question for you all! I'm trying to make a navigation system for
I asked this question on the SCB forum but got no answer I'm trying
Got a question for some jQuery wizard who might stumble upon this. When I
Got a question regarding best practices for doing parallel web service calls, in a
Got a question for you javascript gurus out there. I'm creating a sidebar tool
Probably a stupid question but I'm still trying to wrap my head around nHibernate.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.