0

Displaying ArrayList of Google Datastore entities using Zk MVVM => bad output

asked 2018-03-19 23:49:11 +0800

cheikhhassancisse gravatar image cheikhhassancisse
11 1

updated 2018-03-21 15:08:17 +0800

cor3000 gravatar image cor3000
6280 2 7

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;
    }
}
delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted
1

answered 2018-03-22 17:42:42 +0800

cheikhhassancisse gravatar image cheikhhassancisse
11 1

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

link publish delete flag offensive edit
0

answered 2018-03-20 15:35:22 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-03-19 23:49:11 +0800

Seen: 11 times

Last updated: Mar 22 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More