0

everyone,

I am facing a difficult questions and hope can have your helping hands. Thanks in advance.

I have a form, which have a SelectOneMenu that populate a list for user to select. After that, I load the details from db based on the user selection in the SelectOneMenu, and after that, save to DB by a h:commandButton

However, the action (method emailTemplateBean.updateTemplate) in h:commandButton just simply not triggered. Below is my xhtml code:

<f:metadata>
  <f:event type="preRenderView" listener="#{emailTemplateBean.loadEmailTemplate}"  />       
</f:metadata>

<h:form id="update_template_form">    
  Template: 
  <h:selectOneMenu id="templateSelect" value="#{emailTemplateBean.selectedTemplateID}">
    <f:selectItem id="templ0" itemLabel="" itemValue="" />
    <f:selectItems value="#{emailTemplateBean.emailTemplateList}" var="t" itemLabel="#{t.templateName}" itemValue="#{t.templateID}" />
    <f:ajax listener="#{emailTemplateBean.loadTemplateDetail}" execute="@this" render="@form" update="update_template_form" />
  </h:selectOneMenu>

<table class="table table-bordered table-striped">
    <tr>
      <td>Subject (Eng):</td> 
      <td colspan="3"><h:inputText id="subject_en" value="#{emailTemplateBean.emailTemplate.subjectEN}"/></td>

</tr>
...

</table>
<h:commandButton styleClass="btn btn-small btn-primary" value="Update" action="#{emailTemplateBean.updateTemplate}"></h:commandButton>
</h:form>

the backing bean:

@ManagedBean(name="emailTemplateBean")
@ViewScoped
public class EmailTemplateBean implements Serializable {

public void loadEmailTemplate(){


    SchoolAdminBean schoolAdminBean = SystemUtilBean.findBean("schoolAdminBean");
    schoolUser = schoolAdminBean.getLoginnedSchoolUser() ;

    try{
        emailTemplateList = EmailTemplateDAO.getAllTemplate(schoolUser.getSchool().getSchoolID());

    }catch (Exception e){
        logger.error(e);
    }
}

public void loadTemplateDetail(){
    logger.debug("loadTemplateDetail :" +selectedTemplateID);
    try{
        emailTemplate = EmailTemplateDAO.getEmailTemplate(selectedTemplateID, schoolUser.getSchool().getSchoolID());
        logger.debug("subjectEN="+emailTemplate.getSubjectEN());

    }catch (Exception e){
        logger.error(e);
    }
}

public String updateTemplate(){
    logger.info("updateTemplate");
    try{
        EmailTemplateDAO.update(emailTemplate, schoolUser);

    }catch (Exception e){
        logger.error(e);
    }
    return "schoolInfo";

}

Thanks again ......

  • _"The attribute `update` is not defined in the component ajax."_ – Omar Jan 18 '14 at 16:49
  • Please work through the list of all possible causes in the answer of http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked and update your question accordingly. – BalusC Jan 19 '14 at 15:38

0 Answers0