请检查此表单表单数据已提交,但setAttendancedata方法正在工作。但是classname, sectionname, date没有在变量..
xhtml: <p:panel header="Attendance Entry" style="margin-top:10px">
<p:growl id="msgs" showDetail="true" />
<h:form id="attendance">
<h:panelGrid id="detail" columns="10" styleClass="grid"
cellspacing="10" cellpadding="40">
<h:outputText value="Date: " />
<h:outputText value="" id="popupDate">
<f:convertDateTime pattern="yyyy-mm-dd" />
</h:outputText>
<p:calendar value="#{StudentAttendanceComponent.date}"
id="popupCal" />
<h:outputText value="Class :" />
<p:selectOneMenu id="classname"
value="#{StudentAttendanceComponent.classname}">
<f:selectItem itemLabel="Select Class Name" itemValue="" />
<f:selectItems value="#{PreferencesClassComponent.classnames}" />
</p:selectOneMenu>
<h:outputText value="Section :" />
<p:selectOneMenu id="sectionname"
value="#{StudentAttendanceComponent.sectionname}">
<f:selectItem itemLabel="Select Section Name" itemValue="" />
<f:selectItems value="#{PreferencesSectionComponent.sectionnames}" />
</p:selectOneMenu>
<p:commandButton ajax="false" immediate="true" value="Go"
action="#{StudentAttendanceComponent.setAttendanceData}"
update="msgs" icon="ui-icon-check"></p:commandButton>
</h:panelGrid>
</h:form>
模型:
@Scope("session")
@Component("StudentAttendanceComponent")
public class StudentAttendanceComponentImpl implements
StudentAttendanceComponent {
/**
* Data type variable that provides CRUD operations for StudentAttendance
* entities
*
*/
@Autowired
StudentMasterService studentMasterService;
private Date date = new Date();
private String[] attData;
private StudentAttendance studentattendance;
private String classname;
private String sectionname;
private List<StudentAttendance> studentAttendances;
@Autowired
private StudentAttendanceDAO studentAttendanceDAO;
/**
* Service injected by Spring that provides CRUD operations for
* StudentAttendance entities
*
*/
@Autowired
private StudentAttendanceService studentAttendanceService;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getClassname() {
return classname;
}
public void setClassname(String classname) {
this.classname = classname;
}
public String getSectionname() {
return sectionname;
}
public void setSectionname(String sectionname) {
this.sectionname = sectionname;
}
public void setAttendanceData() {
// TODO Auto-generated method stub
System.out.println(classname+sectionname);
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,
"Filter Data", "Class " + classname + ", section " + sectionname+", date " + getDate().getDate());
FacesContext.getCurrentInstance().addMessage("msgs", msg);
}
问题是,您在p:commandButton
中设置了immediate="true"
属性。由于这个属性,几个JSF生命周期被跳过。
查看这些链接:
- http://docs.oracle.com/javaee/1.4/tutorial/doc/JSFIntro10.html
- http://balusc.blogspot.co.at/2006/09/debug-jsf-lifecycle.html AddImmediateTrueToUICommandOnly
- http://balusc.blogspot.co.at/2006/09/debug-jsf-lifecycle.html WhenShouldIUseTheImmediateAttribute