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 1035579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:33:53+00:00 2026-05-16T14:33:53+00:00

Using GWT I have a Java class: public class Pojo { private String name;

  • 0

Using GWT I have a Java class:

public class Pojo {
  private String name;
  public String getName() { return name; }
  public void setName(String name) { this.name = name; }
}

The above class is shared between the client and server side code.

From the client code I would like to dynamically access the property. That is, I would like to write a method with the following signature:

public String getProperty(Object o, String propertyName)

Such that the following code would work:

Pojo pojo = new Pojo();
pojo.setName("Joe");
getProperty(pojo, "name");    // this should return "Joe"

Java reflection is obviously out. And I have tried the following JSNI method:

public static native String getProperty(Object o, String name) /*-{
  return o[name];
}-*/;

But that does not work.

The special syntax for accessing Java objects from JavaScript can’t be used either as I want this to be dynamic.

Any ideas on how I can do this?

For completeness, I will also want to be able to set a property dynamically as well.

EDIT: blwy10’s answer was a great tip to get me searching using “gwt reflection” instead of with terms like “dynamic property access”. This lead me to gwt-ent, which has an very elegant reflection solution. I am going to try this one, as it does not require a separate code generation step.

  • 1 1 Answer
  • 1 View
  • 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-05-16T14:33:54+00:00Added an answer on May 16, 2026 at 2:33 pm

    This doesn’t directly answer your question, but have you tried this?

    http://gwtreflection.sourceforge.net/

    Hope this helps!

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

Sidebar

Related Questions

I am using GWT/JAVA for development. I have following problem: I want to remove
I'am using GWT 2.4 with Hibernate and RequestFactory and I have queries like this
I have a HTML file that is linked to a Java class using the
I'm using the GWT's Constants Interface. i have an instance class class that create
i have a gwt project and using method GWT.create(SomeClass.class) throw exception. The exception is
I have a problem using Gin. Here is a simple example. @GinModules(AppModule.class) public interface
I am trying to implement a custom Java widget using GWT.This requires me to
I am trying to implement a custom Java widget using GWT.This requires me to
I'm using GWT 2.4 with Java & Mozilla FF 7. I have a TextBox
Using GWT , I have deployed my server into Tomcat . This works fine,

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.