Search in sources :

Example 1 with UIOut

use of org.apache.myfaces.tobago.component.UIOut in project myfaces-tobago by apache.

the class AbstractTobagoTestBase method setUp.

/**
 * <p>Set up instance variables required by Tobago test cases.</p>
 */
@Override
@BeforeEach
public void setUp() throws Exception {
    super.setUp();
    stringWriter = new StringWriter();
    getFacesContext().setResponseWriter(new HtmlResponseWriter(stringWriter, "", StandardCharsets.UTF_8));
    // Tobago specific extensions
    final TobagoConfig tobagoConfig = new TobagoConfig((ServletContext) facesContext.getExternalContext().getContext(), "tobago-config-for-unit-tests.xml");
    servletContext.setAttribute(TOBAGO_CONFIG, tobagoConfig);
    facesContext.getExternalContext().getApplicationMap().put(TOBAGO_CONFIG, tobagoConfig);
    final TobagoContext tobagoContext = new TobagoContext();
    tobagoContext.setTheme(tobagoConfig.getDefaultTheme());
    facesContext.getViewRoot().setLocale(Locale.ENGLISH);
    request.setAttribute(TobagoContext.BEAN_NAME, tobagoContext);
    // XXX is there a better way? Get it from Tobagos generated faces-config.xml?
    application.addComponent(Tags.badge.componentType(), UIBadge.class.getName());
    application.addComponent(Tags.bar.componentType(), UIBar.class.getName());
    application.addComponent(Tags.box.componentType(), UIBox.class.getName());
    application.addComponent(Tags.button.componentType(), UIButton.class.getName());
    application.addComponent(Tags.buttons.componentType(), UIButtons.class.getName());
    application.addComponent(Tags.date.componentType(), UIDate.class.getName());
    application.addComponent(Tags.column.componentType(), UIColumn.class.getName());
    application.addComponent(Tags.file.componentType(), UIFile.class.getName());
    application.addComponent(Tags.gridLayout.componentType(), UIGridLayout.class.getName());
    application.addComponent(Tags.in.componentType(), UIIn.class.getName());
    application.addComponent(Tags.link.componentType(), UILink.class.getName());
    application.addComponent(Tags.links.componentType(), UILinks.class.getName());
    application.addComponent(Tags.out.componentType(), UIOut.class.getName());
    application.addComponent(Tags.panel.componentType(), UIPanel.class.getName());
    application.addComponent(Tags.popup.componentType(), UIPopup.class.getName());
    application.addComponent(Tags.range.componentType(), UIRange.class.getName());
    application.addComponent(Tags.section.componentType(), UISection.class.getName());
    application.addComponent(Tags.segmentLayout.componentType(), UISegmentLayout.class.getName());
    application.addComponent(Tags.selectItem.componentType(), UISelectItem.class.getName());
    application.addComponent(Tags.selectBooleanCheckbox.componentType(), UISelectBooleanCheckbox.class.getName());
    application.addComponent(Tags.selectBooleanToggle.componentType(), UISelectBooleanToggle.class.getName());
    application.addComponent(Tags.selectManyCheckbox.componentType(), UISelectManyCheckbox.class.getName());
    application.addComponent(Tags.selectManyListbox.componentType(), UISelectManyListbox.class.getName());
    application.addComponent(Tags.selectManyShuttle.componentType(), UISelectManyShuttle.class.getName());
    application.addComponent(Tags.selectOneRadio.componentType(), UISelectOneRadio.class.getName());
    application.addComponent(Tags.selectOneChoice.componentType(), UISelectOneChoice.class.getName());
    application.addComponent(Tags.selectReference.componentType(), UISelectReference.class.getName());
    application.addComponent(Tags.separator.componentType(), UISeparator.class.getName());
    application.addComponent(Tags.sheet.componentType(), UISheet.class.getName());
    application.addComponent(Tags.style.componentType(), UIStyle.class.getName());
    application.addComponent(Tags.tab.componentType(), UITab.class.getName());
    application.addComponent(Tags.tabGroup.componentType(), UITabGroup.class.getName());
    application.addComponent(Tags.textarea.componentType(), UITextarea.class.getName());
    application.addComponent(Tags.tree.componentType(), UITree.class.getName());
    application.addComponent(Tags.treeNode.componentType(), UITreeNode.class.getName());
    application.addComponent(Tags.treeIndent.componentType(), UITreeIndent.class.getName());
    application.addComponent(Tags.treeSelect.componentType(), UITreeSelect.class.getName());
    application.addBehavior(AjaxBehavior.BEHAVIOR_ID, AjaxBehavior.class.getName());
    application.addBehavior(EventBehavior.BEHAVIOR_ID, EventBehavior.class.getName());
    application.addConverter(Date.class, DateTimeConverter.class.getName());
    application.addConverter("jakarta.faces.DateTime", DateTimeConverter.class.getName());
    final RenderKit renderKit = facesContext.getRenderKit();
    renderKit.addRenderer(UIBadge.COMPONENT_FAMILY, RendererTypes.BADGE, new BadgeRenderer<UIBadge>());
    renderKit.addRenderer(UIBar.COMPONENT_FAMILY, RendererTypes.BAR, new BarRenderer<UIBar>());
    renderKit.addRenderer(UIBox.COMPONENT_FAMILY, RendererTypes.BOX, new BoxRenderer<UIBox>());
    renderKit.addRenderer(UIButton.COMPONENT_FAMILY, RendererTypes.BUTTON, new ButtonRenderer<UIButton>());
    renderKit.addRenderer(UIButtons.COMPONENT_FAMILY, RendererTypes.BUTTONS, new ButtonsRenderer<UIButtons>());
    renderKit.addRenderer(UIColumn.COMPONENT_FAMILY, RendererTypes.COLUMN, new ColumnRenderer<UIColumn>());
    renderKit.addRenderer(UIDate.COMPONENT_FAMILY, RendererTypes.DATE, new DateRenderer<UIDate>());
    renderKit.addRenderer(UIFile.COMPONENT_FAMILY, RendererTypes.FILE, new FileRenderer<UIFile>());
    renderKit.addRenderer(UIGridLayout.COMPONENT_FAMILY, RendererTypes.GRID_LAYOUT, new GridLayoutRenderer<UIGridLayout>());
    renderKit.addRenderer(UIIn.COMPONENT_FAMILY, RendererTypes.IN, new InRenderer<UIIn>());
    renderKit.addRenderer(UILink.COMPONENT_FAMILY, RendererTypes.LINK, new LinkRenderer<UILink>());
    renderKit.addRenderer(UILinks.COMPONENT_FAMILY, RendererTypes.LINKS, new LinksRenderer<UILinks>());
    renderKit.addRenderer(UIOut.COMPONENT_FAMILY, RendererTypes.OUT, new OutRenderer<UIOut>());
    renderKit.addRenderer(UIPanel.COMPONENT_FAMILY, RendererTypes.PANEL, new PanelRenderer<UIPanel>());
    renderKit.addRenderer(UIPopup.COMPONENT_FAMILY, RendererTypes.POPUP, new PopupRenderer<UIPopup>());
    renderKit.addRenderer(UIRange.COMPONENT_FAMILY, RendererTypes.RANGE, new RangeRenderer<UIRange>());
    renderKit.addRenderer(UISection.COMPONENT_FAMILY, RendererTypes.SECTION, new SectionRenderer<UISection>());
    renderKit.addRenderer(UISegmentLayout.COMPONENT_FAMILY, RendererTypes.SEGMENT_LAYOUT, new SegmentLayoutRenderer<UISegmentLayout>());
    renderKit.addRenderer(UISelectBooleanCheckbox.COMPONENT_FAMILY, RendererTypes.SELECT_BOOLEAN_CHECKBOX, new SelectBooleanCheckboxRenderer<UISelectBooleanCheckbox>());
    renderKit.addRenderer(UISelectBooleanCheckbox.COMPONENT_FAMILY, RendererTypes.SELECT_BOOLEAN_TOGGLE, new SelectBooleanToggleRenderer<UISelectBooleanToggle>());
    renderKit.addRenderer(UISelectManyCheckbox.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_CHECKBOX, new SelectManyCheckboxRenderer<UISelectManyCheckbox>());
    renderKit.addRenderer(UISelectManyListbox.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_LISTBOX, new SelectManyListboxRenderer<UISelectManyListbox>());
    renderKit.addRenderer(UISelectManyListbox.COMPONENT_FAMILY, RendererTypes.SELECT_MANY_SHUTTLE, new SelectManyShuttleRenderer<UISelectManyShuttle>());
    renderKit.addRenderer(UISelectOneRadio.COMPONENT_FAMILY, RendererTypes.SELECT_ONE_RADIO, new SelectOneRadioRenderer<UISelectOneRadio>());
    renderKit.addRenderer(UISelectOneChoice.COMPONENT_FAMILY, RendererTypes.SELECT_ONE_CHOICE, new SelectOneChoiceRenderer<UISelectOneChoice>());
    renderKit.addRenderer(UISelectReference.COMPONENT_FAMILY, RendererTypes.SELECT_REFERENCE, new SelectReferenceRenderer<UISelectReference>());
    renderKit.addRenderer(UISeparator.COMPONENT_FAMILY, RendererTypes.SEPARATOR, new SeparatorRenderer<UISeparator>());
    renderKit.addRenderer(UISheet.COMPONENT_FAMILY, RendererTypes.SHEET, new SheetRenderer<UISheet>());
    renderKit.addRenderer(UIStyle.COMPONENT_FAMILY, RendererTypes.STYLE, new StyleRenderer<UIStyle>());
    renderKit.addRenderer(UITab.COMPONENT_FAMILY, RendererTypes.TAB, new TabRenderer<UITab>());
    renderKit.addRenderer(UITabGroup.COMPONENT_FAMILY, RendererTypes.TAB_GROUP, new TabGroupRenderer<UITabGroup>());
    renderKit.addRenderer(UITextarea.COMPONENT_FAMILY, RendererTypes.TEXTAREA, new TextareaRenderer<UITextarea>());
    renderKit.addRenderer(UITree.COMPONENT_FAMILY, RendererTypes.TREE, new TreeRenderer<UITree>());
    renderKit.addRenderer(UITreeNode.COMPONENT_FAMILY, RendererTypes.TREE_NODE, new TreeNodeRenderer<UITreeNode>());
    renderKit.addRenderer(UITreeIndent.COMPONENT_FAMILY, RendererTypes.TREE_INDENT, new TreeIndentRenderer<UITreeIndent>());
    renderKit.addRenderer(UITreeSelect.COMPONENT_FAMILY, RendererTypes.TREE_SELECT, new TreeSelectRenderer<UITreeSelect>());
    renderKit.addClientBehaviorRenderer("org.apache.myfaces.tobago.behavior.Event", new TobagoClientBehaviorRenderer());
    renderKit.addClientBehaviorRenderer("org.apache.myfaces.tobago.behavior.Ajax", new TobagoClientBehaviorRenderer());
    application.setMessageBundle("org.apache.myfaces.tobago.context.TobagoMessageBundle");
    ResourceBundleVarNames.addVarName(TOBAGO_RESOURCE_BUNDLE, "org.apache.myfaces.tobago.context.TobagoResourceBundle");
    tobagoConfig.lock();
}
Also used : UIFile(org.apache.myfaces.tobago.component.UIFile) UIColumn(org.apache.myfaces.tobago.component.UIColumn) EventBehavior(org.apache.myfaces.tobago.internal.behavior.EventBehavior) UIBar(org.apache.myfaces.tobago.component.UIBar) UISelectBooleanCheckbox(org.apache.myfaces.tobago.component.UISelectBooleanCheckbox) UILink(org.apache.myfaces.tobago.component.UILink) UITextarea(org.apache.myfaces.tobago.component.UITextarea) UISelectOneRadio(org.apache.myfaces.tobago.component.UISelectOneRadio) UISection(org.apache.myfaces.tobago.component.UISection) UITreeNode(org.apache.myfaces.tobago.component.UITreeNode) UISeparator(org.apache.myfaces.tobago.component.UISeparator) TobagoClientBehaviorRenderer(org.apache.myfaces.tobago.internal.renderkit.renderer.TobagoClientBehaviorRenderer) UISelectItem(org.apache.myfaces.tobago.component.UISelectItem) AjaxBehavior(jakarta.faces.component.behavior.AjaxBehavior) UITab(org.apache.myfaces.tobago.component.UITab) UISelectManyListbox(org.apache.myfaces.tobago.component.UISelectManyListbox) UISelectManyShuttle(org.apache.myfaces.tobago.component.UISelectManyShuttle) UIStyle(org.apache.myfaces.tobago.component.UIStyle) DateTimeConverter(jakarta.faces.convert.DateTimeConverter) UITreeSelect(org.apache.myfaces.tobago.component.UITreeSelect) UIBadge(org.apache.myfaces.tobago.component.UIBadge) UIRange(org.apache.myfaces.tobago.component.UIRange) UITabGroup(org.apache.myfaces.tobago.component.UITabGroup) UIButtons(org.apache.myfaces.tobago.component.UIButtons) UISelectManyCheckbox(org.apache.myfaces.tobago.component.UISelectManyCheckbox) UIBox(org.apache.myfaces.tobago.component.UIBox) UIPanel(org.apache.myfaces.tobago.component.UIPanel) UIOut(org.apache.myfaces.tobago.component.UIOut) TobagoContext(org.apache.myfaces.tobago.context.TobagoContext) UISegmentLayout(org.apache.myfaces.tobago.component.UISegmentLayout) UIGridLayout(org.apache.myfaces.tobago.component.UIGridLayout) HtmlResponseWriter(org.apache.myfaces.tobago.internal.webapp.HtmlResponseWriter) UIDate(org.apache.myfaces.tobago.component.UIDate) StringWriter(java.io.StringWriter) UIButton(org.apache.myfaces.tobago.component.UIButton) RenderKit(jakarta.faces.render.RenderKit) UITreeIndent(org.apache.myfaces.tobago.component.UITreeIndent) UILinks(org.apache.myfaces.tobago.component.UILinks) UIPopup(org.apache.myfaces.tobago.component.UIPopup) UITree(org.apache.myfaces.tobago.component.UITree) UISelectBooleanToggle(org.apache.myfaces.tobago.component.UISelectBooleanToggle) UISheet(org.apache.myfaces.tobago.component.UISheet) TobagoConfig(org.apache.myfaces.tobago.config.TobagoConfig) UISelectOneChoice(org.apache.myfaces.tobago.component.UISelectOneChoice) UIIn(org.apache.myfaces.tobago.component.UIIn) UISelectReference(org.apache.myfaces.tobago.component.UISelectReference) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with UIOut

