-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm stuck with a problem for a couple of days now and I would need some help please.
I'm using:
Google App Engine with Google Datastore Zk 8.5 with the MVVM design I’m having an issue trying to display an arrayList in a grid like this:
<grid model="@load(vm.clientResultList)" >
...
<template name="model">
<row >
<label value="@load(each.nom)"/>
</row>
</template>
</grid>
It will display for each row something in this format : com.mypackage.entity.Client@3c3f784e
My Entity:
@Entity
public class Client implements Serializable{
private static final long serialVersionUID = -6603526588403725762L;
@Id
private Long id;
@Index
private String nom;
private Sexe sexe;
private Contact contact;
@Load
private Ref<Mesures> mesures;
public Client() {
contact = new Contact();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public Sexe getSexe() {
return sexe;
}
public void setSexe(Sexe sexe) {
this.sexe = sexe;
}
public Contact getContact() {
return contact;
}
public void setContact(Contact contact) {
this.contact = contact;
}
public Mesures getMesures() {
return mesures.get();
}
public void setMesures(Mesures mesures) {
this.mesures = Ref.create(mesures);
}
}
My Service:
public List<client> getAll() { return ofy().consistency(Consistency.STRONG).load().type(Client.class).order("nom").list(); } My ViewModel:
public class RepertoireViewModel extends PageViewModel implements Serializable {
private static final long serialVersionUID = -3656947251943967000L;
private ListModelList<Client> clientListModel;
private List<Client> clients;
private List<Client> clientResultList;
private String rechercheNom ="";
private String rechercheTelephone="";
@Init
public void init() {
clients = ClientService.getInstance().getAll();
clientResultList = clients;
clientListModel = new ListModelList<>(clients);
menu.get(2).setActive(true);
}
@NotifyChange("clientResultList")
@Command
public void filter() {
clientResultList = clients.stream()
.filter(client -> (Strings.isBlank(rechercheNom) || (!Strings.isBlank(client.getNom()) && (client.getNom().toLowerCase().startsWith(rechercheNom.toLowerCase()) || client.getNom().toLowerCase().contains(" " + rechercheNom.toLowerCase()))))
&& (Strings.isBlank(rechercheTelephone) || (!Strings.isBlank(client.getContact().getTelephone()) && client.getContact().getTelephone().toLowerCase().startsWith(rechercheTelephone.toLowerCase()))))
.collect(Collectors.toList());
}
public ListModelList<Client> getClientListModel() {
return clientListModel;
}
public void setClientListModel(ListModelList<Client> clientListModel) {
this.clientListModel = clientListModel;
}
public List<Client> getClients() {
return clients;
}
public void setClients(List<Client> clients) {
this.clients = clients;
}
public List<Client> getClientResultList() {
return clientResultList;
}
public void setClientResultList(List<Client> clientResultList) {
this.clientResultList = clientResultList;
}
public String getRechercheNom() {
return rechercheNom;
}
public void setRechercheNom(String rechercheNom) {
this.rechercheNom = rechercheNom;
}
public String getRechercheTelephone() {
return rechercheTelephone;
}
public void setRechercheTelephone(String rechercheTelephone) {
this.rechercheTelephone = rechercheTelephone;
}
}
Chill suggested me to proceed by elimination to find the bug.
I found out that the problem was from the use of xmlns="native" xmlns:u="zul" xmlns:x="xhtml" in grid element. After I have removed it, it works fine.
Thank you Chill for the support.
Best regards
As your output show, ZK is calling the toString of the class Client.
Now for the fix, Possible it's copied code from somewhere and I suggest removing the line of the label and retype the line by yourself.
I had in the past also issue with copy/paste where everything looks correct but after doing a full retype it works.
If the problem still exist after this, please try to provide a fiddle example.
Chill.
Asked: 2018-03-19 23:49:11 +0800
Seen: 11 times
Last updated: Mar 22 '18
search button using validation
my login/index zul page is loading twice, where as i am only calling it once
Databinding and auto-complete on combobox
Multiple selection using ListModelMap<Key, Obj>
Notify Form of property change
How to handle lists and complex types with form?
multiple checkboxes in a row of listbox