Author: ilya_shaikovsky
Date: 2007-12-10 11:20:51 -0500 (Mon, 10 Dec 2007)
New Revision: 4663
Added:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/Converter.java
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBarItem.java
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/listShuttle/examples/toolBarCustomization.xhtml
Log:
http://jira.jboss.com/jira/browse/RF-1181
Added:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/Converter.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/Converter.java
(rev 0)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/Converter.java 2007-12-10
16:20:51 UTC (rev 4663)
@@ -0,0 +1,23 @@
+package org.richfaces.demo.listShuttle;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public class Converter implements javax.faces.convert.Converter{
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+
+ int index = value.indexOf(':');
+
+ return new ToolBarItem(value.substring(0, index), value.substring(index + 1));
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+
+ ToolBarItem optionItem = (ToolBarItem) value;
+ return optionItem.getLabel() + ":" + optionItem.getType();
+ }
+
+}
\ No newline at end of file
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java 2007-12-10
16:10:40 UTC (rev 4662)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java 2007-12-10
16:20:51 UTC (rev 4663)
@@ -19,6 +19,14 @@
item.setType("label");
item.setLabel("Close");
items.add(item);
+ item = new ToolBarItem();
+ item.setType("label");
+ item.setLabel("Import");
+ freeItems.add(item);
+ item = new ToolBarItem();
+ item.setType("label");
+ item.setLabel("Export");
+ freeItems.add(item);
}
public List<ToolBarItem> getItems() {
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBarItem.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBarItem.java 2007-12-10
16:10:40 UTC (rev 4662)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBarItem.java 2007-12-10
16:20:51 UTC (rev 4663)
@@ -3,7 +3,16 @@
public class ToolBarItem {
private String type;
private String label;
-private String icon;
+
+public ToolBarItem() {
+ // TODO Auto-generated constructor stub
+}
+
+public ToolBarItem(String label, String type) {
+ setLabel(label);
+ setType(type);
+}
+
public String getType() {
return type;
}
@@ -16,10 +25,35 @@
public void setLabel(String label) {
this.label = label;
}
-public String getIcon() {
- return icon;
+
+public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((label == null) ? 0 : label.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
}
-public void setIcon(String icon) {
- this.icon = icon;
+
+public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ToolBarItem other = (ToolBarItem) obj;
+ if (label == null) {
+ if (other.label != null)
+ return false;
+ } else if (!label.equals(other.label))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
}
+
+
}
Modified: branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-10
16:10:40 UTC (rev 4662)
+++
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-10
16:20:51 UTC (rev 4663)
@@ -2,6 +2,10 @@
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
+ <converter>
+ <converter-id>listShuttleconverter</converter-id>
+
<converter-class>org.richfaces.demo.listShuttle.Converter</converter-class>
+ </converter>
<managed-bean>
<managed-bean-name>skinBean</managed-bean-name>
<managed-bean-class>org.richfaces.demo.common.SkinBean</managed-bean-class>
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/listShuttle/examples/toolBarCustomization.xhtml
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/listShuttle/examples/toolBarCustomization.xhtml 2007-12-10
16:10:40 UTC (rev 4662)
+++
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/listShuttle/examples/toolBarCustomization.xhtml 2007-12-10
16:20:51 UTC (rev 4663)
@@ -6,25 +6,28 @@
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core">
<h:form>
- <rich:toolBar id="toolBar">
+ <rich:toolBar id="toolBar" itemSeparator="line">
<c:forEach items="#{toolBar.items}" var="item">
<h:outputLink value="#">
<h:outputText value="#{item.label}"></h:outputText>
</h:outputLink>
</c:forEach>
</rich:toolBar>
-
<rich:spacer height="20"></rich:spacer>
- <rich:listShuttle sourceValue="#{toolBar.freeItems}"
targetValue="#{toolBar.items}" var="items"
listHeight="300px">
+ <rich:listShuttle sourceValue="#{toolBar.freeItems}"
targetValue="#{toolBar.items}" var="items"
listHeight="300px" sourceCaptionLabel="Available Items"
targetCaptionLabel="Currently Active Items"
converter="listShuttleconverter">
<rich:column>
+ <f:facet name="header">
+ <h:outputText value="Items List"></h:outputText>
+ </f:facet>
<h:outputText value="#{items.label}"></h:outputText>
</rich:column>
+ <a4j:support event="onorderchanged"
reRender="toolBar"></a4j:support>
</rich:listShuttle>
<rich:spacer height="20"></rich:spacer>
<h:commandButton value="Update Toolbar" reRender="toolBar"/>
-
+ <rich:messages></rich:messages>
</h:form>
</ui:composition>
\ No newline at end of file