0
나는 p:commandLink
을 가지고 있으며 컨트롤러가 매개 변수를 기반으로 동작을 결정할 수 있도록하려고합니다. 내가 가진 무엇p : commandLink - 컨트롤러에서 작업 받기
:.
<p:commandLink
action="#{controller.getAction(rownum)}"
title="Go"
styleClass="ui-icon ui-icon-refresh centered"
ajax="false"
disabled="#{controller.isLinkDisabled(rownum)}">
<f:param name="controllerId" value="#{otherController.getId()}" />
</p:commandLink>
rownum
버튼이
컨트롤러 방식이에있는 p:dataTable
의 rowIndexVar
이다는 :
public String getAction(Integer id) {
if(id == 0) {
LOG.info("Id is 0"); //LOG is a log4j logger
return "toDestinationOne";
} else {
LOG.info("Id is not 0");
return "toDestinationTwo";
}
}
이 작동하지 않습니다. 내가
Id is 0
를 참조 로그에서 데이터 테이블의 첫 번째 행에있는 버튼을 누르면
그래서이 방법이 제대로 호출되는 것을 의미하지만, 어떤 이유로 그것을 반환 값을 무시하는 것은 페이지가 새로 고쳐지면 새 페이지로 리디렉션되지 않습니다.
두 문자열은 faces-config.xml
에 : 내가 대신 직접 값을 넣으면
<navigation-case>
<description>To destination one</description>
<from-action>toDestinationOne</from-action>
<from-outcome>toDestinationOne</from-outcome>
<to-view-id>/pages/destinationOne.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<description>To destination two</description>
<from-action>toDestinationTwo</from-action>
<from-outcome>toDestinationTwo</from-outcome>
<to-view-id>/pages/destinationTwo.xhtml</to-view-id>
</navigation-case>
이 제대로 작동합니다.
내 말은,이 :
<p:commandLink
action="toDestinationOne"
title="Go"
styleClass="ui-icon ui-icon-refresh centered"
ajax="false"
disabled="#{controller.isLinkDisabled(rownum)}">
<f:param name="controllerId" value="#{otherController.getId()}" />
</p:commandLink>
가 제대로 작동, 나는 성공적으로 원하는 페이지로 리디렉션.
commandLink
은 getAction
방법으로 반환 된 action
을 따르는 방법이 있습니까?
'# {controller.getAction (ROWNUM는)}'개의 서로 다른 리턴 할 수있는 방법을 말한다 액션, 그것은 액션 문자열이 아니에요 ... – BackSlash
그 뜻 :
dunni
그래, 그것을 시도하자! – BackSlash