JSF中的托管bean。方法未调用

时间:2014-12-23 05:24:17

标签: jsf jsf-2

这是我的经理bean。我已经尝试了很多东西。我无法将数据写入数据库。无论如何都不会调用save()函数。

package com.softtouch.uim;

import com.softtouch.entity.Client;
import com.softtouch.manager.ClientBeanLocal;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "addClientUIM")
@SessionScoped
public class AddClientUIM {

    @EJB
    private ClientBeanLocal clientBean;

    public AddClientUIM() {
    }
    Client client = new Client();

    public void save() {
        boolean saved = clientBean.addClient(client);
        System.out.println("***********************");
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }
}

我的会话bean是

package com.softtouch.manager;

import com.softtouch.dataaccess.ClientFacadeLocal;
import com.softtouch.entity.Client;
import javax.ejb.EJB;
import javax.ejb.Stateless;

@Stateless
public class ClientBean implements ClientBeanLocal {

    @EJB
    private ClientFacadeLocal clientFacade;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public boolean addClient(Client client) {
        boolean valid = false;

        clientFacade.create(client);
        if (client != null && client.getId() != null) {
            valid = true;
        }
        return valid;
    }
}

和我调用save方法的XHTML页面是。

<tr>
    <td> &#8194;&#8194;</td>
    <td> &#8194;&#8194;</td>
    <td width="10%"></td>
    <td> &#8194;&#8194;</td>
    <td align="center">

        <h:commandButton value="Submit"
                         id="button"
                         action="#{addClientUIM.save()}"/>
    </td>
</tr>

0 个答案:

没有答案