Skip to content

Commit

Permalink
quick fix for #325
Browse files Browse the repository at this point in the history
sort resource list before removing duplicates
dont add jsf.js and bsf.js manually anymore
  • Loading branch information
zhedar committed May 7, 2016
1 parent 178c711 commit c0b302f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public class IconAwesome extends Icon {

public IconAwesome() {
Tooltip.addResourceFiles();
AddResourcesListener.addBasicJSResource("javax.faces", "jsf.js");
AddResourcesListener.addBasicJSResource("bsf", "js/bsf.js");
AddResourcesListener.addThemedCSSResource("core.css");
// AddResourcesListener.addThemedCSSResource("font-awesome.css");
setRendererType(DEFAULT_RENDERER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public String getDefaultEventName() {
public InputText() {
setRendererType("net.bootsfaces.component.inputText.InputText");
Tooltip.addResourceFiles();
AddResourcesListener.addBasicJSResource("javax.faces", "jsf.js");
AddResourcesListener.addBasicJSResource("bsf", "js/bsf.js");
AddResourcesListener.addThemedCSSResource("core.css");
AddResourcesListener.addThemedCSSResource("bsf.css");
renderLabel = BsfUtils.getInitParam("net.bootsfaces.defaults.renderLabel");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public String getFamily() {

public InputTextarea() {
setRendererType("net.bootsfaces.component.InputTextareaRenderer");
// AddResourcesListener.addBasicJSResource("javax.faces", "jsf.js");
// AddResourcesListener.addBasicJSResource("bsf", "js/bsf.js");
AddResourcesListener.addThemedCSSResource("core.css");
AddResourcesListener.addThemedCSSResource("bsf.css");
Tooltip.addResourceFiles();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/bootsfaces/component/tree/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class Tree extends UIComponentBase implements ClientBehaviorHolder {
*/
public Tree() {
setRendererType(DEFAULT_RENDERER);
AddResourcesListener.addBasicJSResource("javax.faces", "jsf.js");
AddResourcesListener.addThemedCSSResource("bootstrap-treeview.min.css");
AddResourcesListener.addThemedCSSResource("bsf.css");
AddResourcesListener.addThemedCSSResource("core.css");
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/net/bootsfaces/listeners/AddResourcesListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
Expand Down Expand Up @@ -361,7 +362,15 @@ private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIOut
private void removeDuplicateResources(UIViewRoot root, FacesContext context) {
List<UIComponent> resourcesToRemove = new ArrayList<UIComponent>();
Map<String, UIComponent> alreadyThere = new HashMap<String, UIComponent>();
for (UIComponent resource : root.getComponentResources(context, "head")) {
List<UIComponent> components = new ArrayList<UIComponent>(
root.getComponentResources(context, "head"));
Collections.sort(components, new Comparator<UIComponent>() {
@Override
public int compare(UIComponent o1, UIComponent o2) {
return o1.getClientId().compareTo(o2.getClientId());
}
});
for (UIComponent resource : components) {
String name = (String) resource.getAttributes().get("name");
String library = (String) resource.getAttributes().get("library");
String key = library + "/" + name + "/" + resource.getClass().getName();
Expand Down

0 comments on commit c0b302f

Please sign in to comment.