JSF F: selectItem in h: selectManyCheckbox non funziona nel sostenere di fagioli, ma è visualizzato correttamente in h: dataTable

StackOverflow https://stackoverflow.com/questions/676743

Domanda

Il problema si verifica con questo codice:

<h:form>
    <rich:panel>
        <f:facet name="header">
            <h:selectManyCheckbox title="Select which types of requests you want to see"
                                  onchange="submit();" value="#{filterListener.chosenFilters}"
                                  id="selectBoxContainer" >
                <f:selectItem id="approvedByITS" itemLabel="Approved by ITS" itemValue="approvedByITS"  />
                <f:selectItem id="approvedByPO" itemLabel="Approved by Process Owner" itemValue="approvedByPO"   />
                <f:selectItem id="dob" itemLabel="Date" itemValue="dob"   />
                <f:selectItem id="externalAssignedTo" itemLabel="External assigned" itemValue="externalAssignedTo"  />
                <f:selectItem id="internalAssignedTo" itemLabel="Internal assigned" itemValue="internalAssignedTo"   />
                <f:selectItem id="ITSapprovedBy" itemLabel="ITS approved by" itemValue="ITSapprovedBy"  />
                <f:selectItem id="severity" itemLabel="Severity" itemValue="severity"  />
                <f:selectItem id="status" itemLabel="status" itemValue="status" />
                <f:valueChangeListener type="no.ngt.tech.rt2.listeners.requestFilterListener" />
            </h:selectManyCheckbox>
        </f:facet>

        <h:dataTable value="#{filterListener.chosenFilters}" var="selects" >
            <h:column>
                <h:outputText value="#{selects}" />
            </h:column>
        </h:dataTable>
        <br />
        <h:messages />

    </rich:panel>
</h:form>

Come si può vedere ho la value = "# {} filterListener.chosenFilters". Il valore del dataTable è anche lo stesso, quindi, quando si seleziona una delle SelectItem del dataTable presenta un elemento aggiunto o rimosso da esso (questo funziona). Nel mio backing bean Ho il seguente codice:

public class requestFilterListener implements ValueChangeListener {

    private List<String> chosenFilters;

    public requestFilterListener() {
    }

    public void processValueChange(ValueChangeEvent event) {
        System.out.println("processValueChange called");
        if (chosenFilters != null) {
            System.out.println(chosenFilters.size());
        }
    }

    public List<String> getChosenFilters() {
        return chosenFilters;
    }

    public void setChosenFilters(List<String> chosenFilters) {
        this.chosenFilters = chosenFilters;
    }

Ogni volta che clicco una delle caselle di controllo, viene aggiunta una colonna / rimosso con i dati corretti, nella mia console ottengo il "processValueChange chiamato" messaggio come uscita I nel metodo processValueChange, ma durante questa volta chosenFilters è sempre nullo, e se l'espressione non viene mai eseguito. Come mai? Questo è un session bean, e mi sono davvero non capisco il motivo per cui la mia lista cant essere utilizzato all'interno del backing bean, ma è usato senza problemi dal mio dataTable.

Grazie per il vostro tempo a guardare in questo.

È stato utile?

Soluzione

Il problema è probabilmente su questo tag:

<f:valueChangeListener type="no.ngt.tech.rt2.listeners.requestFilterListener" />

si comunica al f: valueChangeListener per creare una nuova istanza di requestFilterListener , invece di legare a quello specificato dalla configurazione bean gestito. Utilizzare il legame di attributo per l'associazione a # {filterListener} .

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top