在 ajax 更新上动态添加 Primefaces 调度和调度事件



我有一个命令按钮,它以表单形式接收所需的数据,然后创建一个DefaultScheduleModel以及任何DefaultScheduleEvents。然后,命令按钮应通过动态创建新选项卡和新计划以及需要创建的任何事件来更新包含 TabView 的另一个窗体。

问题是由于某种奇怪的原因,新选项卡以及相应的计划/事件不会在 ajax 更新时创建。我唯一得到的是一个带有空时间表的选项卡,其中任何后续提交都不会创建任何其他选项卡/计划/事件。

以下是我的观点:

<h:form>
<b:panel id="createSchedule" title="Create Schedule-o-matic" >
<f:facet name="append">
<b:commandButton look="danger" value="Delete" ajax="true" actionListener="#{onCallJSFBean.deleteTeamMember(teamMember)}" iconAwesome="times" icon-align="right"
update="rosterTable"/>
</f:facet>
</b:inputText>
</h:column>
</h:dataTable>
<b:commandButton value="Add Team Member" ajax="true" update="createSchedule" actionListener="#{onCallJSFBean.addTeamMember}"/>
<f:facet name="footer">
<b:buttonToolbar>
<b:buttonGroup>
<b:commandButton id='scheduleCancel' look="danger" ajax="true" value="Close" icon-awesome="window-close" update="createSchedule" 
onclick="ajax:onCallJSFBean.cancelSchedule();"
oncomplete="$('#j_id_12\:createSchedule').hide();"/>
<b:commandButton id='scheduleCreate' look="success" ajax="true" value="Submit" icon-awesome="fa-check"
actionListener="#{onCallJSFBean.createSchedule()}" update="@(.scheduleClass)"
/>
</b:buttonGroup>
</b:buttonToolbar>
</f:facet>
</b:panel>
</h:form>
<h:form class="scheduleClass">
<b:row>
<p:tabView dynamic="true" value="#{onCallJSFBean.scheduleDOs}" var="scheduleList" scrollable="true">
<p:tab title="#{scheduleList.scheduleTitle}">
<h:outputText value="#{scheduleList.startTime} #{scheduleList.endTime} #{scheduleList.scheduleModel.eventCount}"/>
</p:tab>
</p:tabView>
</b:row>
</h:form>

这是相应的控制器:

//When canceling/closing the schedule creation panel     
public void cancelSchedule(){
this.createScheduleTitle="";
this.createScheduleCycleTime = null;
this.slotStartTimePeriod = null;
this.slotEndTimePeriod = null;
this.createScheduleRoster = new ArrayList<>();
System.err.println(scheduleDOs.size());
}
public void createSchedule(){

if(submitFail == true){
this.scheduleDOs.add(createScheduleData());
System.err.println(this.scheduleDOs.size()+" Size of tab");
}
System.err.println("Finished");
}
private ScheduleDO createScheduleData(){
ScheduleModel scheduleModel = new DefaultScheduleModel();
if(createScheduleCycleTime == 1){
populateDailySchedule(scheduleModel);
}
ScheduleDO onCall = new ScheduleDO(createScheduleTitle, createScheduleCycleTime, 
slotStartTimePeriod, slotEndTimePeriod, createScheduleRoster, scheduleModel);
return onCall;
}
private int rosterCounter = 0;
private String nextTeamMember(List<SimpleStringWrapper> roster){
String tmp;
if(rosterCounter >= roster.size()){
rosterCounter=0;
tmp = roster.get(rosterCounter).getValue();
}else{
tmp = roster.get(rosterCounter).getValue();
}
rosterCounter+=1;
return tmp;
}
private void populateDailySchedule(ScheduleModel scheduleModel){
DateTime startDate = DateTime.now();
Period period = Period.months(6);
DateTime endDate = startDate.plus(period);
Days day = Days.daysBetween(startDate, endDate);
int numDays = day.getDays();
for(int i = 0;i<numDays;i++){
MutableDateTime startTime = new MutableDateTime(startDate.plusDays(i));
startTime.setHourOfDay(this.slotStartTimePeriod);
MutableDateTime endTime = new MutableDateTime(startDate.plusDays(i));
endTime.setHourOfDay(this.slotEndTimePeriod);
String teamMember = nextTeamMember(createScheduleRoster);
//      System.err.println(teamMember+" "+startTime.toDate()+" "+endTime.toDate());
DefaultScheduleEvent event = new DefaultScheduleEvent(teamMember, startTime.toDate(), endTime.toDate());
scheduleModel.addEvent(event);
}
System.err.println(scheduleModel.getEventCount());
}

我正在使用Primefaces 6.0和Bootsfaces 1.1.1

我意识到我的错误在于我更新选项卡视图/计划的方式,而不是有两个表单和针对第二个表单 ID 的提交命令按钮,而是我让提交按钮更新选项卡视图本身。

相关内容

  • 没有找到相关文章

最新更新