使用inputText构造dataTable

时间:2012-10-10 15:37:33

标签: datatable primefaces

我有以下数据表:

<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>

和commandButton

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

identifierBean如下:

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;
}

}

该表有一行(这意味着identifierBean在标识符列表中有一个元素),但是当我尝试在saveIdentifiers方法中使用标识符列表时,它是空的。 有帮助吗? 非常感谢!!!

1 个答案:

答案 0 :(得分:0)

RequestScope太狭隘了。请参阅BalusC's description of scopes