尝试根据下拉列表值动态显示页面。所有关联的组件都在正确呈现。当我的 bean 在视图范围内时,验证不会触发,而会话范围内同样可以正常工作。任何人都可以帮我解决问题?
下面是我的 Main.xhtml 代码。此页面包含下拉列表。基于下拉值动态包括页面。
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="#{templates.standard}">
<ui:define name="contentArea">
<c:choose>
<c:when test="#{testBean.value == '1'}">
<h:panelGroup>
<ui:include src="Page1.xhtml" />
</h:panelGroup>
</c:when>
<c:when test="#{testBean.value == '2'}">
<h:panelGroup>
<ui:include src="Page2.xhtml" />
</h:panelGroup>
</c:when>
</c:choose>
</ui:define>
</ui:composition>
</html>
The below Page1.xhtml will be included dynamically in Main.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<html 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">
<h:panelGroup>
<h:inputText value="#{testBean1.date}"
id="date"
required="true" requiredMessage="Enter Valid date">
<f:validator validatorId="test.TestDateValidator" />
</h:inputText>
</h:panelGroup>
<h:panelGroup>
<h:message for="date"/>
</h:panelGroup>