use of org.apache.myfaces.tobago.component.UIOut in project myfaces-tobago by apache.

the class SheetRendererUnitTest method sheetPaging.

@Test
public void sheetPaging() throws IOException {
    final UISheet sheet = (UISheet) ComponentUtils.createComponent(facesContext, Tags.sheet.componentType(), RendererTypes.Sheet, "sheet");
    sheet.setVar("item");
    sheet.setValue(getSheetSample(10));
    sheet.setRows(2);
    final UIColumn column = (UIColumn) ComponentUtils.createComponent(facesContext, Tags.column.componentType(), RendererTypes.Column, "column");
    column.setLabel("Alphabet");
    sheet.getChildren().add(column);
    final UIOut out = (UIOut) ComponentUtils.createComponent(facesContext, Tags.out.componentType(), RendererTypes.Out, "out");
    out.setValueExpression("value", new MockValueExpression("#{item.name}", String.class));
    out.setLabelLayout(LabelLayout.skip);
    column.getChildren().add(out);
    sheet.encodeAll(facesContext);
    Assertions.assertEquals(loadHtml("renderer/sheet/sheet-paging.html"), formattedResult());
}
Also used : UIColumn(org.apache.myfaces.tobago.component.UIColumn) MockValueExpression(org.apache.myfaces.test.el.MockValueExpression) UIOut(org.apache.myfaces.tobago.component.UIOut) UISheet(org.apache.myfaces.tobago.component.UISheet) Test(org.junit.jupiter.api.Test)

