super.start(tag, attr);
final ElementSpec spec = getLastSpec();
assert spec != null : "we've just created a spec in super.start()";
FormElement model = null;
final MutableAttributeSet specAttr = (MutableAttributeSet)spec.getAttributes();
if (Tag.INPUT.equals(tag)) {
model = handleInput(attr, specAttr);
} else if (Tag.TEXTAREA.equals(tag)) {
model = new FormTextModel(getCurrentForm(), attr);
openedBlocks.add(Tag.TEXTAREA);
} else if (Tag.BUTTON.equals(tag)) {
model = new FormButtonModel(getCurrentForm(), attr);
openedBlocks.add(Tag.BUTTON);
} else if (Tag.LEGEND.equals(tag)) {
openedBlocks.add(Tag.LEGEND);
if (openedBlocks.contains(Tag.FIELDSET)) {
handleLegend(null, specAttr);
}
} else if (Tag.FIELDSET.equals(tag)) {
model = new FormFieldsetModel(getCurrentForm(), attr);
openedBlocks.add(Tag.FIELDSET);
} else if (Tag.SELECT.equals(tag)) {
if (FormAttributes.isListSelect(specAttr)) {
selectModel = new FormSelectListModel(getCurrentForm(), attr);
} else {
selectModel = new FormSelectComboBoxModel(getCurrentForm(), attr);
}
model = selectModel;
openedBlocks.add(Tag.SELECT);
}
if (model != null) {
specAttr.addAttribute(StyleConstants.ModelAttribute, model);
assert currentForm != null : "creating model with getCurrentForm() in constructor assures this";
currentForm.addElement(model);
}
}