【问题标题】:primefaces dataTable with inputText带有 inputText 的 primefaces 数据表
【发布时间】:2012-10-10 15:37:32
【问题描述】:

我有以下数据表:

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

和命令按钮

    <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 方法中使用标识符列表时,它是空的。 有什么帮助吗? 非常感谢!!!

【问题讨论】:

  • 能贴出IdentifierBean的代码吗?
  • 调用 setCountry 方法时,它会在列表中创建一个元素,但是当我尝试在 saveIdentifiers 中打印列表的大小时,它返回 0
  • IdentifierBean的作用域是什么?
  • 我的类 ManagedBean RequestScoped 中有这两个注释

标签: datatable primefaces


【解决方案1】:

RequestScope 太窄。见BalusC's description of scopes

【讨论】:

    猜你喜欢
    • 2013-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    相关资源
    最近更新 更多