2017年4月27日 星期四

ui:debug 和 flash.keep 的衝突

若在 facelet 中使用 ui:debug,則在同一個 facelet 中使用 flash.keep 時無法正常顯示 flash scope 中的變數。

測試資料
<?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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
Name <h:inputText value="#{flash.keep.name}" />
Tel: <h:inputText value="#{flash.keep.tel}" />
</h:panelGrid>
<h:commandButton value="Back" action="index?faces-redirect=true" />
</h:form>
</h:body>
</html>
view raw confirm.xhtml hosted with ❤ by GitHub
<?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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<ui:debug hotkey="x" />
<h:panelGrid columns="2">
Name <h:inputText value="#{flash.name}" />
Tel: <h:inputText value="#{flash.tel}" />
</h:panelGrid>
<h:commandButton value="Submit" action="confirm?faces-redirect=true" />
</h:form>
</h:body>
</html>
view raw index.xhtml hosted with ❤ by GitHub

References:
[1] ui:debug
[2] Flash class

沒有留言: