public AddNodeWindow(AbstractQuestionRelation p) { this.setParent(p); // create ui from template Executions.createComponents("/WEB-INF/zk/survey/design/AddNodeWindow.zul", this, null); Selectors.wireVariables(this, this, Selectors.newVariableResolvers(getClass(), Div.class)); Selectors.wireComponents(this, this, false); Selectors.wireEventListeners(this, this); // type box and default selection ntds = nodeRO.getNodeTypeDescriptions(); ListModelList<String> typeModel = new ListModelList<String>(); for (Map<String, String> ntd : ntds) { String nodeTypeLabel = ntd.get("label"); typeModel.add(nodeTypeLabel); } String defaultContactType = p.getQuestion().getDefaultNewContactType(); if (defaultContactType != null) { Map<String, String> ntd = GeneralUtil.getNodeDescription(ntds, defaultContactType); if (ntd != null) { String nodeTypeLabel = ntd.get("label"); typeModel.addToSelection(nodeTypeLabel); } } typeBox.setModel(typeModel); onNodeTypeChanged(); this.setWidth("200px"); this.setVflex("1"); this.setClosable(true); }
/** * *********************************************************** Create * *********************************************************** */ @SuppressWarnings("rawtypes") private void onNodeTypeChanged() { ListModelList typeModel = (ListModelList) typeBox.getModel(); Set selections = typeModel.getSelection(); if (selections.isEmpty()) return; String selection = (String) selections.iterator().next(); logger.info("Node type set to: " + selection); Map<String, String> ntd = GeneralUtil.getNodeDescriptionByLabel(ntds, selection); String nodeType = ntd.get("type"); if (nodeType.equals(Constants.NODE_TYPE_USER)) { firstNameRow.setVisible(true); firstNameBox.setConstraint("no empty"); lastNameRow.setVisible(true); lastNameBox.setConstraint("no empty"); midNameRow.setVisible(true); } else { firstNameRow.setVisible(false); firstNameBox.setConstraint(""); lastNameRow.setVisible(false); lastNameBox.setConstraint(""); midNameRow.setVisible(false); } }