2

I'm trying to use the component selectManyButton for updating the datalist but it doesn't work. When I use selectOneButton, it works correctly.

The method I'm using to filter is an ElasticSearch query.

This code works without error:

<p:selectOneButton value="#{carEsBean.carEs.carburant}">

<f:selectItem itemLabel="Diesel" itemValue="Diesel" />
<f:selectItem itemLabel="Essence" itemValue="Essence" />
<f:selectItem itemLabel="Hybride" itemValue="Hybride" />
<p:ajax event="change" update="selectedCarsList" />
</p:selectOneButton>
<p:dataList value="#{carEsBean.carsQuery}" var="car" type="definition"
id="selectedCarsList" paginator="true" rows="10" >

and when I want to use this, it's not working:

<p:selectManyButton value="#{carEsBean.carEs.carburant}">

<f:selectItem itemLabel="Diesel" itemValue="Diesel" />
<f:selectItem itemLabel="Essence" itemValue="Essence" />
<f:selectItem itemLabel="Hybride" itemValue="Hybride" />
<p:ajax event="change" update="selectedCarsList" />
</p:selectManyButton>

The query I'm using is :

if (StringUtils.isNotBlank(carEs.getCarburant())) {
    if (query == null) {
        query = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("carburant", carEs.getCarburant()));
    } else {
        query = query.must(QueryBuilders.matchQuery("carburant", carEs.getCarburant()));
    }
}

I'm using primefaces 6.2, jsf 2.3 on Springboot

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Cesar
  • 83
  • 7
  • 1
    PrimeFaces (or even JSF) does not know **anything** of elasticsearch (nor about springboot). Try splitting down your problem. Create a unittest for the elastic search stuff or see if you can create a pure jsf example (without elastic search) that has 'the same problem'... Cannot be related to both ( – Kukeltje Dec 23 '19 at 10:30
  • 1
    i already make this test and they work correctly when i set one value , but can i set multiple value on the same Atrribut ?I think not, because the last value overwrites the previous ones – Cesar Dec 23 '19 at 10:39
  • 2
    Can you set multiple values in java to a `String`? Or do you use something different then? So effectively your question is purely a PrimeFaces `selectManyButton` one of which the PrimeFaces showcase has a working example.. https://www.primefaces.org/showcase/ui/input/manyButton.xhtml – Kukeltje Dec 23 '19 at 10:44
  • 1
    so for this i dont have to edit my querry ? because they work correctly with selectonebutton – Cesar Dec 23 '19 at 10:48
  • 1
    What exact type is `#{carEsBean.carEs.carburant}`? What does 'is not working' mean? – Selaron Dec 23 '19 at 10:56
  • That is a pure elasticsearch/java thing. If you can populate an array/list in with the `p:selectManyButton`, JSF and PrimeFaces have done their thing. Whether you need to change the query when switching from a String to an arrayt/list needs query changes is a pure elasticsearch thing. That is narrowing down problems (=approaching this as a developer) – Kukeltje Dec 23 '19 at 11:00
  • @Selaron yes my type is #{carEsBean.carEs.carburant} , they not work i mean the datalist was not uploaded – Cesar Dec 23 '19 at 11:04
  • `#{carEsBean.carEs.carburant` is not a **TYPE** it is a value expression in EL. String, ArrayList, Boolean those are types... And 'datalist not uploaded' is not a developer analysis. – Kukeltje Dec 23 '19 at 11:10
  • @Kukeltje i mean my Atrribut String type # {carEsBean.carEs.carburant}, and datalist not updated sorry – Cesar Dec 23 '19 at 11:12
  • How many instances of String can be stored in a property of type String by a select***Many***Button? – Selaron Dec 23 '19 at 11:15
  • @Selaron in my example,i need to set a 3 values in selectManyButton – Cesar Dec 23 '19 at 11:17
  • Do you get any error in logfiles? – Selaron Dec 23 '19 at 12:59
  • @Selaron no the console didn't show a error – Cesar Dec 23 '19 at 14:06
  • No error? Not even when running in JSF development mode? – Kukeltje Dec 23 '19 at 18:05
  • @Kukeltje yeah this not show a error , the only think changed is the datalist was not updated (but with selectOneButton is updated) – Cesar Dec 23 '19 at 19:34
  • Then check this: https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value. Most likely validation errors – Kukeltje Dec 23 '19 at 20:50

1 Answers1

1

the carEsBean.carEs.carburant this part should be a list of Strings List<String>, not a String to be able to use SelectManyButton

Check the showcase for more info https://www.primefaces.org/showcase/ui/input/manyButton.xhtml

Karim
  • 1,004
  • 8
  • 18