首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >requestScope中的以下属性在哪里?"requestScope.shouldRender“

requestScope中的以下属性在哪里?"requestScope.shouldRender“
EN

Stack Overflow用户
提问于 2012-03-23 19:24:05
回答 1查看 2.4K关注 0票数 2

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

代码语言:javascript
复制
<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>  

我见过与commandButtonremoteCommand相关的primefaces类,但我没有发现与shouldRender有关的任何东西。我有关于requestScope的搜索信息,但是我没有找到信息。

怎样才能叫"shouldRender"?是否有更多的属性/方法可以以同样的方式调用?

各种问候。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-23 19:45:29

#{requestScope}引用ExternalContext#getRequestMap()可以获得的请求属性映射(如果您知道基本Servlet,它将进一步委托给HttpServletRequest#get/setAttribute() )。

下面这一行,

代码语言:javascript
复制
<f:setPropertyActionListener value="#{true}"   
    target="#{requestScope.shouldRender}" /> 

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

输出文本的呈现属性只是在同一HTTP请求的呈现响应期间截取该属性:

代码语言:javascript
复制
rendered="#{requestScope.shouldRender}"

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

代码语言:javascript
复制
<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>  

使用

代码语言:javascript
复制
@ManagedBean
@RequestScoped
public class Bean {

    private boolean shouldRender;

    // Getter+setter.
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9845319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档