0

我正在尝试填充 PrimeFaces 数据表:

<p:dataTable var = "milestoneIndentifier" id="milestoneTable" value = "#{milestoneIdentifierManager.milestoneIdentifiers}" paginator="true" >
    <p:column sortBy="name" headerText = "Milestone">
        <h:outputText value ="#{milestoneIndentifier.name}" /> 
    </p:column>

    <p:column sortBy="acroynm" headerText = "Acroynm">
        <h:outputText value ="#{milestoneIndentifier.acronym}" />
    </p:column>

    <p:column sortBy="phaseName" headerText = "Phase Name">
        <h:outputText value ="#{milestoneIndentifier.phaseName}" />
    </p:column>

    <p:column headerText = "Action">
    </p:column>
</p:dataTable>

我正在使用这个支持 bean:

//@ManagedBean
//@ViewScoped
@Named
@ViewAccessScoped
public class MilestoneIdentifierManager extends PageBean {    
    private static final long serialVersionUID = 1L;

    private List<MilestoneIdentifier> milestoneIdentifiers; 
    @Inject
    private MilestoneIdentifierBusinessBean milestoneIdentifierBusiness;

    public MilestoneIdentifierManager() {
    }
    /**
     * @param name
     * @param acronym
     * @param phaseName
     */
    public void addMilestoneIdentifier(String name, String acronym, String phaseName)  {
        try {
            milestoneIdentifierBusiness.addMilestoneIdentifier(name, acronym, phaseName);
        } catch (AllValidationException e) {
            // TODO Auto-generated catch block
        }
    }

    public List<MilestoneIdentifier> getMilestoneIdentifiers() {
        return milestoneIdentifiers;
    }

    @PostConstruct
    public void init() {
        milestoneIdentifiers = new ArrayList<MilestoneIdentifier>();
        milestoneIdentifiers.add(new MilestoneIdentifier("Milestone A", "MSA", "Milestone A1"));
    }
}

当我尝试这样做时,该表显示未找到任何记录。如果我注释掉:

@Named
@ViewAccessScoped

并取消注释:

@ManagedBean
@ViewScoped

然后表格将显示我在该init方法中创建的里程碑。

编辑:beans.xml在 WEB-INF 文件夹中有一个文件。

以下是代码导入:

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;

其中一些没有使用,我还没有清理代码。

4

0 回答 0