Skip to content

Commit

Permalink
switch to CDI bean with beans.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
geopossachs committed Oct 8, 2023
1 parent 643a8a8 commit fba83f5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
19 changes: 9 additions & 10 deletions src/main/java/net/bootsfaces/component/ComponentUtils.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package net.bootsfaces.component;


import jakarta.annotation.ManagedBean;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
import net.bootsfaces.beans.ELTools;

@ManagedBean
@Named
@RequestScoped
public class ComponentUtils {

private boolean renderLabelDefault = true;

public ComponentUtils() {
try {
String renderLabel = FacesContext.getCurrentInstance().getExternalContext()
String renderLabel = FacesContext.getCurrentInstance().getExternalContext()
.getInitParameter("net.bootsfaces.defaults.renderLabel");
if (null != renderLabel && renderLabel.contains("#{")) {
renderLabelDefault = (Boolean) ELTools.evalAsObject(renderLabel);
}
else if (null != renderLabel) {
renderLabelDefault = Boolean.valueOf(renderLabel);
}
if (null != renderLabel && renderLabel.contains("#{")) {
renderLabelDefault = (Boolean) ELTools.evalAsObject(renderLabel);
} else if (null != renderLabel) {
renderLabelDefault = Boolean.valueOf(renderLabel);
}
} catch (Exception e) {
System.out.println("Exception when reading net.bootsfaces.defaults.renderLabel");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public boolean isDisabled() {
* @return Returns the value of the attribute, or false, if it hasn't been set by the JSF file.
*/
public boolean isRenderLabel() {
return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.renderLabel, net.bootsfaces.component.ComponentUtils.isRenderLabelDefault());
return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.renderLabel,
net.bootsfaces.component.ComponentUtils.isRenderLabelDefault());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.util.HashMap;
import java.util.Map;

import jakarta.annotation.ManagedBean;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;


@ManagedBean
@Named
@RequestScoped
public class RadioButtonInternalStateBean {

private Map<String, Boolean> inputHasAlreadyBeenRendered = new HashMap<String, Boolean>();

public boolean inputHasAlreadyBeenRendered(String key) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package net.bootsfaces.expressions;

import jakarta.annotation.ManagedBean;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.component.UIComponent;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;

@ManagedBean
@Named
@RequestScoped
public class SearchExpressionResolverBean {

public String resolve(UIComponent component, String expression) {
String componentIDs = ExpressionResolver.getComponentIDs(FacesContext.getCurrentInstance(), component, expression);
if (componentIDs.indexOf(' ')>=0) {
if (componentIDs.indexOf(' ') >= 0) {
// multiple component ids
componentIDs = componentIDs.replace(" ", " :");
}
return ":"+componentIDs;
return ":" + componentIDs;
}
}

}
6 changes: 6 additions & 0 deletions src/main/meta/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
version="4.0" bean-discovery-mode="annotated">
</beans>

0 comments on commit fba83f5

Please sign in to comment.