a4j:commandButton重新渲染rich:datatable [英] a4j:commandButton reRendering rich:datatable

查看:136
本文介绍了a4j:commandButton重新渲染rich:datatable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我试图在数据表中让一列默认显示一个输出文本,并在按下命令按钮时将其替换为输入文本.尚未找到解决方案.顺便说一句.

My issue is that I am trying to have a column in my datatable show an outputtext by default, and replace that with an inputtext when the commandbutton is pressed. Have not found a solution. First post by the way.

我有一个a4j:commandButton,我希望重新呈现我的dataTable的这一部分

I have an a4j:commandButton that I am looking to reRender this part of my dataTable

<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>

我想激活此方法(仅显示相关代码)

And I would like activate this method (just shows relevant code)

@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;
}

非常感谢您的帮助.

推荐答案

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

You need to wrap both components in an <a4j:outputPanel id="myPanel" ajaxRendered="true"/>. The reason both components are failing to be reRendered is that the component you've set torendered="false" will not be sent to the browser on initial view rendering.

<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.

The way ajax refreshes work is by using javascript to locate a clientId in the DOM tree to update with new markup, i.e. the component must already be in the DOM tree. Since you've set the rendered="false", the component was never in the DOM tree to start with. So on an ajax request, the browser doesn't know what you're talking about because it can't find the clientId to update.

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

Using the outputPanel with ajaxRendered="true", you're refreshing the entire outputPanel, so the ajax refresh will update that component as a whole, with whatever you've nested within it

这篇关于a4j:commandButton重新渲染rich:datatable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