Search in sources :

Example 31 with HtmlOutputText

use of jakarta.faces.component.html.HtmlOutputText in project faces by jakartaee.

the class Hello method apply.

@Override
public void apply(FacesContext facesContext, UIComponent root) throws IOException {
    if (!facesContext.getAttributes().containsKey(IS_BUILDING_INITIAL_STATE)) {
        return;
    }
    ComponentBuilder components = new ComponentBuilder(facesContext);
    List<UIComponent> rootChildren = root.getChildren();
    UIOutput output = new UIOutput();
    output.setValue("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
    rootChildren.add(output);
    HtmlBody body = components.create(HtmlBody.COMPONENT_TYPE);
    rootChildren.add(body);
    HtmlForm form = components.create(HtmlForm.COMPONENT_TYPE);
    form.setId("form");
    body.getChildren().add(form);
    HtmlOutputText message = components.create(HtmlOutputText.COMPONENT_TYPE);
    message.setId("message");
    form.getChildren().add(message);
    HtmlCommandButton actionButton = components.create(HtmlCommandButton.COMPONENT_TYPE);
    actionButton.setId("button");
    actionButton.addActionListener(e -> message.setValue("Hello, World"));
    actionButton.setValue("Do action");
    form.getChildren().add(actionButton);
    output = new UIOutput();
    output.setValue("</html>");
    rootChildren.add(output);
}
Also used : HtmlBody(jakarta.faces.component.html.HtmlBody) HtmlForm(jakarta.faces.component.html.HtmlForm) UIOutput(jakarta.faces.component.UIOutput) UIComponent(jakarta.faces.component.UIComponent) HtmlCommandButton(jakarta.faces.component.html.HtmlCommandButton) HtmlOutputText(jakarta.faces.component.html.HtmlOutputText)

Aggregations

HtmlOutputText (jakarta.faces.component.html.HtmlOutputText)31 UIViewRoot (jakarta.faces.component.UIViewRoot)11 Test (org.junit.Test)11 StringWriter (java.io.StringWriter)9 UIComponent (jakarta.faces.component.UIComponent)8 MockResponseWriter (org.apache.myfaces.test.mock.MockResponseWriter)8 UIColumn (jakarta.faces.component.UIColumn)7 UIOutput (jakarta.faces.component.UIOutput)7 HtmlDataTable (jakarta.faces.component.html.HtmlDataTable)7 HtmlColumn (jakarta.faces.component.html.HtmlColumn)6 HtmlInputText (jakarta.faces.component.html.HtmlInputText)6 ArrayList (java.util.ArrayList)5 UIData (jakarta.faces.component.UIData)4 HtmlCommandButton (jakarta.faces.component.html.HtmlCommandButton)4 ListDataModel (jakarta.faces.model.ListDataModel)4 ViewDeclarationLanguage (jakarta.faces.view.ViewDeclarationLanguage)4 Application (jakarta.faces.application.Application)3 FacesContext (jakarta.faces.context.FacesContext)3 HtmlRenderedAttr (org.apache.myfaces.test.utils.HtmlRenderedAttr)3 MethodExpression (jakarta.el.MethodExpression)2