Search in sources :

Example 1 with HtmlPanelGroup

use of jakarta.faces.component.html.HtmlPanelGroup in project guide-jpa-intro by OpenLiberty.

the class EventBean method addErrorMessage.

/**
 * Adds "Choose a valid time" message after selectOptions in user interface.
 */
private void addErrorMessage(ComponentSystemEvent event, String errorMessage) {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message = new FacesMessage(errorMessage);
    HtmlPanelGroup divEventTime = (HtmlPanelGroup) event.getComponent().findComponent("eventform:eventTime");
    context.addMessage(divEventTime.getClientId(context), message);
}
Also used : FacesContext(jakarta.faces.context.FacesContext) HtmlPanelGroup(jakarta.faces.component.html.HtmlPanelGroup) FacesMessage(jakarta.faces.application.FacesMessage)

Example 2 with HtmlPanelGroup

use of jakarta.faces.component.html.HtmlPanelGroup in project myfaces by apache.

the class HtmlGroupRendererTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    servletContext.addInitParameter(MyfacesConfig.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING, "true");
    panelGroup = new HtmlPanelGroup();
    HtmlOutputText panelChildOutputText = new HtmlOutputText();
    panelChildOutputText.setValue(PANEL_CHILD_TEXT);
    panelGroup.getChildren().add(panelChildOutputText);
    writer = new MockResponseWriter(new StringWriter(), null, null);
    facesContext.setResponseWriter(writer);
    facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
    facesContext.getRenderKit().addRenderer(panelGroup.getFamily(), panelGroup.getRendererType(), new HtmlGroupRenderer());
    facesContext.getRenderKit().addRenderer(panelChildOutputText.getFamily(), panelChildOutputText.getRendererType(), new HtmlTextRenderer());
    facesContext.getRenderKit().addClientBehaviorRenderer(AjaxBehavior.BEHAVIOR_ID, new HtmlAjaxBehaviorRenderer());
    facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
Also used : StringWriter(java.io.StringWriter) HtmlPanelGroup(jakarta.faces.component.html.HtmlPanelGroup) MockResponseWriter(org.apache.myfaces.test.mock.MockResponseWriter) HtmlOutputText(jakarta.faces.component.html.HtmlOutputText)

Example 3 with HtmlPanelGroup

use of jakarta.faces.component.html.HtmlPanelGroup in project myfaces by apache.

the class SimpleRequestBean method getPanel3.

/**
 * @return the panel3
 */
public HtmlPanelGroup getPanel3() {
    if (panel3 == null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ViewDeclarationLanguage vdl = facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(facesContext, facesContext.getViewRoot().getViewId());
        panel3 = new HtmlPanelGroup();
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put("src", "/staticPageBinding3_1.xhtml");
        UIComponent component = vdl.createComponent(facesContext, "http://java.sun.com/jsf/facelets", "include", attributes);
        panel3.getChildren().add(component);
    }
    return panel3;
}
Also used : FacesContext(jakarta.faces.context.FacesContext) HashMap(java.util.HashMap) UIComponent(jakarta.faces.component.UIComponent) HtmlPanelGroup(jakarta.faces.component.html.HtmlPanelGroup) ViewDeclarationLanguage(jakarta.faces.view.ViewDeclarationLanguage)

Example 4 with HtmlPanelGroup

use of jakarta.faces.component.html.HtmlPanelGroup in project myfaces by apache.

the class SimpleRequestBean method getPanel4.

/**
 * @return the panel4
 */
