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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:26:51+00:00 2026-05-14T14:26:51+00:00

Here’s a really simple class: static public class Bean1 { final private String name;

  • 0

Here’s a really simple class:

static public class Bean1
{
    final private String name;
    final private Bean1 parent;
    private int favoriteNumber;

    public String getName() { return this.name; }
    public Bean getParent() { return this.parent; }
    public int getFavoriteNumber() { return this.favoriteNumber; }
    public void setFavoriteNumber(int i) { this.favoriteNumber = i; }
}

What I would like to do is to bind some UI components to a BeanAdapter<Bean1> (see com.jgoodies.binding.beans.BeanAdapter) so that if the BeanAdapter points to Bean1 bean1, then I can display

bean1.name           (blank if null)
bean1.parent.name    (blank if null or if bean1.parent is null)
bean1.favoriteNumber 

The fields name and favoriteNumber are easy, but I’m confused about how to display the parent name. It looks like BeanAdapter only lets me bind to properties which exist directly in Bean1. But this is poor modularity and it forces me to add getter/setter functions every time I want to bind to a new aspect of the bean.

What I would like to do is write a helper class which knows how to access a bean, and am confused how to get it to work properly with Bean1 and BeanAdapter.

I’m sorry if this question is not more clear, I don’t know the vocabulary and am a little hazy on the concepts of binding.

  • 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-05-14T14:26:51+00:00Added an answer on May 14, 2026 at 2:26 pm

    The problem here is that binding works in both ways: from model to ui, and from ui to model.

    In your case, how would you deal with someone entering information for the first time in a textfield that’s binded to parent.name? Would you create a parent on the fly? Would you give an error?

    If you know what to do in that situation (e.g. create a parent with that name), you could use a com.jgoodies.binding.value.AbstractConverter to convert a Bean1 to a String:

    public class ParentNameConverter extends AbstractConverter {
    
        /**
         * Converts a value from the subject to the type or format used
         * by this converter.
         *
         * @param subjectValue  the subject's value
         * @return the converted value in the type or format used by this converter
         */
        public Object convertFromSubject(Object subjectValue) { ... }
    
    
        /**
         * Sets a new value on the subject, after converting to appropriate type 
         * or format
         *
         * @param newValue the ui component's value
         */
        public void setValue(Object newValue) { ... }
    }
    

    You can use this converter the same way you use a normal ValueModel:

        Bindings.bind(uifield,"value", 
                      new ParentNameConverter(beanAdapter.getValueModel("parent")));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
Here is a code of a simple editor. public class editor { public static
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here is my serializable abstract class namespace NEN_FS { [Serializable()] abstract public class NFS
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here is a code snippet I was working with: int *a; int p =

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.