使用弹出式面板创建新数据对象失败

时间:2012-05-08 13:25:58

标签: jsf-2 dialog richfaces

这里我再次讨论JSF问题,这次更多关于richfaces(4.2.1 final,JSF 2)。我有一个Eytended DataTable,想要添加新项目。有Journey - 对象列表,每个属性都有getter和setter。表格创建良好(列表中已有一些项目)。现在我点击“添加新项目”按钮:

<a4j:commandButton ajax="true" value="Neue Fahrt hinzufügen" 
   actionListener="'{editorBean.prepareCreateJourney}" render="createJourneyPopupForm"  
   oncomplete="#{rich:component('createJourneyPopup')}.show()" />

editorBean是 SessionScoped ,该方法被正确调用并创建一个名为Journey的{​​{1}}新对象。弹出窗口出现,应该允许我插入一些输入:

currentJourney

当我点击按钮时,方法<rich:popupPanel id="createJourneyPopup" modal="true"> <h:panelGrid id="createJourneyPopupForm" columns="3"> <h:outputLabel for="currentId" value="ID" /> <h:inputText id="currentId" value="#{editorBean.currentJourney.journeyNumber}" /> <rich:message for="currentId" /> [...and more...] </h:panelGrid> <a4j:commandButton value="Save" execute="currentId currentTrainType operator"> <f:ajax event="click" listener="#{editorBean.doCreateJourney}" render=":vmsEditorForm:resultTable" /> <rich:componentControl target="createJourneyPopup" operation="hide" /> </a4j:commandButton> <a4j:commandButton value="Abbrechen" onclick="#{rich:component('createJourneyPopup')}.hide();" /> </rich:popupPanel> 被调用,但doCreateJourney为空。它是创建后的默认currentJourney对象。没有调用setter,在输入字段上做一个提示。

我检查了两次名字,有所需对象的getter和setter。我试图改变范围,但没有效果。对象是相同的,在我创建的准备方法Journey中,在保存方法中它仍然是Journey(id=151)

这里发生了什么?我不能很难创建一些对话框来创建和编辑数据对象。感谢您的倾听和帮助!

1 个答案:

答案 0 :(得分:1)

您需要在表单中包含输入和commandButtons才能正确提交数据。

<rich:popupPanel id="createJourneyPopup" modal="true">
    <h:form>
        ... the content of your popupPanel
    </h:form>
</rich:popupPanel>

此致