2011-03-13 3 views
21

JSF 1.2 : ui : 매개 변수 포함

JSF 1.2 두 페이지 (one.xhtml 및 other.xhtml),
이 규칙에 따라 현재 페이지에 포함됩니다.

... 
    <c:if test="#{flowScope.Bean.param1}"> 
     <ui:include src="one.xhtml"/> 
    </c:if> 

    <c:if test="#{!flowScope.Bean.param1}"> 
     <ui:include src="other.xhtml"/> 
    </c:if> 
... 

지금까지 one.xhtmlother.xhtml과 동작 매개 변수 만 다릅니다.

one.xhtml : <h:commandLink action="actionOne">
other.xhtml : <h:commandLink action="actionTwo">

일부 일반 xhtml을 사용할 수 있습니까?
one.xhtml 및 other.xhtml 대신 다음과 같이하십시오.

... 
    <c:if test="#{flowScope.Bean.param1}"> 
     <ui:include src="general.xhtml" param="actionOne"/> 
    </c:if> 

    <c:if test="#{!flowScope.Bean.param1}"> 
     <ui:include src="general.xhtml" param="actionTwo"/> 
    </c:if> 
... 

도움을 주셔서 감사합니다.

답변

47

포함 된 파일에 매개 변수를 전달하려면 <ui:param><ui:include> 안에 중첩해야합니다.

<ui:include src="general.xhtml"> 
    <ui:param name="action" value="actionOne" /> 
</ui:include> 

과의

은 다음과 같습니다 :이 캐릭터 라인 만이 아닌 행동 방식을 지원

<h:commandButton action="#{action}" /> 

하는 것으로. 후자의 경우 JSF 2.0으로 업그레이드하고 composite components을 사용해야합니다. BalusC의 대답에 추가

+0

덕분에, 난 CC에 대해 khow, 그들은 큰하지만, 현재의 jsf 1.2 프로젝트에서 사용할 수 없습니다. 솔루션을 시도하고 결과를 다시 써 보겠습니다. – sergionni

+0

질문에 제시된대로 작동합니다. 그러나'actionOne' 대신에'# {bean.doSomething}'을 사용했다면 JSF 2.0 복합 컴포넌트를 실제로 가져와야 할 것입니다. – BalusC

+0

이상한, 그것은 던졌습니다 : action = "# {action}": Identity 'action'이 null이고 – sergionni

19

:

참고 이것은 단지 문자열, 하지 액션 메소드를 지원하는지. 후자의 경우 은 JSF 2.0으로 업그레이드하고 복합 구성 요소를 사용해야합니다. 그것은 다소 추한하지만

, JSF 1.2이 할 수있는 방법이있다 :

<ui:include src="general.xhtml"> 
    <ui:param name="actionBean" value="#{myBackingBean}" /> 
    <ui:param name="actionMethod" value="edit" /> 
</ui:include> 

<h:commandButton action="#{actionBean[actionMethod]}" /> 
관련 문제