use of jakarta.faces.component.UISelectMany in project myfaces by apache.
the class HtmlRendererUtils method getSubmittedOrSelectedValuesAsSet.
public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent uiComponent, FacesContext facesContext, Converter converter) {
Set lookupSet;
if (selectMany) {
UISelectMany uiSelectMany = (UISelectMany) uiComponent;
lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
if (lookupSet == null) {
lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
}
} else {
UISelectOne uiSelectOne = (UISelectOne) uiComponent;
Object lookup = uiSelectOne.getSubmittedValue();
if (lookup == null) {
lookup = uiSelectOne.getValue();
String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup);
lookupSet = Collections.singleton(lookupString);
} else if (RendererUtils.EMPTY_STRING.equals(lookup)) {
lookupSet = Collections.EMPTY_SET;
} else {
lookupSet = Collections.singleton(lookup);
}
}
return lookupSet;
}
use of jakarta.faces.component.UISelectMany in project myfaces by apache.
the class _SharedRendererUtilsTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
uiSelectMany = new UISelectMany();
submittedValue = new String[] { "1", "2" };
}
use of jakarta.faces.component.UISelectMany in project myfaces by apache.
the class UISelectManyTest method testValidateRequiredNull.
@Test
public void testValidateRequiredNull() {
facesContext.getViewRoot().setLocale(_TEST_LOCALE);
UISelectMany selectMany = new UISelectMany();
selectMany.setId("selectMany");
selectMany.setRendererType(null);
selectMany.setRequired(true);
List<UIComponent> children = selectMany.getChildren();
UISelectItem one = new UISelectItem();
one.setItemValue(new Integer(1));
children.add(one);
UISelectItem two = new UISelectItem();
two.setItemValue(new Integer(2));
children.add(two);
UISelectItem three = new UISelectItem();
three.setItemValue(new Integer(3));
children.add(three);
selectMany.validateValue(facesContext, null);
Assert.assertFalse(selectMany.isValid());
}
use of jakarta.faces.component.UISelectMany in project myfaces by apache.
the class UISelectManyTest method testValidateRequiredEmptyList.
@Test
public void testValidateRequiredEmptyList() {
facesContext.getViewRoot().setLocale(_TEST_LOCALE);
UISelectMany selectMany = new UISelectMany();
selectMany.setId("selectMany");
selectMany.setRendererType(null);
selectMany.setRequired(true);
List<UIComponent> children = selectMany.getChildren();
UISelectItem one = new UISelectItem();
one.setItemValue(new Integer(1));
children.add(one);
UISelectItem two = new UISelectItem();
two.setItemValue(new Integer(2));
children.add(two);
UISelectItem three = new UISelectItem();
three.setItemValue(new Integer(3));
children.add(three);
selectMany.validateValue(facesContext, Collections.EMPTY_LIST);
Assert.assertFalse(selectMany.isValid());
}
use of jakarta.faces.component.UISelectMany in project myfaces by apache.
the class HtmlCheckboxRendererBase method encodeEnd.
@Override
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
if (uiComponent instanceof UISelectBoolean) {
ResponseWriter writer = facesContext.getResponseWriter();
writer.endElement(HTML.INPUT_ELEM);
} else if (uiComponent instanceof UISelectMany) {
renderCheckboxList(facesContext, (UISelectMany) uiComponent);
} else {
throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName());
}
}
Aggregations