2014-03-02 43 views
0

Hej我有一些问题,我的登录形式。 在形式上我有2个作用:默认命令不起作用

<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ę" /> 

,当我按我的键盘上输入我要选择全自动第二行动“confirmSignIn”

当我击进入应用程序中执行行动“NEWUSER”

我尝试使用默认命令。

,我增加一些类:

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}" /> 

当我重新启动Tomcat我得到:

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

谁能知道在哪里可以是一个问题?我没有线索;/

回答

1

第一:你的action属性需要一个EL表达式。取而代之的

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


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

yourBean需要方法newUserconfirmSignIn

其次:检查DefaultCommandBean中的字符串btn的值,是值newUserButtonsubmitButton

+0

thx为答案我已修复它以其他方式。我改变了线女巫我添加到XHTML到: 及其工作正常:) – Rodenar

+0

与硬编码目标字符串,你不能改变'defaultCommand'在运行时。我认为这就是你想要的。 – Manuel

+0

立即写入我只想瞄准2个动作中的1个。但thx的建议,当我的项目成长时,我会需要它leter :) – Rodenar