Skip to content

Commit

Permalink
adapt to myfaces rendering, Refactorings, Clean-Up
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Mar 29, 2024
1 parent 41467bb commit ad8ae41
Show file tree
Hide file tree
Showing 75 changed files with 1,062 additions and 954 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
package de.cuioss.jsf.api.application;

import de.cuioss.tools.logging.CuiLogger;

import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;

import de.cuioss.tools.logging.CuiLogger;

/**
* CuiVersionLoggerEventListener run once at jsf application start<br>
* and log cui version information. The content is places at project manifest.
* and log cui version information.
* The content is read from the project manifest.
*
* @author Eugen Fischer
*/
Expand All @@ -34,9 +35,9 @@ public class CuiVersionLoggerEventListener implements SystemEventListener {
public void processEvent(final SystemEvent event) {
final var pack = CuiVersionLoggerEventListener.class.getPackage();
log.info("Running on {} ( Version : {} )",
pack.getImplementationTitle() != null ? pack.getImplementationTitle().toUpperCase()
: "cuioss-Common-Ui",
pack.getImplementationVersion() != null ? pack.getImplementationVersion().toUpperCase() : "unknown");
pack.getImplementationTitle() != null ? pack.getImplementationTitle().toUpperCase()
: "cuioss-Common-Ui",
pack.getImplementationVersion() != null ? pack.getImplementationVersion().toUpperCase() : "unknown");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package de.cuioss.jsf.api.application.bundle;

import java.io.Serial;
import java.util.Optional;

import javax.annotation.Priority;
Expand All @@ -35,6 +36,7 @@
@EqualsAndHashCode
public class CuiJSfResourceBundleLocator implements ResourceBundleLocator {

@Serial
private static final long serialVersionUID = -8478481710191113463L;

private static final String PATH = "de.cuioss.jsf.api.l18n.messages";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package de.cuioss.jsf.api.application.message;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import de.cuioss.portal.common.bundle.ResourceBundleWrapper;
import de.cuioss.portal.common.priority.PortalPriorities;
import de.cuioss.tools.collect.MoreCollections;
import de.cuioss.tools.string.TextSplitter;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.annotation.Priority;
import javax.enterprise.context.RequestScoped;
Expand All @@ -10,13 +14,9 @@
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Provider;

import de.cuioss.portal.common.bundle.ResourceBundleWrapper;
import de.cuioss.portal.common.priority.PortalPriorities;
import de.cuioss.tools.collect.MoreCollections;
import de.cuioss.tools.string.TextSplitter;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serial;
import java.text.MessageFormat;
import java.util.MissingResourceException;

/**
* Portal version of MessageProducer.
Expand All @@ -38,7 +38,7 @@
@ToString
public class MessageProducerBean implements MessageProducer {

private static final int ABBRIDGE_SIZE = 256;
private static final int ABRIDGED_SIZE = 256;

private static final int FORCE_BREAK_COUNT = 35;

Expand All @@ -47,6 +47,7 @@ public class MessageProducerBean implements MessageProducer {
*/
public static final String MISSING_KEY_PREFIX = "Missing key : ";

@Serial
private static final long serialVersionUID = 4405826619024002836L;

@Inject
Expand All @@ -62,7 +63,7 @@ public FacesMessage getMessageFor(final String messageKey, final Severity severi
if (parameter.length > 0) {
resultingMessage = MessageFormat.format(resultingMessage, parameter);
}
var splitter = new TextSplitter(resultingMessage, FORCE_BREAK_COUNT, ABBRIDGE_SIZE);
var splitter = new TextSplitter(resultingMessage, FORCE_BREAK_COUNT, ABRIDGED_SIZE);
var cleaned = splitter.getTextWithEnforcedLineBreaks();
return new FacesMessage(severity, cleaned, cleaned);
} catch (final MissingResourceException e) {
Expand All @@ -72,9 +73,9 @@ public FacesMessage getMessageFor(final String messageKey, final Severity severi
}

@Override
public void setFacesMessage(final String messagekey, final Severity severity, final String componentId,
final Object... parameter) {
facesContextProvider.get().addMessage(componentId, getMessageFor(messagekey, severity, parameter));
public void setFacesMessage(final String messageKey, final Severity severity, final String componentId,
final Object... parameter) {
facesContextProvider.get().addMessage(componentId, getMessageFor(messageKey, severity, parameter));
}

@Override
Expand All @@ -83,7 +84,7 @@ public void addMessage(String message, Severity severity, String componentId, Ob
if (!MoreCollections.isEmpty(parameter)) {
resultingMessage = MessageFormat.format(resultingMessage, parameter);
}
var splitter = new TextSplitter(resultingMessage, FORCE_BREAK_COUNT, ABBRIDGE_SIZE);
var splitter = new TextSplitter(resultingMessage, FORCE_BREAK_COUNT, ABRIDGED_SIZE);
var cleaned = splitter.getTextWithEnforcedLineBreaks();
facesContextProvider.get().addMessage(componentId, new FacesMessage(severity, cleaned, cleaned));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class JsfHtmlComponent<T extends UIComponent> {
HtmlInputHidden.class, Node.INPUT);

/** Component representation for h:inputText */
public static final JsfHtmlComponent<HtmlInputText> HTMLINPUT = new JsfHtmlComponent<>(
public static final JsfHtmlComponent<HtmlInputText> HTML_INPUT = new JsfHtmlComponent<>(
HtmlInputText.COMPONENT_FAMILY, HtmlInputText.COMPONENT_TYPE, TEXT_RENDERER_TYPE, HtmlInputText.class,
Node.INPUT);

Expand All @@ -111,9 +111,9 @@ public class JsfHtmlComponent<T extends UIComponent> {
Node.A);

/** Similar toEnum#values(): Provides all elements */
@SuppressWarnings("squid:S2386") // owolff: false positive, list is immutable
@SuppressWarnings("squid:S2386") // owolff: false positive, the list is immutable
public static final Collection<JsfHtmlComponent<? extends UIComponentBase>> VALUES = CollectionLiterals
.immutableList(BUTTON, COMMAND_BUTTON, FORM, PANEL_GROUP, SPAN, CHECKBOX, INPUT, HIDDEN, HTMLINPUT,
.immutableList(BUTTON, COMMAND_BUTTON, FORM, PANEL_GROUP, SPAN, CHECKBOX, INPUT, HIDDEN, HTML_INPUT,
HTML_OUTPUT_TEXT, HTML_OUTPUT_LINK);
@Getter
private final String family;
Expand Down Expand Up @@ -150,7 +150,7 @@ public Renderer renderer(final FacesContext context) {
* Shortcut for creating and casting a component to a given type.
*
* @param context must not be null
* @param component to be created, must not be null
* @param component to be created must not be null
* @return the created component.
*/
public static <T extends UIComponent> T createComponent(final FacesContext context,
Expand All @@ -163,7 +163,7 @@ public static <T extends UIComponent> T createComponent(final FacesContext conte
* Shortcut for creating and casting a renderer to a given type.
*
* @param context must not be null
* @param component to be created, must not be null
* @param component to be created must not be null
* @return the created component.
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProvider;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProviderImpl;
import de.cuioss.jsf.api.components.partial.StyleAttributeProvider;
import de.cuioss.jsf.api.components.partial.StyleAttributeProviderImpl;
import lombok.experimental.Delegate;

/**
* Minimal superset for cui-based components that are no
* {@link UINamingContainer}. Therefore, it provides the handling of the
Expand All @@ -37,17 +33,14 @@
* @author Oliver Wolff
*/
public abstract class AbstractBaseCuiComponent extends UIComponentBase
implements ComponentBridge, ComponentStyleClassProvider, StyleAttributeProvider {
implements ComponentBridge, ComponentStyleClassProvider, StyleAttributeProvider {

@Delegate
private final ComponentStyleClassProvider styleClassProvider;

@Delegate
private final StyleAttributeProvider styleAttributeProvider;

/**
*
*/
protected AbstractBaseCuiComponent() {
styleClassProvider = new ComponentStyleClassProviderImpl(this);
styleAttributeProvider = new StyleAttributeProviderImpl(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,31 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.TitleProvider;
import de.cuioss.jsf.api.components.partial.TitleProviderImpl;
import lombok.experimental.Delegate;

/**
* Base class for creating cui variants of {@link HtmlCommandButton}
* implementing {@link ComponentBridge} and {@link TitleProvider}
*
* @author Oliver Wolff
*
*/
public class BaseCuiCommandButton extends HtmlCommandButton implements ComponentBridge, TitleProvider {

@Delegate
private final TitleProvider titleProvider;

/**
*
*/
@Delegate
private final ComponentStyleClassProvider styleClassProvider;

public BaseCuiCommandButton() {
titleProvider = new TitleProviderImpl(this);
styleClassProvider = new ComponentStyleClassProviderImpl(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.ComponentBridge;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputHidden;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;

/**
* Minimal super-set for cui-based components that are at least
* {@link HtmlInputHidden}. It acts as a {@link ComponentBridge}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputText;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProvider;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProviderImpl;
import de.cuioss.jsf.api.components.partial.StyleAttributeProvider;
import de.cuioss.jsf.api.components.partial.StyleAttributeProviderImpl;
import lombok.experimental.Delegate;

/**
* Minimal super-set for cui-based components that are at least
* {@link HtmlInputText}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProvider;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProviderImpl;
import de.cuioss.jsf.api.components.partial.StyleAttributeProvider;
import de.cuioss.jsf.api.components.partial.StyleAttributeProviderImpl;
import lombok.experimental.Delegate;

/**
* Minimal super-set for cui-based components that are at least
* {@link HtmlSelectBooleanCheckbox}.
Expand All @@ -39,13 +35,13 @@
*/
@SuppressWarnings("squid:MaximumInheritanceDepth") // Artifact of Jsf-structure
public class BaseCuiHtmlSelectBooleanCheckboxComponent extends HtmlSelectBooleanCheckbox
implements ComponentBridge, ComponentStyleClassProvider, StyleAttributeProvider {
implements ComponentBridge, ComponentStyleClassProvider, StyleAttributeProvider {

@Delegate
protected final ComponentStyleClassProvider styleClassProvider;
private final ComponentStyleClassProvider styleClassProvider;

@Delegate
protected final StyleAttributeProvider styleAttributeProvider;
private final StyleAttributeProvider styleAttributeProvider;

/***/
public BaseCuiHtmlSelectBooleanCheckboxComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProvider;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProviderImpl;
import de.cuioss.jsf.api.components.partial.StyleAttributeProvider;
import de.cuioss.jsf.api.components.partial.StyleAttributeProviderImpl;
import lombok.experimental.Delegate;

/**
* Minimal super-set for cui-based components that are at least {@link UIInput}.
* Therefore, it provides the handling of the styleClass and style attribute and
Expand All @@ -44,9 +40,6 @@ public class BaseCuiInputComponent extends UIInput
@Delegate
private final StyleAttributeProvider styleAttributeProvider;

/**
*
*/
public BaseCuiInputComponent() {
styleClassProvider = new ComponentStyleClassProviderImpl(this);
styleAttributeProvider = new StyleAttributeProviderImpl(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;

import de.cuioss.jsf.api.components.partial.ComponentBridge;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProvider;
import de.cuioss.jsf.api.components.partial.ComponentStyleClassProviderImpl;
import de.cuioss.jsf.api.components.partial.StyleAttributeProvider;
import de.cuioss.jsf.api.components.partial.StyleAttributeProviderImpl;
import lombok.experimental.Delegate;

/**
* Minimal super-set for cui-based components that are at least
* {@link UINamingContainer}.
Expand All @@ -46,9 +42,6 @@ public class BaseCuiNamingContainer extends UINamingContainer
@Delegate
private final StyleAttributeProvider styleAttributeProvider;

/**
*
*/
public BaseCuiNamingContainer() {
styleClassProvider = new ComponentStyleClassProviderImpl(this);
styleAttributeProvider = new StyleAttributeProviderImpl(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void setStyleClass(final String styleClass) {
/**
* @return the component specific style-classes.
* Must not be null.
* But may be empty
* The parent component (BaseCuiOutputText) takes care on the configured styleClass
* attribute and implements the actual method
* {@link HtmlOutputText#getStyleClass()} by calling this method and
Expand Down
Loading

0 comments on commit ad8ae41

Please sign in to comment.