Example 3 with UIOut

use of org.apache.myfaces.tobago.component.UIOut in project myfaces-tobago by apache.

the class BoxRendererUnitTest method boxLabelFacet.

@Test
public void boxLabelFacet() throws IOException {
    final UIBox c = (UIBox) ComponentUtils.createComponent(facesContext, Tags.box.componentType(), RendererTypes.Box, "id");
    final UIOut o = (UIOut) ComponentUtils.createComponent(facesContext, Tags.out.componentType(), RendererTypes.Out, "out");
    o.setValue("label");
    o.setPlain(true);
    c.getFacets().put("label", o);
    c.encodeAll(facesContext);
    Assertions.assertEquals(loadHtml("renderer/box/box-label-facet.html"), formattedResult());
}
Also used : UIBox(org.apache.myfaces.tobago.component.UIBox) UIOut(org.apache.myfaces.tobago.component.UIOut) Test(org.junit.jupiter.api.Test)

Example 4 with UIOut

use of org.apache.myfaces.tobago.component.UIOut in project myfaces-tobago by apache.

the class InRendererUnitTest method inputGroupOutBefore.

@Test
public void inputGroupOutBefore() throws IOException {
    final UIIn c = (UIIn) ComponentUtils.createComponent(facesContext, Tags.in.componentType(), RendererTypes.In, "id");
    final UIOut o = (UIOut) ComponentUtils.createComponent(facesContext, Tags.out.componentType(), RendererTypes.Out, "out");
    o.setValue("out");
    c.getFacets().put("before", o);
    c.encodeAll(facesContext);
    Assertions.assertEquals(loadHtml("renderer/in/input-group-out-before.html"), formattedResult());
}
Also used : UIOut(org.apache.myfaces.tobago.component.UIOut) UIIn(org.apache.myfaces.tobago.component.UIIn) Test(org.junit.jupiter.api.Test)

