Search in sources :

Example 1 with TobagoClientBehaviorRenderer

use of org.apache.myfaces.tobago.internal.renderkit.renderer.TobagoClientBehaviorRenderer 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)

Aggregations

AjaxBehavior (jakarta.faces.component.behavior.AjaxBehavior)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 UIBox (org.apache.myfaces.tobago.component.UIBox)1 UIButton (org.apache.myfaces.tobago.component.UIButton)1 UIButtons (org.apache.myfaces.tobago.component.UIButtons)1 UIColumn (org.apache.myfaces.tobago.component.UIColumn)1 UIDate (org.apache.myfaces.tobago.component.UIDate)1 UIFile (org.apache.myfaces.tobago.component.UIFile)1 UIGridLayout (org.apache.myfaces.tobago.component.UIGridLayout)1 UIIn (org.apache.myfaces.tobago.component.UIIn)1 UILink (org.apache.myfaces.tobago.component.UILink)1 UILinks (org.apache.myfaces.tobago.component.UILinks)1 UIOut (org.apache.myfaces.tobago.component.UIOut)1 UIPanel (org.apache.myfaces.tobago.component.UIPanel)1 UIPopup (org.apache.myfaces.tobago.component.UIPopup)1 UIRange (org.apache.myfaces.tobago.component.UIRange)1