Author: ilya_shaikovsky
Date: 2010-05-17 10:21:49 -0400 (Mon, 17 May 2010)
New Revision: 17082
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml
Log:
https://jira.jboss.org/browse/RF-8663
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,37 @@
+package org.richfaces.demo.common.navigation;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+public class BaseDescriptor {
+ private String name;
+ private boolean newItem;
+ private boolean currentItem;
+
+ @XmlElement
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @XmlAttribute(name = "new")
+ public boolean isNewItem() {
+ return newItem;
+ }
+
+ public void setNewItem(boolean newItem) {
+ this.newItem = newItem;
+ }
+
+ @XmlAttribute(name = "current")
+ public boolean isCurrentItem() {
+ return currentItem;
+ }
+
+ public void setCurrentItem(boolean currentItem) {
+ this.currentItem = currentItem;
+ }
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,66 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class DemoDescriptor extends BaseDescriptor {
+ private static final String BASE_SAMPLES_DIR = "/richfaces/";
+ // TODO: could get from JSF instead of constant using
+ private static final String PAGE_EXT = ".xhtml";
+
+ private String page;
+ private String id;
+ private boolean current;
+ private String activeSample;
+ private List<SampleDescriptor> samples;
+
+
+ public String getDemoURI() {
+ return BASE_SAMPLES_DIR + getPage() + PAGE_EXT;
+ }
+
+ @XmlElement
+ public String getPage() {
+ return page;
+ }
+
+ public void setPage(String page) {
+ this.page = page;
+ }
+
+ @XmlElement
+ public List<SampleDescriptor> getSamples() {
+ return samples;
+ }
+
+ public void setSamples(List<SampleDescriptor> samples) {
+ this.samples = samples;
+ }
+
+ public boolean isCurrent() {
+ return current;
+ }
+
+ public void setCurrent(boolean current) {
+ this.current = current;
+ }
+
+ public String getActiveSample() {
+ return activeSample;
+ }
+
+ public void setActiveSample(String activeSample) {
+ this.activeSample = activeSample;
+ }
+
+ @XmlElement
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,99 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+@ManagedBean
+@SessionScoped
+public class DemoNavigator {
+ @ManagedProperty(value = "#{navigationParser.groupsList}")
+ private List<GroupDescriptor> groups;
+ private DemoDescriptor currentDemo = null;
+
+ public DemoDescriptor getCurrentDemo() {
+ String id = getDemoParam("demo");
+ if (id != null) {
+ setCurrentDemo(findDemoById(id));
+ } else {
+ String uri = getDemoUri();
+ setCurrentDemo(findDemoByUri(uri));
+ }
+
+ // set active sample for current component if any
+ if (null != currentDemo) {
+ String sample = getDemoParam("sample");
+ if (null != sample) {
+ currentDemo.setActiveSample(sample);
+ }
+ }
+
+ return currentDemo;
+ }
+
+ private String getDemoUri() {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ return ((HttpServletRequest)
fc.getExternalContext().getRequest()).getRequestURI();
+ }
+
+ private String getDemoParam(String name) {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ String param = (String)
fc.getExternalContext().getRequestParameterMap().get(name);
+ if (param != null && param.trim().length() > 0) {
+ return param;
+ } else {
+ return null;
+ }
+ }
+
+ public DemoDescriptor findDemoByUri(String uri) {
+ Iterator<GroupDescriptor> it = groups.iterator();
+ while (it.hasNext()) {
+ GroupDescriptor group = it.next();
+ Iterator<DemoDescriptor> dit = group.getDemos().iterator();
+ while (dit.hasNext()) {
+ DemoDescriptor demo = dit.next();
+ if (uri.endsWith(demo.getDemoURI())) {
+ return demo;
+ }
+ }
+ }
+ return null;
+ }
+
+ public DemoDescriptor findDemoById(String id) {
+ Iterator<GroupDescriptor> it = groups.iterator();
+ while (it.hasNext()) {
+ GroupDescriptor group = it.next();
+ Iterator<DemoDescriptor> dit = group.getDemos().iterator();
+ while (dit.hasNext()) {
+ DemoDescriptor demo = (DemoDescriptor) dit.next();
+ if (demo.getId().equals(id)) {
+ return demo;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setCurrentDemo(DemoDescriptor currentDemo) {
+ if (currentDemo == null) {
+ this.currentDemo = (DemoDescriptor) groups.get(0).getDemos().get(0);
+ }
+ this.currentDemo = currentDemo;
+ }
+
+ public List<GroupDescriptor> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDescriptor> groups) {
+ this.groups = groups;
+ }
+
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,21 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+
+public class GroupDescriptor extends BaseDescriptor{
+ private List<DemoDescriptor> demos;
+
+ @XmlElementWrapper(name="demos")
+ @XmlElement(name="demo")
+ public List<DemoDescriptor> getDemos() {
+ return demos;
+ }
+
+ public void setDemos(List<DemoDescriptor> demos) {
+ this.demos = demos;
+ }
+
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,52 @@
+package org.richfaces.demo.common.navigation;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@ManagedBean
+@ApplicationScoped
+public class NavigationParser {
+
+ private List<GroupDescriptor> groupsList;
+
+ @XmlRootElement(name = "root")
+ private static final class CapitalsHolder {
+
+ private List<GroupDescriptor> groups;
+
+ @XmlElement(name = "group")
+ public List<GroupDescriptor> getGroups() {
+ return groups;
+ }
+
+ @SuppressWarnings("unused")
+ public void setGroups(List<GroupDescriptor> groups) {
+ this.groups = groups;
+ }
+ }
+
+ public synchronized List<GroupDescriptor> getGroupsList() {
+ if (groupsList == null) {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ URL resource =
ccl.getResource("org/richfaces/demo/data/common/navigation.xml");
+ JAXBContext context;
+ try {
+ context = JAXBContext.newInstance(CapitalsHolder.class);
+ CapitalsHolder capitalsHolder = (CapitalsHolder)
context.createUnmarshaller().unmarshal(resource);
+ groupsList = capitalsHolder.getGroups();
+ } catch (JAXBException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ return groupsList;
+ }
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,6 @@
+package org.richfaces.demo.common.navigation;
+
+
+public class SampleDescriptor extends BaseDescriptor{
+
+}
Added:
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <group>
+ <name>Ajax Action</name>
+ <demos>
+ <demo>
+ <id>ajax</id>
+ <name>a4j:ajax</name>
+ <page>ajax</page>
+ <samples>
+ <sample new="true">
+ <name>Ajax Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>commandButton</id>
+ <name>a4j:commandButton</name>
+ <page>commandButton</page>
+ <samples>
+ <sample>
+ <name>Command Button Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>commandLink</id>
+ <name>a4j:commandLink</name>
+ <page>commandLink</page>
+ <samples>
+ <sample>
+ <name>Command Link Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>jsFunction</id>
+ <name>a4j:jsFunction</name>
+ <page>jsFunction</page>
+ <samples>
+ <sample>
+ <name>jsFunction Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>poll</id>
+ <name>a4j:poll</name>
+ <page>poll</page>
+ <samples>
+ <sample>
+ <name>Poll Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>push</id>
+ <name>a4j:push</name>
+ <page>push</page>
+ <samples>
+ <sample>
+ <name>push Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
+ <name>Ajax Queue</name>
+ <demos>
+ <demo new="true">
+ <id>queue</id>
+ <name>a4j:queue</name>
+ <page>queue</page>
+ <samples>
+ <sample>
+ <name>queue</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>attachQueue</id>
+ <name>a4j:attachQueue</name>
+ <page>attachQueue</page>
+ <samples>
+ <sample>
+ <name>attachQueue</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
+ <name>Ajax Output/Indication</name>
+ <demos>
+ <demo new="true">
+ <id>outputPanel</id>
+ <name>a4j:outputPanel</name>
+ <page>outputPanel</page>
+ <samples>
+ <sample>
+ <name>outputPanel Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>status</id>
+ <name>a4j:status</name>
+ <page>status</page>
+ <samples>
+ <sample>
+ <name>status Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>mediaoutput</id>
+ <name>a4j:mediaOutput</name>
+ <page>mediaOutput</page>
+ <samples>
+ <sample>
+ <name>mediaOutput Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>log</id>
+ <name>a4j:log</name>
+ <page>log</page>
+ <samples>
+ <sample>
+ <name>log</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group new="true">
+ <name>Data Iteration</name>
+ <demos>
+ <demo>
+ <id>dataTable</id>
+ <name>rich:dataTable</name>
+ <page>dataTable</page>
+ <samples>
+ <sample>
+ <name>Data Table Basic</name>
+ </sample>
+ <sample>
+ <name>Data Table Sorting</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+</root>
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml 2010-05-17
14:20:08 UTC (rev 17081)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -15,14 +15,14 @@
<composite:attribute name="style" required="false"/>
<composite:attribute name="styleClass" required="false"/>
<composite:attribute name="headerClass" required="false"/>
- <composite:attribute name="bodyClass" required="true"/>
+ <composite:attribute name="bodyClass" required="false"/>
</composite:interface>
<composite:implementation>
<h:outputStylesheet name="rich/css/panel.css" />
<div class="rich-panel #{compositeComponent.attrs.styleClass}"
- style="#{compositeComponent.attrs.style}"
+ style="#{cc.attrs.style}"
onclick="#{compositeComponent.attrs.onclick}"
ondblclick="#{compositeComponent.attrs.ondblclick}"
onkeydown="#{compositeComponent.attrs.onkeydown}"
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml 2010-05-17
14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -6,6 +6,9 @@
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
+ <f:metadata>
+ <f:viewParam name="sampleId"
value="#{demoNavigator.currentDemo.activeSample}"/>
+ </f:metadata>
<p>
The behavior that adds javascript call for sending Ajax request
to specified event on parent component
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml 2010-05-17
14:20:08 UTC (rev 17081)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -7,7 +7,9 @@
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
-
+ <fieldset>
+ <legend></legend>
+ </fieldset>
<ui:insert/>
</ui:define>
</ui:composition>
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml 2010-05-17
14:20:08 UTC (rev 17081)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -4,34 +4,28 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://java.sun.com/jsf/composite/rich">
- <rich:panel bodyClass="">
+ <rich:panel style="width:250px" bodyClass="">
<f:facet name="header">
<h:outputText value="Navigation" />
- </f:facet>
- <h:panelGrid columns="1">
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/ajax.jsf">a4j:ajax</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/jsFunction.jsf">a4j:jsFunction</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/mediaOutput.jsf">a4j:mediaOutput</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/push.jsf">a4j:push</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/status.jsf">a4j:status</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/outputPanel.jsf">a4j:outputPanel</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/commandButton.jsf">a4j:commandButton</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/commandLink.jsf">a4j:commandLink</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/log.jsf">a4j:log</h:outputLink>
- <hr/>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/dataTable.jsf">h:dataTable
vs Ajax</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/skin.jsf">Skin
sample</h:outputLink>
- </h:panelGrid>
+ </f:facet>
+ <ul>
+ <a4j:repeat value="#{demoNavigator.groups}" var="gr">
+ <li>
+ <h:outputText value="#{gr.name}" />
+ <h:outputText value="NEW!" rendered="#{gr.newItem}"/>
+ </li>
+ <ul>
+ <a4j:repeat value="#{gr.demos}" var="d">
+ <li>
+ <h:link outcome="#{d.demoURI}" value="#{d.name}"
includeViewParams="true">
+ <f:param name="demo" value="#{d.id}"/>
+ </h:link>
+ <h:outputText value="NEW!" rendered="#{d.newItem or
gr.newItem}" style="color:red"/>
+ <h:outputText value="CUR!" rendered="#{d.id ==
demoNavigator.currentDemo.id}" style="color:orange"/>
+ </li>
+ </a4j:repeat>
+ </ul>
+ </a4j:repeat>
+ </ul>
</rich:panel>
</ui:composition>
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml 2010-05-17
14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml 2010-05-17
14:21:49 UTC (rev 17082)
@@ -36,6 +36,13 @@
style="width:#{cc.attrs.sidebarWidth}px"></div>
<ui:include src="/templates/includes/navigation.xhtml"
/></td>
<td class="content_col rich-page-body #{cc.attrs.bodyClass}">
+
+ <ui:remove>
+ <fieldset>
+ <legend>#{demoNavigator.currentComponent}</legend>
+ </fieldset>
+ </ui:remove>
+
<ui:insert name="body">
Body content missed
</ui:insert></td>