我正在尝试将面板添加到我的jsf页面的主体中,它们出现在页面上,但没有一个设置正常工作,日历只显示为常规的inputText框。我是否错误地初始化我的组件或错误地添加它们?我正在制作的页面允许我点击一个按钮并将预制面板添加到我的页面。
private Date startDate;
private Date endDate;
private String Kpi;
private String baselineName;
private UIOutput body;
public void addPanel(ActionEvent event){
//UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
if(body != null){
body.getChildren().add(createCommandThroughputPanel());
log.debug("Panel Added");
}
}
public void removePanel(ActionEvent event){
if(body != null){
body.getChildren().remove(body.getChildren().size() - 1);
log.debug("Panel Removed");
}
}
public UIForm createCommandThroughputPanel(){
UIForm form = new UIForm();
//Create Panel
Panel p = new Panel();
p.setHeader("Command Throughput Data");
p.setClosable(true);
p.setToggleable(true);
p.setToggleSpeed(500);
p.setVisible(true);
log.debug("p.getToggleSpeed() = " + p.getToggleSpeed());
//Initialize startDate input calendar
Calendar startCalendar = new Calendar();
startCalendar.setValue(startDate);
startCalendar.setShowButtonPanel(true);
startCalendar.setNavigator(true);
startCalendar.setPattern("MM/dd/yyyy HH:mm");
startCalendar.setId("start");
log.debug("startCalendar.getPattern() = " + startCalendar.getPattern());
log.debug("startCalendar.getFamily() = " + startCalendar.getFamily());
//Initialize endDate input Calendar
Calendar endCalendar = new Calendar();
endCalendar.setValue(endDate);
endCalendar.setShowButtonPanel(true);
endCalendar.setNavigator(true);
endCalendar.setPattern("MM/dd/yyyy HH:mm");
endCalendar.setId("end");
log.debug("startCalendar.getPattern() = " + startCalendar.getPattern());
log.debug("endCalendar.getFamily() = " + endCalendar.getFamily());
//Initialize baseline selectOneMenu
SelectOneMenu baseline = new SelectOneMenu();
baseline.setId("baseline");
baseline.setValue(baselineName);
UISelectItems item = new UISelectItems();
p.getChildren().add((Calendar)startCalendar);
p.getChildren().add((Calendar)endCalendar);
form.getChildren().add(p);
for(UIComponent cal : p.getChildren()){
log.debug("cal.getId() = " + cal.getId());
log.debug("cal.getFamily() = " + cal.getFamily());
}
return form;
}
答案 0 :(得分:0)
为什么你不喜欢只使用一个xhtml页面而你只需写这个:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:layoutUnit position="north" size="40">
<p:commandButton value="About" onclick="PF(alert('Esprit Olap View')).show()" type="button" icon="ui-icon-power"/>
<p:commandButton align="right" value="Connect" type="button" onclick="PF('dlg3').show();" style="text-align:right" />
</p:layoutUnit>
</html>