Example 5 with UIOut

use of org.apache.myfaces.tobago.component.UIOut in project myfaces-tobago by apache.

the class TabGroupRendererUnitTest method withLabel.

@Test
public void withLabel() throws IOException {
    final UITabGroup tg = (UITabGroup) ComponentUtils.createComponent(facesContext, Tags.tabGroup.componentType(), RendererTypes.TabGroup, "id");
    final UITab t1 = (UITab) ComponentUtils.createComponent(facesContext, Tags.tab.componentType(), RendererTypes.Tab, "t1");
    t1.setLabel("T1");
    final UITab t2 = (UITab) ComponentUtils.createComponent(facesContext, Tags.tab.componentType(), RendererTypes.Tab, "t2");
    t2.setLabel("T2");
    final UIOut o = (UIOut) ComponentUtils.createComponent(facesContext, Tags.out.componentType(), RendererTypes.Out, "o");
    o.setLabel("Label");
    t2.getFacets().put("label", o);
    tg.getChildren().add(t1);
    tg.getChildren().add(t2);
    tg.encodeAll(facesContext);
    Assertions.assertEquals(loadHtml("renderer/tabGroup/tabGroup-label.html"), formattedResult());
}
Also used : UITabGroup(org.apache.myfaces.tobago.component.UITabGroup) UITab(org.apache.myfaces.tobago.component.UITab) UIOut(org.apache.myfaces.tobago.component.UIOut) Test(org.junit.jupiter.api.Test)

