【发布时间】:2023-03-29 14:55:02
【问题描述】:
<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:为什么?
-
要隐藏某些内容,您可以使用
Disabled或Rendred在这种情况下(渲染)它将是不可见的。
标签: jsf jsf-2 primefaces jsf-2.2