public HtmlPanelGroup getPanel4() {
    if (panel4 == null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ViewDeclarationLanguage vdl = facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(facesContext, facesContext.getViewRoot().getViewId());
        panel4 = new HtmlPanelGroup();
        Map<String, Object> attributes = new HashMap<String, Object>();
        UIComponent cc = vdl.createComponent(facesContext, "http://java.sun.com/jsf/composite/testComposite", "dynComp_1", attributes);
        UIOutput text = (UIOutput) facesContext.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
        text.setValue("Dynamically added header");
        cc.getFacets().put("header", text);
        panel4.getChildren().add(cc);
    }
    return panel4;
}
Also used : FacesContext(jakarta.faces.context.FacesContext) HashMap(java.util.HashMap) UIOutput(jakarta.faces.component.UIOutput) UIComponent(jakarta.faces.component.UIComponent) HtmlPanelGroup(jakarta.faces.component.html.HtmlPanelGroup) ViewDeclarationLanguage(jakarta.faces.view.ViewDeclarationLanguage)

Example 5 with HtmlPanelGroup

use of jakarta.faces.component.html.HtmlPanelGroup in project myfaces by apache.

the class ComponentBindingVDLBean2 method getPanel.

public UIPanel getPanel() {
    if (panel == null) {
        panel = new HtmlPanelGroup();
        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (facesContext.isPostback()) {
            // Just try to mess the binding. In theory this does
            // not have effect, because the binding with children
            // or facets should be restored fully.
            UIOutput out2 = new UIOutput();
            out2.setValue("hello2");
            panel.getChildren().add(out2);
        }
        UIOutput out = new UIOutput();
        out.setValue("hello1");
        panel.getChildren().add(out);
        ViewDeclarationLanguage vdl = facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(facesContext, facesContext.getViewRoot().getViewId());
        Map<String, Object> attributes = new HashMap<String, Object>();
        UIComponent cc = vdl.createComponent(facesContext, "http://java.sun.com/jsf/composite/testComposite", "dynComp_1", attributes);
        cc.setId("ccpanel");
        Map<String, Object> attributes2 = new HashMap<String, Object>();
        UIComponent text = (UIComponent) vdl.createComponent(facesContext, "http://java.sun.com/jsf/composite/testComposite", "dynComp_2", attributes2);
        text.setId("component");
        cc.getFacets().put("header", text);
        panel.getChildren().add(cc);
        if (!facesContext.isPostback()) {
            // Store something into the state
            panel.getAttributes().put("attr1", "value1");
            panel.getChildren().get(0).getAttributes().put("attr2", "value2");
        } else {
            // Try to mess the state, in theory it should not have effect
            panel.getAttributes().remove("attr1");
            panel.getChildren().get(0).getAttributes().remove("attr2");
        }
    }
    return panel;
}
Also used : FacesContext(jakarta.faces.context.FacesContext) UIOutput(jakarta.faces.component.UIOutput) HashMap(java.util.HashMap) UIComponent(jakarta.faces.component.UIComponent) HtmlPanelGroup(jakarta.faces.component.html.HtmlPanelGroup) ViewDeclarationLanguage(jakarta.faces.view.ViewDeclarationLanguage)

Aggregations

HtmlPanelGroup (jakarta.faces.component.html.HtmlPanelGroup)17 UIOutput (jakarta.faces.component.UIOutput)12 UIComponent (jakarta.faces.component.UIComponent)11 FacesContext (jakarta.faces.context.FacesContext)11 ViewDeclarationLanguage (jakarta.faces.view.ViewDeclarationLanguage)9 HashMap (java.util.HashMap)9 HtmlOutputText (jakarta.faces.component.html.HtmlOutputText)2 FacesMessage (jakarta.faces.application.FacesMessage)1 UIColumn (jakarta.faces.component.UIColumn)1 UIData (jakarta.faces.component.UIData)1 HtmlInputText (jakarta.faces.component.html.HtmlInputText)1 VisitCallback (jakarta.faces.component.visit.VisitCallback)1 VisitContext (jakarta.faces.component.visit.VisitContext)1 VisitHint (jakarta.faces.component.visit.VisitHint)1 ResponseWriter (jakarta.faces.context.ResponseWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 MockResponseWriter (org.apache.myfaces.test.mock.MockResponseWriter)1