【发布时间】:2014-03-18 16:48:01
【问题描述】:
这是一个 Facelets 文件,用于获取名字和姓氏,然后将转到另一个 Facelets 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head><title>User Form</title></h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<p:graphicImage value="resources/images/image.jpg" width="50%"/>
<p:panelGrid columns="2" width="50%">
<f:facet name="header">
User Form
</f:facet>
<h:outputLabel for="firstname" value="Firstname: *"/>
<p:inputText id="firstname" value="" label="Firstname"/>
<h:outputLabel for="surname" value="Surname: *"/>
<p:inputText id="surname" value="" required="true" label="Surname"/>
<f:facet name="footer">
<p:commandButton type="button" value="Save" icon="ui-icon-check" style="margin:0" action="construction"/>
</f:facet>
</p:panelGrid>
</h:panelGrid>
</h:form>
</h:body>
</html>
当我按下“保存”按钮时,我预计会转到construction.xhtml,但没有任何反应。这是如何引起的,我该如何解决?
【问题讨论】:
-
这是实际代码吗?因为a)您使用
commandButton进行导航,b)您的inputTexts 没有支持值。也就是说,尝试使用h:commandButton或<p:commandButton ajax="false">,如here 所述。 -
感谢@mabi,当用户按住保存按钮时,
under Construction页面必须出现,因为正如你所说,它并不完整,它只是这个程序的开始 -
你到底为什么使用
type="button"? -
你确定吗?您熟悉基本的 HTML 和 HTTP 吗?您是否检查过 HTTP 流量监视器和服务器日志?当您删除它时,它应该开始触发 ajax 请求,而不是什么都不做。该 ajax 请求是否会反过来触发导航只是第二个问题。你有一个带有
required="true"的输入,没有任何面孔消息处理程序。 -
最后,一个例外!一个好的例外本身已经是一个完整的答案。但是,根据到目前为止发布的代码,我无法解释这一点;您没有运行问题中显示的代码。
标签: jsf jsf-2 primefaces