Aggregations

UIOut (org.apache.myfaces.tobago.component.UIOut)16 Test (org.junit.jupiter.api.Test)15 UIColumn (org.apache.myfaces.tobago.component.UIColumn)5 UISheet (org.apache.myfaces.tobago.component.UISheet)5 MockValueExpression (org.apache.myfaces.test.el.MockValueExpression)4 UIIn (org.apache.myfaces.tobago.component.UIIn)4 UIBox (org.apache.myfaces.tobago.component.UIBox)2 UISection (org.apache.myfaces.tobago.component.UISection)2 UITab (org.apache.myfaces.tobago.component.UITab)2 UITabGroup (org.apache.myfaces.tobago.component.UITabGroup)2 FacesMessage (jakarta.faces.application.FacesMessage)1 AjaxBehavior (jakarta.faces.component.behavior.AjaxBehavior)1 FacesContext (jakarta.faces.context.FacesContext)1 DateTimeConverter (jakarta.faces.convert.DateTimeConverter)1 RenderKit (jakarta.faces.render.RenderKit)1 StringWriter (java.io.StringWriter)1 UIBadge (org.apache.myfaces.tobago.component.UIBadge)1 UIBar (org.apache.myfaces.tobago.component.UIBar)1 UIButton (org.apache.myfaces.tobago.component.UIButton)1 UIButtons (org.apache.myfaces.tobago.component.UIButtons)1