显示jsf 2D表

时间:2018-10-17 12:35:50

标签: jsf

我想在我的.xhtml视图中显示一个2D数组,其中包含数据库列作为行,但是我无法获得2D数组

我的BD表

training | experience | motivation
NA       | B          | AT

我要显示如下数据表

                | evaluation | comment
-------------------------------------------
training        | A          | ...
-------------------------------------------------- -----
experience      | B          | ....

1 个答案:

答案 0 :(得分:0)

您必须像这样在托管bean中编写一些Java代码:

public class SomethingSomethingDTO {
    private final String subject;
    private final String evaluation;
    private final String comment;

    public SomethingSomethingDTO(final String subject, 
            final String evaluation, final String comment) {
        this.subject = subject;
        this.evaluation = evaluation;
        this.comment = comment;
    }

    public String getSubject() {
        return subject;
    }

    public String getEvaluation() {
        return evaluation;
    }

    public String getComment() {
        return comment;
    }

}

@PostConstruct // or some other event or command button action
public void initializeSomething() {
    somethings = new ArrayList<>();
    somethings.add(new SomethingSomethingDTO("training", "A", "..."));
    somethings.add(new SomethingSomethingDTO("experiance", "B", "..."));
}

private List<SomethingSomethingDTO> somethings;

public List<SomethingSomethingDTO> getSomethings() {
    return somethings;
}