0
votes

I have the following dataTable:

<p:dataTable var="indentifier" value="#{identifierBean.identifiers}">
        <p:column>
            <f:facet name="header">
                <h:outputText value="#{indentifier.key}" />
            </f:facet>
            <h:outputText value="#{indentifier.key}" />
            <p:inputText id="userValue" required="true" value="#{identifier.userValue}">
            </p:inputText>
        </p:column>
    </p:dataTable>

and the commandButton

    <p:commandButton            
        value="Search" ajax="false" action="#{identifierBean.saveIdentifiers}">     
    </p:commandButton>

The identifierBean is the following:

public class IdentifierBean {
private List<Identifier> identifiers;
private String country;
private List<Patient> patients;
public IdentifierBean() {
    identifiers = new ArrayList<Identifier>();

}

public IdentifierBean(List<Identifier> identifiers) {
    this.identifiers = identifiers;
}

public List<Identifier> getIdentifiers() {
    return identifiers;
}



public void saveIdentifiers(){
    try {           
        System.out.println("-"+this.identifiers.size()+"-");
    } catch (Exception ex) {
        //ex.printStackTrace();
    }

}

public void setIdentifiers(List<Identifier> identifiers) {
    this.identifiers = identifiers;

}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;     
    Vector vec = Service.getCountryIdsFromCS(this.country);
    for (int i = 0; i < vec.size(); i++) {
        Identifier id = new Identifier();
        id.setKey(Service.getPortalTranslation(
                ((SearchMask) vec.get(i)).getLabel(),
                LiferayUtils.getPortalLanguage()));
        id.setDomain("");
        this.identifiers.add(id);
    }
    System.out.println("-"+this.identifiers.size()+"-");
}

public List<Patient> getPatients() {
    return patients;
}

public void setPatients(List<Patient> patients) {
    this.patients = patients;
}

}

The table has one row (that means that identifierBean has one element in identifiers list), but when I try to use the identifiers list in the saveIdentifiers method it is empty. Any help? Thank you very much!!!

1
Can you post the code for IdentifierBean?WA Hunt
When the setCountry method is called, it creates one element in the list, but when I try to print the size of the list in saveIdentifiers it returns 0loubas
What's the scope of IdentifierBean?WA Hunt
I have these two annotations in my class ManagedBean RequestScopedloubas

1 Answers

0
votes

RequestScope is too narrow. See BalusC's description of scopes.