gpt4 book ai didi

java - requestScope 中的以下属性在哪里? "requestScope.shouldRender"

转载 作者:行者123 更新时间:2023-12-04 05:53:01 27 4
gpt4 key购买 nike

我乞求使用primefaces,在remoteCommand的这段代码中,我看到#{requestScope.shouldRender},我很困惑

<h:form id="form">  

<p:commandButton value="Load" type="button" onclick="lazyload()" id="btnLoad" />

<p:outputPanel id="lazypanel" layout="block">
<h:outputText value="This part of page is lazily loaded on demand using a RemoteCommand"
rendered="#{requestScope.shouldRender}"/>
</p:outputPanel>

<p:remoteCommand name="lazyload" update="lazypanel">
<f:setPropertyActionListener value="#{true}"
target="#{requestScope.shouldRender}" />
</p:remoteCommand>



我见过与 相关的 primefaces 类命令按钮 远程命令 但我没有找到与 相关的任何内容应该渲染 .我有关于 requestScope 的搜索信息,但我没有找到信息。

怎么可能调用“shouldRender”?是否有更多的属性/方法可以以相同的方式调用???

亲切的问候。

最佳答案

#{requestScope}引用请求属性映射,您可以通过 ExternalContext#getRequestMap() 获得(如果您了解基本的 Servlet API,则进一步委托(delegate)给 HttpServletRequest#get/setAttribute() )。

下一行,

<f:setPropertyActionListener value="#{true}"   
target="#{requestScope.shouldRender}" />

基本上在调用父命令组件时在当前请求中设置一个名为“shouldRender”和值为“true”的请求属性。

输出文本的渲染属性只是在同一 HTTP 请求的渲染响应期间截取该属性:
rendered="#{requestScope.shouldRender}"

总而言之,它只是一种在请求范围内设置属性的方法,而不需要整个请求范围的支持 bean。它实际上与

<p:outputPanel id="lazypanel" layout="block">  
    <h:outputText value="This part of page is lazily loaded on demand using a RemoteCommand"   
            rendered="#{bean.shouldRender}"/>  
</p:outputPanel>  

<p:remoteCommand name="lazyload" update="lazypanel">  
    <f:setPropertyActionListener value="#{true}"   
        target="#{bean.shouldRender}" />  
</p:remoteCommand>  


@ManagedBean
@RequestScoped
public class Bean {

private boolean shouldRender;

// Getter+setter.
}

关于java - requestScope 中的以下属性在哪里? "requestScope.shouldRender",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9845319/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com