【问题标题】:Unable to send mail from jsf using data table,无法使用数据表从 jsf 发送邮件,
【发布时间】:2014-01-27 17:27:09
【问题描述】:
     public void approveVacation() throws AddressException,MessagingException
     String emplname=this.getEmployeeName();

    session = FacesContext.getCurrentInstance().getExternalContext()
        .getSessionMap();

    VacationDTO vacation=new VacationDTO();
    vacation.setLeaveId(this.getLeaveId());
    vacation.setLeaveDescriptions(this.getLeaveDescriptions());
    vacation.setLeaveStartDate(this.getLeaveStartDate());
    vacation.setEmployee(getEmployeeService().getUserByEmployeeId(getEmployeeId()));

    vacation.setIsApproved((byte)1);
    getVacationService().approveVacation(vacation);
    String to=vacation.getEmployee().getEmployeeEmailAddress();
    String name=vacation.getEmployee().getEmployeeName();
    getVacationService().approveVacation(vacation);
    Util.sendMail(to, "Hi"+name,
            "Your vacation have been approved");

这是我使用 List 的 Xhtml 页面......

  <h:form>


            <h:dataTable headerClass="header" rowClasses="oddRow,evenRow" value="#{approveVacationBean.vacationList}"
                    var="list">
                     <h:column>
                        <f:facet name="header">Employee Id</f:facet>
                    #{list.employee.employeeId}
                </h:column>
                     <h:column>
                        <f:facet name="header">Employee Name</f:facet>
                    #{list.employee.employeeName}
                </h:column>

                  <h:column>
                        <f:facet name="header">Leave Applied</f:facet>
                    #{list.leaveStartDate}

                </h:column>
                    <h:column>
                        <f:facet name="header">Leave Start Date</f:facet>
                    #{list.leaveStartDate}

                </h:column>


                    <h:column>
                        <f:facet name="header">Leave End Date</f:facet>
                    #{list.leaveEndDate}
                </h:column>
                    <h:column>
                        <f:facet name="header">No of days</f:facet>
                    #{list.leaveEndDate}


</h:column>
<h:column>
<f:facet name="header">Paid Leave Balence</f:facet>
  #{list.leaveBalance}
  </h:column>

                  <h:column>
                  <f:facet name="header">Leave  Description</f:facet>
                  #{list.leaveDescriptions}


                  </h:column>
                <h:column>
                        <f:facet name="header">Comment</f:facet>
                    <h:inputTextarea ></h:inputTextarea>
                </h:column>
                <h:column>
                        <f:facet name="header"></f:facet>
                <h:commandButton value="Approve"/>
                <h:commandButton value="Reject"/>
                </h:column>

                </h:dataTable>

我在选择特定的行按钮时遇到问题。

多次调用服务方法...我使用 getVacationList() 来显示列表,但没有邮件发送给特定员工

【问题讨论】:

    标签: jsf


    【解决方案1】:

    首先,将您的approveVacation 方法放在approveVacationBean 中。

    然后改变方法接受列表作为参数(我猜是VacationDTO)。

    最后你应该把 commandButton 和approveVacation 方法联系起来:

    <h:commandButton value="Approve" ajax="false" action="#{approveVacationBean.approveVacation(list)}"/>
    

    您的approveVacation 方法应如下所示:

    public void approveVacation(VacationDTO vacation) throws AddressException,MessagingException {
    
    vacation.setIsApproved((byte)1);
    getVacationService().approveVacation(vacation);
    String to=vacation.getEmployee().getEmployeeEmailAddress();
    String name=vacation.getEmployee().getEmployeeName();
    getVacationService().approveVacation(vacation);
    Util.sendMail(to, "Hi"+name,
            "Your vacation have been approved");
    

    }

    【讨论】:

    • MB持有vacationList()的范围是什么?您是否使用@PostConstruct 来初始化vacationList?显示您的 MB 代码...
    • 我尝试了所有范围。我正在使用 getVacationList()..我没有使用 @PostConstruct..
    猜你喜欢
    • 2011-12-08
    • 1970-01-01
    • 2014-07-29
    • 2022-01-18
    • 2016-02-03
    • 2016-05-30
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多