我的DefaultScheduleEvent创建如下:
DefaultScheduleEvent newResourceEvent = new DefaultScheduleEvent(reason, dteBeginOrWaitingItem, dteEndOrWaitingItem, orWaitinglist);
orWaitinglist
是一个对象,它包含值和更多对象。
现在如何在JSF
页面中访问此对象。
Primefaces演示显示您可以访问事件对象,如下所示。但是,如何将对象orWaitinglist
的值放在p:inputText
- 字段中。
<p:inputText id="title" value="#{scheduleController.event.data}" required="true"/>
DefaultScheduleEvent.java
public DefaultScheduleEvent(String title, Date start, Date end, Object data) {
this.title = title;
this.startDate = start;
this.endDate = end;
this.data = data;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
ScheduleController.java
public ScheduleEvent getEvent() {
return event;
}
public void setEvent(ScheduleEvent event) {
this.event = event;
}
OrWaitinglist.java
public OrWaitinglist(BigDecimal WKey, Patients patients, OrBaseLists orBaseListsByWPriority, String WDescription, int WState, Date WDateInserted, Date WDateModified, String WModifiedBy, byte WPlannedType, boolean WCanBeScheduled) {
this.WKey = WKey;
this.patients = patients;
this.orBaseListsByWPriority = orBaseListsByWPriority;
this.WDescription = WDescription;
this.WState = WState;
this.WDateInserted = WDateInserted;
this.WDateModified = WDateModified;
this.WModifiedBy = WModifiedBy;
this.WPlannedType = WPlannedType;
this.WCanBeScheduled = WCanBeScheduled;
}
答案 0 :(得分:1)
您可以使用标准JSF表示法语法访问自定义对象。只需确保您的对象具有需要访问的字段的setter和getter。然后,您可以传入或创建一个新对象到DefaultScheduleEvent并从表示层访问它。
DefaultScheduleEvent newResourceEvent = new DefaultScheduleEvent(reason, dteBeginOrWaitingItem, dteEndOrWaitingItem, new OrWaitinglist();
使用默认构造函数
然后,JSF页面可以使用:
访问它<p:inputText value="#{scheduleController.event.data.WKey}"/>
<强> NB。按照惯例,您的变量应以小写字母开头! ( WKey 写得更好 wKey )