0

Refresh listbox after filtering

asked 2015-01-30 07:15:24 +0800

emreturka gravatar image emreturka
9 2

I have written a method for filtering my listbox.Method is executing but listbox is not refreshing.Here is the codes;

      <listbox id="kayitListBoxId"
        model="${win$composer.kayitModelList}" checkmark="true" mold="paging"
        pageSize="9">
        <auxhead>
            <auxheader colspan="3">
                <textbox id="filterName"  instant="true" width="100px"/>
            </auxheader>
        </auxhead>
        <listhead>
            <listheader width="32px" />
            <listheader label="Ad" align="center" sort="auto(ad)" />
            <listheader label="Soyad" align="center"
                sort="auto(soyad)" />
            <listheader label="E-Posta" align="center" width="190px"
                sort="auto(eposta)" />
            <listheader label="Doğum Tarihi" width="150px"
                align="center" sort="auto(dogumtarihi)" />
            <listheader label="Cinsiyet" align="center"
                sort="auto(cinsiyet)" />
            <listheader label="Tahsil" align="center"
                sort="auto(tahsil)" />
        </listhead>
        <template name="model">
            <listitem>
                <listcell />
                <listcell label="${each.ad}" />
                <listcell label="${each.soyad}" />
                <listcell label="${each.eposta}" />
                <listcell label="${each.dogumtarihi}" />
                <listcell label="${each.cinsiyet}" />
                <listcell label="${each.tahsil}" />
            </listitem>
        </template>
    </listbox>

The method is here;

@Listen("onChange = #filterName")
@NotifyChange("kayitModelList")
public void changeFilter() {
    filtervalue = new KayitParam(filterName.getValue(), null,
            null, null, null, null);
    List kayitList1 = getFilterKayitlar(filtervalue);
    kayitModelList = new ListModelList<KayitParam>(kayitList1);
}

public List<KayitParam> getFilterKayitlar(KayitParam filtervalue) {
    List<KayitParam> kayitListFilter = new ArrayList<KayitParam>();
    String ad = null;
    String soyad = null;
    String eposta = null;
    String dogumtarihi = null;
    String cinsiyet = null;
    String tahsil = null;

    if (filtervalue != null && filtervalue.getAd() != null) {
        ad = filtervalue.getAd().toLowerCase();
    }
    if (filtervalue != null && filtervalue.getSoyad() != null) {
        soyad = filtervalue.getSoyad().toLowerCase();
    }
    if (filtervalue != null && filtervalue.getEposta() != null) {
        eposta = filtervalue.getEposta().toLowerCase();
    }
    if (filtervalue != null && filtervalue.getDogumtarihi() != null) {
        dogumtarihi = filtervalue.getDogumtarihi().toLowerCase();
    }
    if (filtervalue != null && filtervalue.getCinsiyet() != null) {
        cinsiyet = filtervalue.getCinsiyet().toLowerCase();
    }
    if (filtervalue != null && filtervalue.getTahsil() != null) {
        tahsil = filtervalue.getTahsil().toLowerCase();
    }

    for (Iterator<KayitParam> i = ((List<KayitParam>) kayitModelList)
            .iterator(); i.hasNext();) {
        KayitParam tmp = i.next();
        if (tmp.getAd().toLowerCase().contains(ad) && !ad.trim().isEmpty()) {
            kayitListFilter.add(tmp);
        }
    }
    if (kayitListFilter.size() > 0)
        return kayitListFilter;
    else
        return kayitList;

}

Is there any simple way to refresh listbox like in PrimeFaces.

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-01-30 07:53:23 +0800

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

Like so many people you are mixing MVC and MVVM.
@NotifyChange is an annotation ment for MVVM and not MVC.

What you have to do :

@Listen("onChange = #filterName")
public void changeFilter() {
    filtervalue = new KayitParam(filterName.getValue(), null,
            null, null, null, null);
    List kayitList1 = getFilterKayitlar(filtervalue);
    kayitModelList.clear();
    kayitModelList.addAll(kayitList1);
}
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: 2015-01-30 07:15:24 +0800

Seen: 34 times

Last updated: Jan 30 '15

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