JList data binding not working. [message #717333] |
Sat, 20 August 2011 02:30  |
Eclipse User |
|
|
|
so I created a JList component and a simple "add user" button and the username text input field.
I right click on JList and add self to Users.people and detail binding on Person.username;
public class Users {
public List<Person> people = new ArrayList<Person>();
public List<Person> getPeople() {
return people;
}
public void addPerson(Person person) {
people.add(person);
}
}
public class Person {
public String username ="";
public String location ="";
public Person(String name){
username = name;
}
public String getUsername() {
return username;
}
}
so on "add user" button click:
actionPerformed(){
users.addPerson(new Person("Jim"));
}
The code runs, and I click on the "Add user" button. I output the size() of people array, and it's increasing, but nothing is being updated on the JList component. I expected it to fill up with "Jim"s but it didn't happen.
I spent days on this and can't find out what is being wrong or what I am overlooking.
|
|
|
Re: JList data binding not working. [message #717337 is a reply to message #717333] |
Sat, 20 August 2011 03:04   |
Eclipse User |
|
|
|
Looks to me like your addPerson() method isn't firing any property change event. Unless you do that, the JList and the Data Binding framework itself have no idea that you have added anything. I would recommend reviewing the JFace Data Binding docs as the framework imposes specific requirements on any domain objects that you use.
In general, questions about how to use the JFace Data Binding framework should be posted to the Eclipse JFace Forum.
|
|
|
Re: JList data binding not working. [message #717365 is a reply to message #717337] |
Sat, 20 August 2011 06:52   |
Eclipse User |
|
|
|
Eric Clayberg wrote on Fri, 19 August 2011 23:04Looks to me like your addPerson() method isn't firing any property change event. Unless you do that, the JList and the Data Binding framework itself have no idea that you have added anything. I would recommend reviewing the JFace Data Binding docs as the framework imposes specific requirements on any domain objects that you use.
In general, questions about how to use the JFace Data Binding framework should be posted to the Eclipse JFace Forum.[/url]
Hello Eric,
I just began using Window Builder, followed the data binding tutorial for Swing.
Do I need to manually write the property change events? I thought WindowBuilder would generate that automatically.....
Where is the package? Can I just follow what the tutorial is doing? I will try that anyhow.
Now, I have no clue what JFace is....should I be using that instead of Swing? I thought Swing was the way to go if you wanted it to work without extra library packaging. But I am actually deploying via .jnlp file.
When I public class Person extends ModelObject on Person class, it will not detect the package. Eclipse is telling me to create ModelObject....I am following the guide here
wiki.eclipse.org/JFace_Data_Binding/Tutorial
Thank you for your prompt reply.
Joe.
[Updated on: Sat, 20 August 2011 07:01] by Moderator Report message to a moderator
|
|
|
Re: JList data binding not working. [message #717412 is a reply to message #717365] |
Sat, 20 August 2011 13:24   |
Eclipse User |
|
|
|
If you are doing Swing Data Binding, the same advice applies...you need to review the requirements of the Swing Data Binding Framework with respect to domain objects (they are basically the same as for JFace Data Binding). This forum is not the place to learn that framework. WindowBuilder assumes that you are already familiar with it.
And, no, it is not WindowBuilder's job to add code to trigger property change events in your domain objects. WindowBuilder is responsible for generating the data binding code in your UI class. Your domain classes are your responsibility. You can certainly use the code provided with the tutorial as that is complete and includes a complete set of domain objects (including Person).
|
|
|
Re: JList data binding not working. [message #775151 is a reply to message #717412] |
Thu, 05 January 2012 13:08   |
Eclipse User |
|
|
|
This is related to Swing Binding example,
I did the binding between text fields and table, but when I select a row on the table, the text fields are not not getting updated, Do I need to add any code for the source ?? If yes, Please let me know where to add that.
I am trying to develop the same application that was given in SwingBinding tutorial,
I spent 3 days on this, till now I didn't get any answer to it.
Please help me on this.
Thanks in advance.
Attachment: Frst.png
(Size: 510.67KB, Downloaded 349 times)
Attachment: second.jpg
(Size: 183.88KB, Downloaded 330 times)
|
|
|
Re: JList data binding not working. [message #775186 is a reply to message #775151] |
Thu, 05 January 2012 14:22   |
Eclipse User |
|
|
|
You have not provided any example code, so how could I possibly know what code you might be missing?
Full source code is provided with the Swing Data Binding example, so why not just take a look at that?
|
|
|
Re: JList data binding not working. [message #775504 is a reply to message #775186] |
Fri, 06 January 2012 05:55   |
Eclipse User |
|
|
|
I had seen the source code, the problem is there is no documentation for the code to understand why he wrote AbstractModelObject class, And I don't know about firepropertychange method. To bind table's parameter to textfield do I need to write this method ??
However as per my knowledge, when the table fields table fields are getting populated the binded textfields should also get populated as I did binding through binding tab. Am I wrong ?? Please let me know.
|
|
|
Re: JList data binding not working. [message #775699 is a reply to message #775504] |
Fri, 06 January 2012 14:42  |
Eclipse User |
|
|
|
I can't tell you what is wrong with your code without actually seeing it. From your comments, all I can do is guess that your domain objects don't meet the requirements of the Swing Data Binding Framework (JSR 295). Your domain objects are your responsibility while WindowBuilder is only responsible for generating the data binding code in your UI class. If you aren't understanding the domain objects provided with the tutorial, you should review the requirements of the Swing Data Binding Framework with respect to domain objects. This forum is not the place to learn that framework or ask general questions about it. WindowBuilder assumes that you are already familiar with it, so one suggestion is to build a small example by hand so that you understand it from start to finish. You can certainly start with the code provided in the tutorial as that is complete and includes a complete set of domain objects (including an AbstractModelObject you can use as the parent for your domain object classes).
|
|
|
Powered by
FUDForum. Page generated in 0.04501 seconds