Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java save方法仅获取id,其他属性为空_Java_Jsf_Ejb - Fatal编程技术网

Java save方法仅获取id,其他属性为空

Java save方法仅获取id,其他属性为空,java,jsf,ejb,Java,Jsf,Ejb,我用EJB和JSF(primefaces)用java开发了一个应用程序。这是我的问题。我的应用程序中有一个itemsave方法。我想从文件表中检索数据,但在调试时,我发现该方法只从表单检索id,其余属性返回null。我哪里做错了什么。先谢谢你 public String savedol(ActionEvent actionEvent) { FacesContext context = FacesContext.getCurrentInstance(); try {

我用EJB和JSF(primefaces)用java开发了一个应用程序。这是我的问题。我的应用程序中有一个item
save
方法。我想从
文件
表中检索数据,但在调试时,我发现该方法只从表单检索id,其余属性返回null。我哪里做错了什么。先谢谢你

public String savedol(ActionEvent actionEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    try {
        Long idFile = (Long) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("idFile");
        if (this.doleance.getId() == null) {
            idFile = file.getId();
            this.fiche.setId(idFile );
            this.fiche.getId();
            this.fiche.getCustumer();
            this.fiche.getCustumer().getCountry();
            doleance.setFiche(fiche);
            this.complaintsDetailsService.saveOne(doleance);
            context.addMessage(null, new FacesMessage(Constante.SAVE_SUCCESSFUL));
            this.complaint= new ComplaintsDetails();
            this.file= new File();
            return "/fileComplaints/complaints.xhtml?faces-redirect=true";
        } else {
            this.complaintsDetailsService.updateOne(complaint);
            this.file = new File();
            context.addMessage(null, new FacesMessage(Constante.MODIF_SUCCESSFUL));
        }
        return "/fileComplaints/complaints.xhtml?faces-redirect=true";
    } catch (Exception e) {
        e.getMessage();
        context.addMessage(null, new FacesMessage(Constante.SAVE_UNDONE));
        this.complaintsDetailsService.updateOne(doleance);
        this.fileService.updateOne(fiche);
    }
    this.file = new File();
    return null;
}
我发现了一个错误 的确我对服务进行了值强化,现在它得到了所有的类in参数,如下所示

public String savedol(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
try {
    Long idFile = (Long) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("idFile ");
        this.file = this.ficheService.find(idFile );
        doleance.setFile(file);
        doleance.setClient(file.getCustumer());
        doleance.setPays(file.getCustumer().getCountry());
        this.complaintsDetailsService.saveOne(doleance);
        context.addMessage(null, new FacesMessage(Constante.SAVE_SUCCESSFUL));
        this.complaint= new ComplaintsDetails();
        this.file= new File();
        return "/fileComplaints/complaints.xhtml?faces-redirect=true";
    } else {
        this.complaintsDetailsService.updateOne(complaint);
        this.file = new File();
        context.addMessage(null, new FacesMessage(Constante.MODIF_SUCCESSFUL));
    }
    return "/fileComplaints/complaints.xhtml?faces-redirect=true";
} catch (Exception e) {
    e.getMessage();
    context.addMessage(null, new FacesMessage(Constante.SAVE_UNDONE));
    this.complaintsDetailsService.updateOne(doleance);
    this.fileService.updateOne(fiche);
}
this.file = new File();
return null;}
它现在保存值​​客户端和从文件中恢复的国家/地区的名称。 使用此
this.file=this.ficheService.find(idFile)


如果这对其他人有帮助。

Hi,首先从创建一个and read开始。它帮助你缩小问题的范围。在这个问题上帮不上忙。请发布版本信息。此外,您阅读
idFile
的方式非常陈旧(实际上,JSF中从未需要它,这是jsp/servlet和php人员的工作方式),我只看到您“阅读”这个值……您应该删除您的电子邮件,因为您想来这里查看答案:-)谢谢您的回答,关于
idFile
的阅读,您建议我如何阅读,谢谢。很抱歉,在发送之前我没有阅读问题。请暂时保留该部分,关注其他事项;-)谢谢好多了。嗨,我想知道是否有人能帮我改进代码,让它更干净、更专业。非常感谢。