【问题标题】:a4j:commandButton reRendering rich:datatablea4j:commandButton reRendering rich:datatable
【发布时间】:2012-10-30 09:06:12
【问题描述】:

我的问题是我试图让我的数据表中的列默认显示输出文本,并在按下命令按钮时将其替换为输入文本。还没有找到解决办法。顺便说一下第一次发帖。

我有一个 a4j:commandButton,我希望重新渲染这部分数据表

<a4j:commandButton reRender="yieldTable" action="#{yieldSearch.activateVisible()}"
id="modify" styleClass="editLargeIcon" value="Modify">
</a4j:commandButton>

<rich:dataTable id="yieldTable" value="#{yieldSearch.yfitem.yielditem}" var="_yield">
<rich:column>
<f:facet name="header">%-YLD</f:facet>
<h:outputText value="#{_yield.yfYield}" rendered="#{not yieldSearch.visible}">
</h:outputText>
<h:inputText rendered="#{yieldSearch.visible}" />
</rich:column>

我想激活这个方法(只显示相关代码)

@Name("yieldSearch")
@Scope(ScopeType.CONVERSATION)
public class YieldSearch implements Serializable{

private Boolean visible;

public void activateVisible(){
    this.setVisible(true);
    System.out.print(true);
}

    public void setVisible(Boolean visible) {
    this.visible = visible;
}

public Boolean getVisible() {
    return visible;
}

非常感谢任何帮助。

【问题讨论】:

    标签: jsf richfaces jsf-1.2 rerender richdatatable


    【解决方案1】:

    您需要将这两个组件包装在 &lt;a4j:outputPanel id="myPanel" ajaxRendered="true"/&gt; 中。两个组件都无法重新渲染的原因是您设置为rendered="false" 的组件在初始视图渲染时不会发送到浏览器。

    <a4j:outputPanel id="myPanel" ajaxRendered="true">
    <h:outputText value="#{_yield.yfYield}" rendered="#{not yieldSearch.visible}"/>
    <h:inputText rendered="#{yieldSearch.visible}" />
    </a4j:outputPanel>
    

    ajax 刷新工作的方式是使用 javascript 在 DOM 树中定位 clientId 以使用新标记进行更新,即组件必须已经在 DOM 树中。由于您设置了rendered="false",因此该组件从不在DOM 树中开始。因此,在 ajax 请求中,浏览器不知道您在说什么,因为它找不到要更新的 clientId。

    将 outputPanel 与 ajaxRendered="true" 一起使用,您将刷新整个 outputPanel,因此 ajax 刷新将更新该组件作为一个整体,以及您在其中嵌套的任何内容

    【讨论】:

    • 在这种情况下,&lt;rich:dataTable&gt; 将充当 UIContainer,因此重新渲染数据表将相应地显示/隐藏&lt;h:outputText&gt;/&lt;h:inputText&gt;。看起来 OP 无法处理这种情况下的对话范围。
    猜你喜欢
    • 2011-01-15
    • 2015-03-30
    • 1970-01-01
    • 2013-05-08
    • 2010-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-27
    相关资源
    最近更新 更多