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();
}
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());
}
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());
}
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());
}
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());
}
Aggregations