【问题标题】:rendered tag in JSF 2JSF 2 中的渲染标签
【发布时间】:2015-04-20 13:23:09
【问题描述】:

我有一个应用程序使用 JSF implementation 2.1.29 Sun JSF RI 与 Spring 3.1.0 和 Richfaces 4.3.7 集成,代码如下:

<h:form>
<a4j:outputPanel rendered="#{searchBean.activeTab}">
    .....
</a4j:outputPanel>
</h:form>

<h:form>
<a4j:outputPanel id="searchPanel">
    <a4j:outputPanel rendered="#{searchBean.activeTab2}">

                <div class="formline">
                    <div class="formLabelGrueso">
                        <h:outputText value="#{msgs['search.height']}" />
                    </div>
                    <div class="formTextCorto oblig">
                        <h:inputText value="#{searchBean.form.height}" required="true" label="#{msgs['search.height']}" maxlength="6">
                            <f:validateDoubleRange minimum="50.00" maximum="300.00" />
                        </h:inputText>
                    </div>
                    <div class="formLabelGrueso">
                        <h:outputText value="#{msgs['searchBean.weight]}" />
                    </div>
                    <div class="formTextCorto">
                        <h:inputText value="#{searchBean.form.weight}" label="#{msgs['searchBean.weight]}" maxlength="6">
                            <f:validateDoubleRange minimum="1.00" maximum="199.00" />
                        </h:inputText>
                    </div>
                </div>      
        <a4j:commandButton action="#{searchBean.advancedSearch}" execute="@this" id="buttonDefault"
            render="searchPanel" value="#{msgs['user.button.search']}"></a4j:commandButton> 
    </a4j:outputPanel>
</<a4j:outputPanel>
</h:form>

ManagedBean 由 spring 框架管理,代码如下:

@Component
@Scope(WebApplicationContext.SCOPE_SESSION)
public class SearchBean{
    private boolean activeTab;

    private boolean activeTab2;

    ....
}

当我提交时,在服务器上运行 #{searchBean.activeTab} 和 #{searchBean.activeTab2} 方法。为什么当真的只进行呈现“searchPanel”面板的ajax调用时执行这两种方法?不应该只运行 #{searchBean.activeTab2} 方法?。

谢谢。

【问题讨论】:

    标签: jsf-2 richfaces tabpanel conditional-rendering


    【解决方案1】:

    我不确定我是否理解正确,但默认情况下&lt;a4j:outputPanel&gt; 将随每个 AJAX 请求重新呈现,即使您没有将其 id 放入 @render;禁用添加ajaxRendered="false"

    【讨论】:

    • 问题不在于 标签,如果通过 更改 两种方法在 ajax 调用时仍在运行。
    猜你喜欢
    • 1970-01-01
    • 2012-04-27
    • 2010-12-14
    • 2011-05-17
    • 2013-08-31
    • 1970-01-01
    • 2015-01-22
    • 2010-11-30
    • 1970-01-01
    相关资源
    最近更新 更多