Search in sources :

Example 1 with UIInput

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;
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UIInput(jakarta.faces.component.UIInput)

Example 2 with UIInput

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);
    }
}
Also used : HtmlInputFile(jakarta.faces.component.html.HtmlInputFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ClientBehaviorHolder(jakarta.faces.component.behavior.ClientBehaviorHolder) UIInput(jakarta.faces.component.UIInput) FacesException(jakarta.faces.FacesException) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) ServletException(jakarta.servlet.ServletException) HttpPartWrapper(org.apache.myfaces.renderkit.html.util.HttpPartWrapper) Part(jakarta.servlet.http.Part)

Example 3 with UIInput

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);
}
Also used : UIInput(jakarta.faces.component.UIInput)

Example 4 with UIInput

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);
}
Also used : UIInput(jakarta.faces.component.UIInput)

Example 5 with UIInput

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;
}
Also used : UIInput(jakarta.faces.component.UIInput)

Aggregations

UIInput (jakarta.faces.component.UIInput)205 UIViewRoot (jakarta.faces.component.UIViewRoot)92 PrintWriter (java.io.PrintWriter)90 FacesContext (jakarta.faces.context.FacesContext)68 Test (org.junit.Test)63 UIComponent (jakarta.faces.component.UIComponent)48 ServletException (jakarta.servlet.ServletException)31 IOException (java.io.IOException)31 TCKValueChangeListener (com.sun.ts.tests.jsf.api.jakarta_faces.component.common.TCKValueChangeListener)21 ELContext (jakarta.el.ELContext)18 NumberConverter (jakarta.faces.convert.NumberConverter)18 ValueChangeEvent (jakarta.faces.event.ValueChangeEvent)18 ParseException (java.text.ParseException)18 MethodExpression (jakarta.el.MethodExpression)16 UINamingContainer (jakarta.faces.component.UINamingContainer)16 ValidatorException (jakarta.faces.validator.ValidatorException)16 UIOutput (jakarta.faces.component.UIOutput)15 TCKValidator (com.sun.ts.tests.jsf.api.jakarta_faces.component.common.TCKValidator)13 TestBean (com.sun.ts.tests.jsf.common.beans.TestBean)13 MethodExpressionValidator (jakarta.faces.validator.MethodExpressionValidator)13