我乞求使用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> 我见过与commandButton和remoteCommand相关的primefaces类,但我没有发现与shouldRender有关的任何东西。我有关于requestScope的搜索信息,但是我没有找到信息。
怎样才能叫"shouldRender"?是否有更多的属性/方法可以以同样的方式调用?
各种问候。
发布于 2012-03-23 19:45:29
#{requestScope}引用ExternalContext#getRequestMap()可以获得的请求属性映射(如果您知道基本Servlet,它将进一步委托给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.
}https://stackoverflow.com/questions/9845319
复制相似问题