jsf - PrimeFaces 远程命令未调用

标签 jsf jsf-2 primefaces

我正在使用远程命令按钮来执行 bean 级别的方法。但是我的命令按钮不起作用。

我在下面附上我的代码:

 <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/BasicTemplate.xhtml">
    <ui:define name="content">
        <div class="container">

        <script>

        function doAlert(s)
        {
            if(s=="true")
                {
                alert(s);
                rc();
                alert('hi i am');
                }
            else
                {
                 alert("Wrong Finger Print");
                }
        }

        </script>


          <h:form class="form-horizontal" id="myform" >
                <div class="row">

        <h:messages />
        <h:panelGrid columns="3" cellpadding="4" border="0" columnClasses="control-label">

            <h:outputText  value="Username :" />
            <h:inputText id="username" value="#{loginBean.login}" label="username" style="width: 200;" /> 
            <p:watermark for="username" value="Username" ></p:watermark>

            <h:outputLabel for="password" value="Password :" />
            <h:inputSecret id="password" value="#{loginBean.password}" label="password" style="width: 200;"/> 
            <p:watermark for="password" value="Password"></p:watermark>

            <p:spacer></p:spacer>
            <!-- <p:commandButton value="Login" action="#{loginBean.logMeIn}" widgetVar="mybutton" /> -->

            <p:commandButton id="loginButton" value="Login" action="#{loginBean.logMeIn}" widgetVar="mybutton"  disabled="#{!loginBean.enabled}"/>
            <p:remoteCommand name="rc" update="loginButton" actionListener="#{loginBean.enableButton}" /> 
            <p:spacer></p:spacer>
            <h:outputText value="#{loginBean.enabled}"></h:outputText>
            <applet id="fingureprintapplet" name="fingureprint" codebase="classes"  code="fingerprintntscanner.MyClassApplet.class" archive="#{facesContext.externalContext.requestContextPath}/FIngerprintntScanner.jar,#{facesContext.externalContext.requestContextPath}/lib/NBioBSPJNI.jar" width="300" height="400">

            </applet>
        </h:panelGrid>

        </div>
        </h:form>

        </div>
    </ui:define>
</ui:composition>

我的 bean 是:

     @ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {
    private static final long serialVersionUID = 1L;

    private String login;
    private String password;
    private boolean enabled;

    @ManagedProperty(value = "#{authenticationService}")
    private AuthenticationService authenticationService; // injected Spring defined service for bikes


    public String logMeIn() {

        boolean success = authenticationService.login(login, password);

        if (success){
            return "/faces/pages/home.xhtml?faces-redirect=true"; // return to application but being logged now 
        }
        else{
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Login or password incorrect."));           
            return "/faces/login.xhtml";
        }
    }

    public String logout(){
        System.out.println("chandan");
        authenticationService.logout();
        return "/faces/pages/home.xhtml?faces-redirect=true"; 
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }



    public void setAuthenticationService(AuthenticationService authenticationService) {
        this.authenticationService = authenticationService;
    }

    public void enableButton() {
        System.out.println("chandan");
        enabled = true;
    }

    public boolean isEnabled(){
        System.out.println("value is");
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        System.out.println("value is sdgsdg");
        this.enabled = enabled;
    }

请检查为什么我的远程命令不起作用。

最佳答案

remoteCommand 上使用 process="@this"partialSubmit="true"

关于jsf - PrimeFaces 远程命令未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28338444/

相关文章:

jsf - 在dataTable中显示一对多关系

jsf - 滚动数据表素数

jsf - 为什么在 p :messages if the client id doesn't match? 中添加了 JSF 消息

java - 仅当对象属于用户时,用户才能调用方法

javascript - 在 JSF 中 - 获取客户端的语言环境(以浏览器的时区显示时间)

jsf-2 - 定义自定义转换器时,FacesConverter 注释中的 value 和 forClass 哪个优先级更高?

jsf - 警告 : @FacesConverter is using both value and forClass, 仅应用值

primefaces - 如何使用 p :calendar - PrimeFaces 6. 2 隐藏周末

css - 按钮在一行中 h :panelGrid

java - 如何通过角色声明来验证用户身份?