Excel 파일 집합에서 정적으로 생성되는 jsf 구성 요소 집합 (비즈니스 사람들이 업데이트 함)이 있습니다. 생성 된 각 파일은 데이터가 약간 다른 비즈니스 오브젝트를 나타내며, 모두 동일한 클래스에 속합니다.JSF ui : 조각 렌더링 된 성능
<!-- IMPLEMENTATION -->
<composite:implementation>
<ui:fragment rendered="#{cc.attrs.type eq 'cartcred'}">
<limites:limites-cartcred limite="#{cc.attrs.limite}"/>
</ui:fragment>
<ui:fragment rendered="#{cc.attrs.type eq 'cdcp'}">
<limites:limites-cdcp limite="#{cc.attrs.limite}"/>
</ui:fragment>
<ui:fragment rendered="#{cc.attrs.type eq 'cheqpredatado'}">
<limites:limites-cheqpredatado limite="#{cc.attrs.limite}"/>
</ui:fragment>
<ui:fragment rendered="#{cc.attrs.type eq 'confirming'}">
<limites:limites-confirming limite="#{cc.attrs.limite}"/>
</ui:fragment>
<!-- many more lines -->
<!-- many more lines -->
<!-- many more lines -->
<ui:fragment rendered="#{cc.attrs.type eq 'contacorr'}">
<limites:limites-contacorr limite="#{cc.attrs.limite}"/>
</ui:fragment>
:
동적으로 렌더링하기 위해
, 내가 찾은 유일한 해결책은 런타임에 적절한 구성 요소에 ui:fragment
의 무리 파견을 설정했다
그러나 나는 이것의 성능이 끔찍하다는 것을 알았습니다. 나는 JSF가 하나의 컴포넌트만을 렌더링 할 것을 강요했지만, 모두을 렌더링하고 런타임에 다른 컴포넌트를 "숨기는"것으로 보인다.
내 목표를 달성하는보다 효율적인 방법이 있습니까? 을 비즈니스 클래스에 대한 런타임 정보 (if-then-else와 비슷 함)를 기반으로 단일 구성 요소으로 렌더링하려고하지만 런타임시 렌더링 할 구성 요소 만 결정할 수 있습니다.
명확한 설명 : 무슨 일하는 limites:limites*
에 의해 참조 각 구성 요소가 다른 구성 요소의 많은 거대한 복잡한 페이지는 것이다. 런타임에 type' will decide what component to render. But my tests show that if I only render one component, but leave the other
ui : fragments`라는 매개 변수 (심지어 렌더링되지 않는다는 것을 알면서도)는 을보다 더 느리게 렌더링합니다.
그래서 내 페이지가 정확히 같은 경우 :
가<composite:interface>
<composite:attribute name="type" required="true" />
<composite:attribute name="limite" required="true" />
</composite:interface>
<composite:implementation>
<ui:fragment rendered="#{cc.attrs.type eq 'cartcred'}">
<limites:limites-cartcred limite="#{cc.attrs.limite}"/>
</ui:fragment>
</composite:implementation>
더 빨리 초기 버전보다 많은 (10 배 주위를) 렌더링, 매개 변수가 동일하더라도. 필자는 JSF가 전체 컴포넌트 트리를 생성하고 런타임시에만 (제공된 파라미터에 따라) 서로를 렌더링할지 여부를 결정할 것이라고 생각합니다.
거의 다
편집. 내 복합 구성 요소동적으로을 포함하면됩니다. ELExpression을 평가하려고 시도했지만 작동하지 않았습니다.
//obviously, ELExpressions don't work here
Resource resource = application.getResourceHandler().createResource("file-#{varStatus.loop}.xhtml", "components/dynamicfaces");
이 기능은 제 특정 문제를 해결하지 못했지만 정답이라고 생각합니다. –
@Miguel, 감사합니다. Java 코드에서 el 식을 사용하는 방법에 대한 예제는 내 업데이트를 참조하십시오. –
Hehe 고마워, 나는 콩에서 ELExpression을 평가하려고 이미 시도했지만 어떤 이유로 제대로 평가하지 못했다. 'setComponent'가 불려 갔을 때에 액세스하려고하고 있던 변수를 해결할 수 없었습니다. 때때로 당신은 계속 전진해야합니다. –