jsf - 在表单上提交表单数据为空 Jsf Primefaces
问题描述
我在提交表单时遇到问题,第一件事是没有 @this 我的 <p:commandButton> 没有调用我的 Managedbean。
当我添加 @this 时,它使用空表单数据调用我的托管 bean。
我无法弄清楚我在这里缺少什么。结构是
employee.xhtml:
<ui:composition template="employee/employeeTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:define name="mainContent">
<ui:include src="employee/employeeEditForm.xhtml"></ui:include>
</ui:define>
</ui:composition>
我的employeeTemplate.xhtml是:
<ui:composition template="../../templates/sidebarLayout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="sidebarContent">
<p:panel styleClass="panelContainer">
<p:panel styleClass="panelHeader"
header="#{o:translate('Employee List')}"></p:panel>
<p:panel styleClass="panelSpacing">
<h:form id="employeeListForm">
<ui:include src="employeeList.xhtml">
</ui:include>
<ui:include src="addNewEmployee.xhtml">
</ui:include>
</h:form>
</p:panel>
</p:panel>
</ui:define>
</ui:composition>
我的对话框在addNewEmployee.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:commandButton id="addEmployeeBtn"
value="#{o:translate('Add New Employee')}"
styleClass="btnAction"
style="float: right;"
oncomplete="PF('dlgExample').show();">
</p:commandButton>
<p:dialog id="dlgExample"
header="#{o:translate('Dlg Example')}"
widgetVar="dlgExample" dynamic="true" width="750" height="600" appendTo="@(body)">
<h:form id="dlgExampleForm">
<p:outputLabel for="val1"
value="#{o:translate('Employee Type')}:" />
<p:selectOneMenu value="#{myManagedBean.selectedEmp.type}" id="val1">
<f:selectItems value="#{myManagedBean.employeeTypes}" />
</p:selectOneMenu>
<p:commandButton id="cancelButton"
value="#{o:translate('Cancel')}" update=":mainContent,:msgs"
oncomplete="PF('dlgExample').hide();" />
<p:commandButton style="float: right;"
styleClass="pull_right btnAction"
actionListener="#{myManagedBean.saveEmployee}"
value="#{o:translate('Save')}" process="@this"
update=":mainPage,:msgs" >
<p:confirm header="Confirmation" message="Are you sure you want to Save?"
icon="ui-icon-alert" />
</p:commandButton>
</h:form>
</p:dialog>
</ui:composition>
任何帮助将不胜感激。
解决方案
推荐阅读
- excel - Excel 在验证列表中循环并导出为工作簿
- react-native - React Native 中的嵌套导航器导致 iOS 中的 View Controller 错误
- java - 是否可以在处理器中扫描类路径上的注释?
- reactjs - 打字稿不会因类型不匹配而失败
- spring-boot - 如何使用 spring data jpa 和 mongotemplate 了解 mongo 批量查询的执行统计信息?
- java - 通过 JDBC PrepareStatement 将参数传递给 CREATE LOGIN 类型的 SQL 语句
- python - 从电子邮件主题中提取日期戳
- python - 将多行元素文本转换为变量
- flutter - 如何显示图像,其文本填充到右侧填充线直到图像高度颤动
- javascript - 如何将 MongoDB 查询结果导出到文件