2012-03-23 3 views
2

내가 primefaces를 사용하는 구걸하고 있고 remoteCommand이 코드에서, 나는 # {requestScope.shouldRender}을보고 나는requestScope의 다음 속성은 어디에 있습니까? "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 클래스와 관련 의아해입니다 commandButtonremoteCommand 그러나 나는 과 관련이 없습니다. 렌더. requestScope에 대한 검색 정보가 있지만 정보를 찾지 못했습니다.

"shouldRender"는 어떻게 호출 할 수 있습니까? 같은 방식으로 호출하기위한 프로퍼티/메소드가 더 있습니까 ???

종류에 관해서. #{requestScope}

답변

3

당신이 ExternalContext#getRequestMap()에 의해 얻을 수있는지도 속성 요청을 의미한다 (이것은 다시 위임에 더 HttpServletRequest#get/setAttribute()에, 당신은 기본 서블릿 API를 알고있는 경우).

다음 줄

,

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

는 기본적으로 이름이 "shouldRender"부모 명령 구성 요소가 호출되고있는 현재의 요구에 "사실"의 값을 요청 속성을 설정합니다.

rendered="#{requestScope.shouldRender}" 

모든 모든이가 요청 범위에 속성을 설정하는 단지 방법 :

출력 텍스트의 렌더링 속성은 단지 바로 그 HTTP 요청의 응답을 렌더링 중에 있음에 차단한다 전체 요청 범위의 백업 빈을 사용할 필요가 없습니다. 그것은 ** setPropertyActionListener **의 actionListener을 통해 특성을 소개

@ManagedBean 
@RequestScoped 
public class Bean { 

    private boolean shouldRender; 

    // Getter+setter. 
} 
+0

Ah¡¡와

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

로 효과적으로 동일 않습니다. _setPropertyActionListener_에 대한 설명서를 잘못 읽었습니다. 고마워요. –

+0

당신을 진심으로 환영합니다. – BalusC

관련 문제