throws Exception {
DoSelectInputTestHelper helper = new DoSelectInputTestHelper();
XFSelectAttributes atts = helper.buildSelectAttributes();
Styles styles = atts.getStyles();
MutablePropertyValues propertyValues = styles.getPropertyValues();
if(!multiSelect) {
for(int i=0; i<selectedOtions.length; i++) {
if(selectedOtions[i]) {
atts.setInitial("Value" + (i+1));
break;
}
}
}
atts.setMultiple(multiSelect);
//atts.setTabindex(tabIndex);
// add some options
helper.addOption(atts, "Caption1", "Prompt1", "Value1",
selectedOtions[0]);
helper.addOption(atts, "Caption2", "Prompt2", "Value2",
selectedOtions[1]);
SelectOptionGroup group = null;
String caption, prompt;
int count = 0;
do {
caption = "Group" + (count + 1);
prompt = "Prompt" + (count + 1);
if(0 == count) {
group = helper.addOptionGroup(atts, caption, prompt);;
} else {
group = helper.addOptionGroup(group, caption, prompt);
}
} while(++count < optGroupCount);
helper.addOption(group, "Caption3", "Prompt3", "Value3",
selectedOtions[2]);
//protocol.addStyleMapping(atts, style);
TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();
propertyValues.setComputedValue(
StylePropertyDetails.MCS_SELECTION_LIST_STYLE,
MCSSelectionListStyleKeywords.CONTROLS);
propertyValues.setComputedValue(
StylePropertyDetails.MCS_SELECTION_LIST_OPTION_LAYOUT,
rightAlignCaption ? MCSSelectionListOptionLayoutKeywords.CONTROL_FIRST
: MCSSelectionListOptionLayoutKeywords.CAPTION_FIRST);
propertyValues.setComputedValue(
StylePropertyDetails.MCS_MENU_ORIENTATION,
vertical ? MCSMenuOrientationKeywords.VERTICAL
: MCSMenuOrientationKeywords.HORIZONTAL);
TestMarinerPageContext testPageContext =
(TestMarinerPageContext)protocol.getMarinerPageContext();
testPageContext.setFormFragmentResetState(true);
testable.setCurrentBuffer(atts.getEntryContainerInstance(), buffer);
String type = (multiSelect) ? "checkbox" : "radio";
String seperator = (vertical) ? "<br/>" : "\u00a0";
StringBuffer sb = new StringBuffer();
sb.append("<div ");
sb.append("id=\"" + atts.getId() + "\">");
for (int i=0; i<3; i++) {
if(i > 0) {
sb.append(seperator);
}
if (!rightAlignCaption) {
sb.append("Caption").append(i+1);
}
sb.append("<input ");
if(selectedOtions[i]) {
sb.append("checked=\"checked\" ");
}
sb.append("id=\"OptionId\" ");
sb.append("name=\"").append(atts.getName()).append("\" ");
sb.append("title=\"").append("Prompt").append(i+1).append("\" ");
sb.append("type=\"").append(type).append("\" ");
sb.append("value=\"").append("Value").append(i+1).append("\"/>");
if(rightAlignCaption) {
sb.append("Caption").append(i+1);