Primefaces选择列表目标始终为空

时间:2017-03-16 17:50:50

标签: jsf primefaces managed-bean picklist

我有一个选择列表组件,我有2个列表,第一个包含来自我的数据库的数据,第二个是DualListModel,我有一个按钮在选择列表之间传输,当我传输数据时没有任何事情发生在DualListModel保持为空。

这是我的JSF代码:

<p:pickList id="a" value="#{mbInstructor.model}" var="pickQ"
    itemLabel="#{pickQ}" itemValue="#{pickQ}">
     <o:converter converterId="omnifaces.ListConverter" list="#{mbInstructor.fullList}" />
    <p:ajax event="transfer" listener="#{mbInstructor.onTransfer}" update="msg" />
    <p:ajax event="select" listener="#{mbInstructor.onSelect}" update="msg" />
    <p:ajax event="unselect" listener="#{mbInstructor.onUnselect}" update="msg" />
    <p:ajax event="reorder" listener="#{mbInstructor.onReorder}" update="msg" />
</p:pickList>

这是托管bean中的方法:

private List<Question> fullList;
private DualListModel<Question> model;

public List<SemesterExamQuestionForm> getAllQuestionForms() {
    GeneralFacade facade = new GeneralFacade();
    return facade.lstSemesterExamQuestionForm(getCurrentStudySemesterExam());
}

public void onTransfer(TransferEvent event) {
    StringBuilder builder = new StringBuilder();
    for (Object item : event.getItems()) {
        ((Question) item).getQuestionTxt();
    }
    FacesMessage msg = new FacesMessage();
    msg.setSeverity(FacesMessage.SEVERITY_INFO);
    msg.setSummary("Items Transferred");
    msg.setDetail(builder.toString());
    FacesContext.getCurrentInstance().addMessage(null, msg);
}

 public List<Question> getFullList() {
        return fullList;
    }

    public DualListModel<Question> getModel() {
        if(model == null){
            model = new DualListModel<>();
        }
        fullList = getAllCourseQuestions();
         model = new DualListModel<>(new ArrayList<>(fullList),new ArrayList<Question>());
        return model;
    }

    public void setModel(DualListModel<Question> model) {
        this.model = model;
    }

0 个答案:

没有答案