[richfaces-svn-commits] JBoss Rich Faces SVN: r4432 - in branches/3.1.x/samples/listShuttleDemo/src/main: webapp/WEB-INF and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Tue Dec 4 00:21:18 EST 2007
Author: nbelaevski
Date: 2007-12-04 00:21:18 -0500 (Tue, 04 Dec 2007)
New Revision: 4432
Added:
branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItemConverter.java
Modified:
branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItem.java
branches/3.1.x/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml
branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
Log:
latest changes for listShuttle & orderingList
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItem.java
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItem.java 2007-12-03 20:37:53 UTC (rev 4431)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItem.java 2007-12-04 05:21:18 UTC (rev 4432)
@@ -39,4 +39,30 @@
public void action() {
System.out.println("ListShuttleOptionItem.action() " + this.toString());
}
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + price;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ListShuttleOptionItem other = (ListShuttleOptionItem) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (price != other.price)
+ return false;
+ return true;
+ }
}
Added: branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItemConverter.java
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItemConverter.java (rev 0)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleOptionItemConverter.java 2007-12-04 05:21:18 UTC (rev 4432)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * @author mikalaj
+ *
+ */
+public class ListShuttleOptionItemConverter implements Converter {
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
+ */
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+
+ int index = value.indexOf(':');
+
+ return new ListShuttleOptionItem(value.substring(0, index), Integer.valueOf(value.substring(index + 1)));
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
+ */
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+
+ ListShuttleOptionItem optionItem = (ListShuttleOptionItem) value;
+ return optionItem.getName() + ":" + optionItem.getPrice();
+ }
+
+}
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-03 20:37:53 UTC (rev 4431)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-04 05:21:18 UTC (rev 4432)
@@ -19,4 +19,10 @@
<managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>converter</managed-bean-name>
+ <managed-bean-class>org.richfaces.ListShuttleOptionItemConverter</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-03 20:37:53 UTC (rev 4431)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-04 05:21:18 UTC (rev 4432)
@@ -25,6 +25,7 @@
fastOrderControlsVisible="#{listShuttleDemoBean.fastOrderControlsVisible}"
moveControlsVisible="#{listShuttleDemoBean.moveControlsVisible}"
fastMoveControlsVisible="#{listShuttleDemoBean.fastMoveControlsVisible}"
+ converter="#{converter}"
>
<h:column><h:outputText value="#{item.name}" /></h:column>
<h:column><h:outputText value="#{item.price}" /></h:column>
More information about the richfaces-svn-commits
mailing list