2014-03-02 8 views
0

안녕하세요, 제 로그인 양식에 문제가 있습니다.기본 명령이 작동하지 않습니다.

<p:commandButton id="newUserButton" action="newUser" immediate="true" icon="ui->icon-plus" value="Zarejestruj się" /> 
<p:commandButton id="submitButton" action="confirmSignIn" update="logPanelGrid,messages" icon="ui-icon-check" value="Zaloguj się" /> 

그리고 난 내 키보드의 Enter 키를 누르면 나는 응용 프로그램이

행동 "NEWUSER"를 실행 Enter 키를 누르 때를 automaticly 두 번째 작업 "confirmSignIn"

을 선택합니다 : 형태에서 난 2 행동이

tryed 기본 명령을 사용합니다.

와 나는 몇 가지 클래스 추가 :

package org.primefaces.examples.view; 

public class DefaultCommandBean 
{ 

    private String btn; 

public DefaultCommandBean(String btn) { 
     this.btn = btn; 
    } 

public String getBtn() { 
    return btn; 
} 

public void setBtn(String btn) { 
    this.btn = btn; 
} 

} 

을하고 난 XHTML 일부 행을 추가합니다 내가 바람둥이를 다시 시작할 때

<p:defaultCommand target="#{defaultCommandBean.btn}" /> 

내가 얻을 :

SEVERE: Error Rendering View[/WEB-INF/flows/main/welcome.xhtml] 
java.lang.IllegalArgumentException: "" 

할 수있는 사람이 위치를 알고 문제가 될 수 있습니까?/

답변

1

첫 번째 : action 속성에는 EL 표현식이 필요합니다. yourBean 반면 대신

<p:commandButton ... action="newUser" ... /> 
<p:commandButton ... action="confirmSignIn" ... /> 


<p:commandButton ... action="#{yourBean.newUser}" ... /> 
<p:commandButton ... action="#{yourBean.confirmSignIn}" ... /> 

는 방법을 newUserconfirmSignIn이 필요합니다.

두 번째로 :에서 문자열 btn의 값을 확인하십시오. newUserButtonsubmitButton입니까?

+0

답을위한 thx 나는 다른 방법으로 그것을 고쳤습니다. 나는 xhtml에 다음을 추가한다.

및 그 작업은 매우 좋다. – Rodenar

+0

하드 코딩 된 target-string을 사용하면 런타임시'defaultCommand'를 변경할 수 없다. 나는 그것이 당신이 원하는 것이라고 생각했습니다. – Manuel

+0

글을 참고하세요 : 나는 단지 1 of 2 행동을 목표로하고 싶다. 하지만 조언을위한 thx 내 프로젝트 growe 때 그것을 내게 필요할 것입니다 :) – Rodenar

관련 문제