I am using Netbeans to display a simple list,
it is working with "list of string",
but cannot success with "list of 'customer'"
I want to display the name, age of the customer
Here is my code:
public class Customer {
private String name;
public void setName(String name) { this.name = name; }
public String getName(){ return name;}
public Customer(String name){
this.name = name;
}
}
Customers object
public final SimpleListProperty<Customer> Customers = new SimpleListProperty<>(this, "Customers", FXCollections.observableArrayList());
Add a customer
Customer customer = new Customer('test');
Customers.getValue().add(customer);
Interface
<div class="row">
<ul class="col s12 collection" data-bind="foreach: Customers">
<li class="collection-item">
<span data-bind="text: $data.name"></span>
</li>
</ul>
</div>
I tried all the following
<span data-bind="text: $data"></span>
<span data-bind="text: $data.name"></span>
<span data-bind="text: $name"></span>
Nothing work, only empty list appears. But when I changed the list to (list of simple string) it works fine.
I also tried "private String name;" and "public String name;"
Any help, please