Author: ilya_shaikovsky
Date: 2010-05-17 14:13:42 -0400 (Mon, 17 May 2010)
New Revision: 17092
Added:
root/examples/richfaces-showcase/trunk/mvnEclipse.bat
Modified:
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/SampleDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax/ajax.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/mvnEclipse.bat
===================================================================
--- root/examples/richfaces-showcase/trunk/mvnEclipse.bat (rev 0)
+++ root/examples/richfaces-showcase/trunk/mvnEclipse.bat 2010-05-17 18:13:42 UTC (rev
17092)
@@ -0,0 +1 @@
+call mvn eclipse:clean eclipse:eclipse %*
\ No newline at end of file
Modified:
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 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java 2010-05-17
18:13:42 UTC (rev 17092)
@@ -4,6 +4,7 @@
import javax.xml.bind.annotation.XmlElement;
public class BaseDescriptor {
+ private String id;
private String name;
private boolean newItem;
private boolean currentItem;
@@ -34,4 +35,12 @@
public void setCurrentItem(boolean currentItem) {
this.currentItem = currentItem;
}
+ @XmlElement
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
}
Modified:
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 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java 2010-05-17
18:13:42 UTC (rev 17092)
@@ -3,21 +3,36 @@
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
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 SampleDescriptor activeSample;
private List<SampleDescriptor> samples;
+ private SampleDescriptor getSampleById(String id) {
+ for (SampleDescriptor sample : getSamples()) {
+ if (sample.getId().equals(id)) {
+ return sample;
+ }
+ }
+ return null;
+ }
+ public void setActiveSampleById(String id) {
+ setActiveSample(getSampleById(id));
+ }
+
+ public String getSampleURI() {
+ return BASE_SAMPLES_DIR + activeSample.getSrc();
+ }
+
public String getDemoURI() {
- return BASE_SAMPLES_DIR + getPage() + PAGE_EXT;
+ return BASE_SAMPLES_DIR + getPage();
}
@XmlElement
@@ -29,7 +44,8 @@
this.page = page;
}
- @XmlElement
+ @XmlElementWrapper(name = "samples")
+ @XmlElement(name = "sample")
public List<SampleDescriptor> getSamples() {
return samples;
}
@@ -46,21 +62,12 @@
this.current = current;
}
- public String getActiveSample() {
+ public SampleDescriptor getActiveSample() {
return activeSample;
}
- public void setActiveSample(String activeSample) {
+ public void setActiveSample(SampleDescriptor activeSample) {
this.activeSample = activeSample;
}
- @XmlElement
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
}
Modified:
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 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java 2010-05-17
18:13:42 UTC (rev 17092)
@@ -15,7 +15,8 @@
@ManagedProperty(value = "#{navigationParser.groupsList}")
private List<GroupDescriptor> groups;
private DemoDescriptor currentDemo = null;
-
+ private String currentSample;
+
public DemoDescriptor getCurrentDemo() {
String id = getDemoParam("demo");
if (id != null) {
@@ -24,12 +25,13 @@
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);
+ if (null != currentSample) {
+ currentDemo.setActiveSampleById(currentSample);
+ }else{
+ currentDemo.setActiveSample(currentDemo.getSamples().get(0));
+ currentSample = currentDemo.getActiveSample().getId();
}
}
@@ -96,4 +98,12 @@
this.groups = groups;
}
+ public String getCurrentSample() {
+ return currentSample;
+ }
+
+ public void setCurrentSample(String currentSample) {
+ this.currentSample = currentSample;
+ }
+
}
Modified:
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 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java 2010-05-17
18:13:42 UTC (rev 17092)
@@ -1,6 +1,16 @@
package org.richfaces.demo.common.navigation;
+import javax.xml.bind.annotation.XmlElement;
+
public class SampleDescriptor extends BaseDescriptor{
+ private String src;
+ @XmlElement
+ public String getSrc() {
+ return src;
+ }
+ public void setSrc(String src) {
+ this.src = src;
+ }
}
Modified:
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 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-05-17
18:13:42 UTC (rev 17092)
@@ -8,9 +8,16 @@
<name>a4j:ajax</name>
<page>ajax</page>
<samples>
- <sample new="true">
- <name>Ajax Simple</name>
+ <sample>
+ <id>simple</id>
+ <name>Simple sample</name>
+ <src>ajax/ajax.xhtml</src>
</sample>
+ <sample>
+ <id>selects</id>
+ <name>Dynamic Selects</name>
+ <src>ajax/ajax.xhtml</src>
+ </sample>
</samples>
</demo>
<demo new="true">
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax/ajax.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax/ajax.xhtml 2010-05-17
18:07:48 UTC (rev 17091)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax/ajax.xhtml 2010-05-17
18:13:42 UTC (rev 17092)
@@ -6,6 +6,7 @@
xmlns:a4j="http://richfaces.org/a4j">
<ui:composition>
+
<h:form>
<h:inputText value="#{userBean.name}">
<a4j:ajax event="keyup" render="out"/>
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
18:07:48 UTC (rev 17091)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml 2010-05-17
18:13:42 UTC (rev 17092)
@@ -5,26 +5,24 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/templates/main.xhtml">
+ <ui:define name="demoSampleParameters">
+ <f:viewParam name="simple"
value="#{demoNavigator.currentSample}" />
+ </ui:define>
<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
</p>
<fieldset>
<legend>Simple sample</legend>
- <ui:include src="/richfaces/ajax/ajax.xhtml" />
+ <ui:include src="#{demoNavigator.currentDemo.sampleURI}" />
</fieldset>
<p>Typical use-case of dependent select components. When you choosing
the type in the first select - corresponding items appears in second one.
</p>
- <fieldset>
- <legend>Simple sample</legend>
- <ui:include src="/richfaces/ajax/selectsUpdates.xhtml" />
- </fieldset>
+
+
</ui:define>
</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
18:07:48 UTC (rev 17091)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml 2010-05-17
18:13:42 UTC (rev 17092)
@@ -13,6 +13,9 @@
<title>Components Gallery</title>
</h:head>
<h:body>
+ <f:metadata>
+ <ui:insert name="demoSampleParameters"/>
+ </f:metadata>
<h:outputStylesheet name="rich/css/page.css" />
<table border="0" cellpadding="0" cellspacing="0"
class="rich-page #{cc.attrs.pageClass}">