JSF ajax呈现inputText,但不呈现panelGrid

JSF ajax呈现inputText,但不呈现panelGrid,ajax,jsf,rendering,panelgrid,Ajax,Jsf,Rendering,Panelgrid,我发现JSF的ajax呈现有一种奇怪的行为,我不是舒尔,我缺少的是什么。 为了简单起见,我有一个带有h:inputText和h:panelGrid的页面,其中有一个按钮。当有人单击按钮时,应使用标准值设置h:inputText的值,并且h:panelGrid应消失。首先,我将展示代码,然后再进一步解释 xhtml页面: <h:inputText id="trackingIdValue" value="#{bean.trackingId}" /> <h:panelGrid bo

我发现JSF的ajax呈现有一种奇怪的行为,我不是舒尔,我缺少的是什么。 为了简单起见,我有一个带有
h:inputText
h:panelGrid
的页面,其中有一个按钮。当有人单击按钮时,应使用标准值设置
h:inputText
的值,并且
h:panelGrid
应消失。首先,我将展示代码,然后再进一步解释

xhtml页面:

<h:inputText id="trackingIdValue" value="#{bean.trackingId}" />

<h:panelGrid border="15"  id="panel"  rendered="#{not empty bean.list}">
    <h:commandButton action="#{bean.render}" value="Clear Panel" >
        <f:ajax execute="@this" render="panel trackingIdValue" />
    </h:commandButton>
</h:panelGrid>
private Long trackingId;
private List<String> list;

public Long getTrackingId() {
    return trackingId;
}

public List<String> getList() {
    return list;
}

public void setList( List<String> list ) {
     this.list = list;
}

@PostConstruct
public void init() {
     // the list will be filled with some initial values
}

public void render() {
     this.trackingId = 954643L;
     list.clear();
}

当我删除标题标记时,ajax请求可以与inputtext和面板一起正常工作。但是,当我像上面那样在标题中添加样式表时,ajax只对inputtext起作用

哪个是您的bean的作用域?bean在视图作用域中,但由于ajax呈现,这应该不是问题所在。请检查
getList
方法,该方法在点击按钮后返回一个完全空的列表。您的确切意思是什么?我正在清除render方法中的列表,当我在render方法完成后打印出列表的大小时,它告诉我大小是zeroMmh,这很奇怪。无论如何,您是否介意使用包装的
h:commandButton
中的
rendered
属性,而不是要渲染的
panelGrid
?在JSF中,这样做是最佳实践。
<h:head>
    <h:outputStylesheet name="masterStyle.css" library="css"  />
</h:head>
<h:body>
    <h:form>
        <h:inputText id="trackingIdValue" value="#{testBean.trackingId}" />
        <h:panelGroup border="15" id="panel"
            rendered="#{not empty testBean.list}">
            <h:commandButton action="#{testBean.render}" value="Clear Panel">
                <f:ajax execute="@this" render="panel trackingIdValue" />
            </h:commandButton>
        </h:panelGroup>
    </h:form>
</h:body>
</html>