Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bootstrap: added the navbar component

  • Loading branch information...
commit ce74b1d2c0c1632d323ca8143bcbdf4406db0bfa 1 parent 927b3ed
@bleathem authored
View
9 bootstrap/demo/src/main/webapp/index.xhtml
@@ -7,9 +7,14 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
- xmlns:a4j="http://richfaces.org/a4j">
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:bootstrap="http://richfaces.org/sandbox/bootstrap">
<ui:define name="body">
- Welcome to the bootstrap demo app.
+ <bootstrap:heroUnit heading="RichFaces Bootstrap" tagline="Build JSF applications with the amazing Bootstrap components">
+ <p>
+ Click one of the menu links above to see some Bootstrap components in action!
+ </p>
+ </bootstrap:heroUnit>
</ui:define>
</ui:composition>
View
8 bootstrap/demo/src/main/webapp/resources/menu.xhtml
@@ -3,12 +3,14 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:rich="http://richfaces.org/rich">
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:bootstrap="http://richfaces.org/sandbox/bootstrap">
<div>
- <h:panelGrid columns="10" style="width:100%;">
+ <bootstrap:navbar brand="Richfaces">
<h:link outcome="/samples/heroUnit.xhtml" value="heroUnit"/>
<h:link outcome="/samples/tabbable.xhtml" value="tabbable"/>
<h:link outcome="/samples/buttonGroup.xhtml" value="buttonGroup"/>
- </h:panelGrid>
+ <h:link outcome="/samples/navbar.xhtml" value="navbar"/>
+ </bootstrap:navbar>
</div>
</ui:fragment>
View
21 bootstrap/demo/src/main/webapp/samples/navbar.xhtml
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en-US">
+
+<ui:composition template="/resources/template.xhtml"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:bootstrap="http://richfaces.org/sandbox/bootstrap">
+ <ui:define name="body">
+ <bootstrap:navbar brand="Nav Bar">
+ <h:link outcome="/samples/heroUnit.xhtml" value="heroUnit"/>
+ <h:link outcome="/samples/tabbable.xhtml" value="tabbable"/>
+ <h:link outcome="/samples/buttonGroup.xhtml" value="buttonGroup"/>
+ <h:link outcome="/samples/navbar.xhtml" value="navbar"/>
+ </bootstrap:navbar>
+ </ui:define>
+</ui:composition>
+</html>
View
50 bootstrap/ui/src/main/java/org/richfaces/bootstrap/component/AbstractNavbar.java
@@ -0,0 +1,50 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.bootstrap.component;
+
+import org.richfaces.bootstrap.renderkit.NavbarRendererBase;
+import org.richfaces.bootstrap.renderkit.TabbableRendererBase;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+
+import javax.faces.component.UIPanel;
+
+/**
+ * Base class for the navbar component
+ *
+ * @author <a href="http://community.jboss.org/people/bleathem">Brian Leathem</a>
+ */
+@JsfComponent(
+ type = AbstractNavbar.COMPONENT_TYPE,
+ family = AbstractNavbar.COMPONENT_FAMILY,
+ renderer = @JsfRenderer(type = NavbarRendererBase.RENDERER_TYPE),
+ tag = @Tag(name="navbar"))
+abstract public class AbstractNavbar extends UIPanel {
+ public static final String COMPONENT_FAMILY = "org.richfaces.bootstrap.Navbar";
+ public static final String COMPONENT_TYPE = "org.richfaces.bootstrap.Navbar";
+
+ @Attribute
+ abstract public String getBrand();
+
+}
View
55 bootstrap/ui/src/main/java/org/richfaces/bootstrap/renderkit/NavbarRendererBase.java
@@ -0,0 +1,55 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.bootstrap.renderkit;
+
+import org.richfaces.bootstrap.component.AbstractNavbar;
+import org.richfaces.bootstrap.component.AbstractTabbable;
+import org.richfaces.component.AbstractCommandLink;
+import org.richfaces.renderkit.html.DivPanelRenderer;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlOutcomeTargetLink;
+import javax.faces.component.html.HtmlOutputLink;
+import java.util.ArrayList;
+import java.util.List;
+
+@ResourceDependencies({
+ @ResourceDependency(library = "org.richfaces", name = "ajax.reslib"),
+ @ResourceDependency(library = "org.richfaces", name = "base-component.reslib"),
+ @ResourceDependency(library = "bootstrap/css", name = "bootstrap.css"),
+ @ResourceDependency(library = "bootstrap/js", name = "bootstrap.js")})
+/**
+ * Base class for the navbar renderer
+ *
+ * @author <a href="http://community.jboss.org/people/bleathem">Brian Leathem</a>
+ */
+public abstract class NavbarRendererBase extends DivPanelRenderer {
+ public static final String RENDERER_TYPE = "org.richfaces.bootstrap.NavbarRenderer";
+
+ // A workaround for RF-11668
+ public AbstractNavbar castComponent(UIComponent component) {
+ return (AbstractNavbar) component;
+ }
+}
View
37 bootstrap/ui/src/main/templates/org/richfaces/bootstrap/navbar.template.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
+ xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+ xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+ xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.bootstrap.renderkit.NavbarRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.bootstrap.renderkit.NavbarRendererBase</cdk:superclass>
+ <cdk:renderer-type>org.richfaces.bootstrap.NavbarRenderer</cdk:renderer-type>
+ <cdk:renders-children>true</cdk:renders-children>
+ </cc:interface>
+
+ <cc:implementation>
+ <cdk:object type="org.richfaces.bootstrap.component.AbstractNavbar" name="navbar"
+ value="#{castComponent(component)}"/>
+ <div id="#{clientId}" class="navbar">
+ <div class="navbar-inner">
+ <div class="container">
+ <c:if test="#{not empty navbar.brand}"/>
+ <a class="brand" href="#">
+ #{navbar.brand}
+ </a>
+ <ul class="nav">
+ <c:forEach var="child" items="#{component.getChildren()}">
+ <li>
+ <cdk:call expression="child.encodeAll(facesContext)"/>
+ </li>
+ </c:forEach>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </cc:implementation>
+
+</cdk:root>
Please sign in to comment.
Something went wrong with that request. Please try again.