use of jakarta.faces.component.UIInput in project guide-jpa-intro by OpenLiberty.
the class EventBean method getUnitOfTimeOptions.
/**
* Gets 'selectOptions' for a specific unit of time from user interface
*/
private UIInput getUnitOfTimeOptions(ComponentSystemEvent event, String unit) {
UIComponent components = event.getComponent();
UIInput unitOptions = (UIInput) components.findComponent("eventform:" + unit);
return unitOptions;
}
use of jakarta.faces.component.UIInput in project myfaces by apache.
the class HtmlInputFileRendererBase method decode.
@Override
public void decode(FacesContext facesContext, UIComponent component) {
try {
String clientId = component.getClientId();
HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
Collection<Part> parts = request.getParts();
Collection<Part> submittedValues = new ArrayList<>(parts.size());
for (Part part : parts) {
if (clientId.equals(part.getName())) {
HttpPartWrapper wrapper = new HttpPartWrapper(part);
submittedValues.add(wrapper);
}
}
if (((HtmlInputFile) component).isMultiple()) {
((UIInput) component).setSubmittedValue(submittedValues);
} else if (!submittedValues.isEmpty()) {
((UIInput) component).setSubmittedValue(submittedValues.iterator().next());
}
} catch (IOException | ServletException e) {
throw new FacesException(e);
}
if (component instanceof ClientBehaviorHolder && !HtmlRendererUtils.isDisabled(component)) {
ClientBehaviorRendererUtils.decodeClientBehaviors(facesContext, component);
}
}
use of jakarta.faces.component.UIInput in project myfaces by apache.
the class RendererUtilsTest method testGetStringValue.
public void testGetStringValue() {
// Test for situation where submittedValue IS NOT String:
UIInput uiInput = new UIInput();
Object submittedValue = new Object();
uiInput.setSubmittedValue(submittedValue);
String stringValue = RendererUtils.getStringValue(facesContext, uiInput);
Assert.assertNotNull(stringValue);
Assert.assertEquals("If submittedvalue is not String, toString() must be used", submittedValue.toString(), stringValue);
}
use of jakarta.faces.component.UIInput in project myfaces by apache.
the class RendererUtilsTest method testGetConvertedUIOutputValue.
public void testGetConvertedUIOutputValue() {
UIInput uiInput = new UIInput();
StringBuilder submittedValue = new StringBuilder("submittedValue");
uiInput.setSubmittedValue(submittedValue);
Object convertedUIOutputValue = RendererUtils.getConvertedUIOutputValue(facesContext, uiInput, submittedValue);
Assert.assertEquals("If submittedvalue is not String, toString() must be used", submittedValue.toString(), convertedUIOutputValue);
}
use of jakarta.faces.component.UIInput in project myfaces by apache.
the class RendererUtilsTest method _setUpComponentStack.
private UIInput _setUpComponentStack() {
UIInput uiInput = new UIInput();
parent.getChildren().add(uiInput);
uiInput.setId("testId");
MockRenderedValueExpression ve = new MockRenderedValueExpression("#{component.id eq 'testId'}", Boolean.class, uiInput);
uiInput.setValueExpression("rendered", ve);
// simlulate that parent panel encodes children and is on the stack:
parent.pushComponentToEL(facesContext, null);
return uiInput;
}
Aggregations