boolean bIsExclusive = getObligation().equalsIgnoreCase(Section.OBLIGATION_EXCLUSIVE);
boolean bIsOptional = getObligation().equalsIgnoreCase(Section.OBLIGATION_OPTIONAL);
HtmlPanelGroup panel = new HtmlPanelGroup();
panel.setStyleClass("section");
MessageBroker msgBroker = context.extractMessageBroker();
// determine the caption
String sCaption = "";
if (getLabel() != null) {
sCaption = msgBroker.retrieveMessage(getLabel().getResourceKey());
}
if (sCaption.length() == 0) {
sCaption = getKey();
}
StringBuffer sbOnclick = new StringBuffer();
sbOnclick.append("mdeOnSectionClicked(");
sbOnclick.append("this,").append(bIsOptional).append(",").append(bIsExclusive);
sbOnclick.append(",'").append(sSectionId).append("')");
// add the caption
if (bIsExclusive) {
Sections exclusive = getExclusiveSiblings(schema);
boolean bIsFirstExclusive = (exclusive.size() > 0) &&
(this == exclusive.values().iterator().next());
if (bIsFirstExclusive) {
HtmlSelectOneRadio radio = new HtmlSelectOneRadio();
radio.setId(sRadioId);
radio.setStyleClass("optionalSectionHeader");
radio.setOnclick(sbOnclick.toString());
ArrayList<SelectItem> radioItems = new ArrayList<SelectItem>();
UISelectItems uiItems = new UISelectItems();
uiItems.setValue(radioItems);
radio.getChildren().add(uiItems);
panel.getChildren().add(radio);
int nIdx = 0;
for (Section sibling: exclusive.values()) {
String sItemLabel = "";
String sItemId = sibling.getFacesId();
if (sibling.getLabel() != null) {
sItemLabel = msgBroker.retrieveMessage(sibling.getLabel().getResourceKey());
}
if (sItemLabel.length() == 0) {
sItemLabel = sibling.getKey();
}
radioItems.add(new SelectItem(sItemId,sItemLabel));
if (sibling.getOpen()) {
radio.setValue(sItemId);
}
nIdx++;
}
}
} else if (bIsOptional) {
HtmlPanelGroup captionPanel = new HtmlPanelGroup();
captionPanel.setStyleClass("optionalSectionHeader");
HtmlPanelGrid headerTable = new HtmlPanelGrid();
headerTable.setColumns(2);
headerTable.setStyleClass("optionalSectionHeader");
headerTable.setSummary(msgBroker.retrieveMessage("catalog.general.designOnly"));
HtmlSelectBooleanCheckbox checkBox = new HtmlSelectBooleanCheckbox();
checkBox.setId(sCheckboxId);
checkBox.setSelected(getOpen());
checkBox.setOnclick(sbOnclick.toString());
headerTable.getChildren().add(checkBox);
HtmlOutputLabel caption = new HtmlOutputLabel();
// even label has to have unique id (for GlassFish)
caption.setId(sCheckboxId+"label");
caption.setFor(sCheckboxId);
caption.setValue(sCaption);
caption.setStyleClass("sectionCaption");
headerTable.getChildren().add(caption);
panel.getChildren().add(headerTable);
} else {
HtmlPanelGrid headerTable = new HtmlPanelGrid();
headerTable.setColumns(3);
headerTable.setStyleClass("mandatorySectionHeader");
headerTable.setSummary(msgBroker.retrieveMessage("catalog.general.designOnly"));
headerTable.setOnclick(sbOnclick.toString());
HtmlSelectBooleanCheckbox checkBox = new HtmlSelectBooleanCheckbox();
checkBox.setId(sCheckboxId);
checkBox.setSelected(getOpen());
//checkBox.setOnclick(sbOnclick.toString());
checkBox.setStyle("display:none;");
headerTable.getChildren().add(checkBox);
HtmlGraphicImage img = new HtmlGraphicImage();
img.setId(sImgId);
setGraphicUrl(img);
headerTable.getChildren().add(img);
HtmlOutputText caption = new HtmlOutputText();
caption.setValue(sCaption);
caption.setStyleClass("sectionCaption");
headerTable.getChildren().add(caption);
if (getLabel() != null) {
panel.getChildren().add(headerTable);
} else {
panel.setStyleClass("");
}
}
// make the section body
boolean bContainerOnly = (getLabel() == null);
String sBodyClass = "sectionBody";
if (bContainerOnly) sBodyClass= "";
HtmlPanelGrid sectionBody = new HtmlPanelGrid();
sectionBody.setId(sBodyId);
sectionBody.setStyleClass(sBodyClass);
setBodyDisplay(sectionBody);
panel.getChildren().add(sectionBody);
// make the table to hold section parameters, add all parameters
HtmlPanelGrid parametersTable = new HtmlPanelGrid();
parametersTable.setId(sParamsId);
parametersTable.setColumns(2);
parametersTable.setStyleClass("parameters");
parametersTable.setColumnClasses("parameterLabel,parameterInput");
parametersTable.setSummary(msgBroker.retrieveMessage("catalog.general.designOnly"));
for (Parameter parameter: getParameters().values()) {
if (parameter.getVisible()) {
UIComponent cmpLabel = null;
if (parameter.getLabel() != null) {
cmpLabel = parameter.getLabel().makeEditorLabel(context,this,parameter);