是否有可能让JSF更新一个放在组件上下文之外的组件?
目前以下页面不起作用:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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">
<h:head>
<title>Welcome</title>
</h:head>
<h:body>
<p><h:outputText id="out" value="#{user.greeting}" /></p>
<h:form id="form1">
<h:inputText value="#{user.name}" id="user-name" />
<p><h:inputSecret value="#{user.password}" id="password" /></p>
<p>
<h:commandButton value="Login" id="login-button">
<f:ajax execute="user-name password" render="out" />
</h:commandButton>
</p>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
我知道,如果我把#out
组件放在<h:form>
页面内将会正确呈现.但有没有办法将#out
组件放在表单之外(例如现在的位置)?
Lam*_*bda 12
解决了!可以out
称为:out
.以这种方式findComponent
从视图根开始搜索它.所以这是工作解决方案:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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">
<h:head>
<title>Welcome</title>
</h:head>
<h:body>
<p><h:outputText id="out" value="#{user.greeting}" /></p>
<h:form id="form1">
<h:inputText value="#{user.name}" id="user-name" />
<p><h:inputSecret value="#{user.password}" id="password" /></p>
<p>
<h:commandButton value="Login" id="login-button">
<f:ajax execute="user-name password" render=":out" />
</h:commandButton>
</p>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9921 次 |
最近记录: |