1
<h:form id="aform">
<p:growl id="debug-growl" showDetail="true" sticky="false" />
<p:inputText id="expression" value="#{debug.expression}" required ="true" />
<p:commandButton update="debug-growl" value="Process" action="#{debug.myaction}" />
<h:outputText value="Source regular expression: #{debug.expression}" rendered="#{not empty debug.expression}" />
</h:form>
@ManagedBean
@ViewScoped
public class Debug implements Serializable {
private String expression; //getter & setter is present
當我進入那說明提交在h:outputText
元素後的值。 但是如果我輸入空值(這是錯誤的),那麼在h:outputText
元素中仍然存在以前的值。
未提交任何值時如何隱藏'h:outputText'?
試着改變你的@ViewScoped註釋 – JokerTheFourth
@JokerTheFourth:要什麼,爲什麼? – Kukeltje
要隱藏一些你可以使用'Disabled'或'Rendred'的例子(Rendred),它將被隱藏。 –