Jsf 在<;f:ajax>;组件';语境

Jsf 在<;f:ajax>;组件';语境,jsf,jsf-2,Jsf,Jsf 2,有可能让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://ww

有可能让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>

欢迎


我知道如果我将
#out
组件放入
中,页面将正确呈现。但是是否有办法将
#out
组件放置在表单之外(例如,它现在所在的位置)?

已解决!可以将
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>

欢迎