String sBodyId = sSectionId+"-body";
String sParamsId = sSectionId+"-params";
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();
// return if there is nothing to display
if ((bIsExclusive || bIsOptional) && !getOpen()) {
return false;
}
// determine the caption
String sCaption = "";
if (getLabel() != null) {
sCaption = msgBroker.retrieveMessage(getLabel().getResourceKey());
}
if (sCaption.length() == 0) {
sCaption = getKey();
}
// make the header
StringBuffer sbOnclick = new StringBuffer();
sbOnclick.append("mddOnSectionClicked('").append(sSectionId).append("')");
HtmlPanelGrid headerTable = new HtmlPanelGrid();
headerTable.setColumns(3);
headerTable.setStyleClass("sectionHeader");
headerTable.setSummary(msgBroker.retrieveMessage("catalog.general.designOnly"));
headerTable.setOnclick(sbOnclick.toString());
HtmlSelectBooleanCheckbox checkBox = new HtmlSelectBooleanCheckbox();
checkBox.setId(sCheckboxId);
checkBox.setSelected(getOpen());
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.setSummary(msgBroker.retrieveMessage("catalog.general.designOnly"));
boolean hasMap = false;
for (Parameter parameter: getParameters().values()) {
HtmlOutputText cmpLabel = null;
UIComponent cmpValue = null;
// check for a binary thumbnail
if (parameter.getMeaningType().equalsIgnoreCase(Meaning.MEANINGTYPE_THUMBNAIL_URL)) {
if (schema.getMeaning().getThumbnailUrl().length() == 0) {
String uuid = Val.chkStr(context.extractHttpServletRequest().getParameter("uuid"));
if ((uuid.length() > 0) && (schema.getMeaning().getThumbnailBinary().length() > 0)) {
try {
String thumbUrl = "/thumbnail?uuid="+URLEncoder.encode(uuid,"UTF-8");
parameter.getContent().getSingleValue().setValue(thumbUrl);
} catch (UnsupportedEncodingException e) {}
}
}
}
boolean bDisplay = parameter.getVisible() && parameter.getVisibleOnDetails() &&
!parameter.getContent().isValueEmpty() &&
(parameter.getInput() != null);
if ((parameter.getInput() instanceof InputMap)) {
cmpValue = parameter.getInput().makeOutputComponent(context,this,parameter);
if (cmpValue != null) {
parametersTable.getChildren().add(cmpValue);
hasMap = true;
}
} else if (bDisplay) {
cmpValue = parameter.getInput().makeOutputComponent(context,this,parameter);
if (cmpValue != null) {
cmpLabel = new HtmlOutputText();
cmpLabel.setValue(msgBroker.retrieveMessage(parameter.getLabel().getResourceKey()));
parametersTable.getChildren().add(cmpLabel);
parametersTable.getChildren().add(cmpValue);
}
}
}
parametersTable.setColumnClasses(hasMap? ",parameterValue": "parameterLabel,parameterValue");
if (parametersTable.getChildCount() > 0) {
bHadParameters = true;
sectionBody.getChildren().add(parametersTable);
}
// append all sub-sections
for (Section section: getSections().values()) {
boolean bHadSubParams = section.appendDetailComponents(schema,context,sectionBody);
if (bHadSubParams) bHadParameters = true;
}
if (!bHadParameters) panel.setRendered(false);
if ((panel != null) && (panel.getChildCount() > 0) && panel.isRendered()) {
parentComponent.getChildren().add(panel);
}
return bHadParameters;
}