[richfaces-svn-commits] JBoss Rich Faces SVN: r4434 - in branches/3.1.x/samples/orderingListDemo/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:43 EST 2007
Author: nbelaevski
Date: 2007-12-04 00:21:42 -0500 (Tue, 04 Dec 2007)
New Revision: 4434
Added:
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItemConverter.java
Modified:
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java
branches/3.1.x/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml
branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp
Log:
latest changes for listShuttle & orderingList
Modified: branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java 2007-12-04 05:21:32 UTC (rev 4433)
+++ branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java 2007-12-04 05:21:42 UTC (rev 4434)
@@ -36,4 +36,30 @@
return this.getClass().getSimpleName() + " [" + name + "] by " + price;
}
+ 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;
+ OptionItem other = (OptionItem) 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/orderingListDemo/src/main/java/org/richfaces/OptionItemConverter.java
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItemConverter.java (rev 0)
+++ branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OptionItemConverter.java 2007-12-04 05:21:42 UTC (rev 4434)
@@ -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 OptionItemConverter 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 OptionItem(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) {
+
+ OptionItem optionItem = (OptionItem) value;
+ return optionItem.getName() + ":" + optionItem.getPrice();
+ }
+
+}
Modified: branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java 2007-12-04 05:21:32 UTC (rev 4433)
+++ branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java 2007-12-04 05:21:42 UTC (rev 4434)
@@ -13,9 +13,10 @@
import javax.faces.event.PhaseId;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.richfaces.component.UIOrderingList;
public final class UIEventsBouncer extends UIOutput {
+ private PhaseId phaseId;
+
final class Event extends FacesEvent {
/**
@@ -73,6 +74,8 @@
public void processDecodes(FacesContext context) {
super.processDecodes(context);
+ this.phaseId = PhaseId.APPLY_REQUEST_VALUES;
+
queueEvent(PhaseId.PROCESS_VALIDATIONS);
queueEvent(PhaseId.UPDATE_MODEL_VALUES);
queueEvent(PhaseId.INVOKE_APPLICATION);
@@ -81,12 +84,16 @@
public void processUpdates(FacesContext context) {
super.processUpdates(context);
+ this.phaseId = PhaseId.UPDATE_MODEL_VALUES;
+
queueEvent(PhaseId.INVOKE_APPLICATION);
}
public void processValidators(FacesContext context) {
super.processValidators(context);
+ this.phaseId = PhaseId.PROCESS_VALIDATIONS;
+
queueEvent(PhaseId.UPDATE_MODEL_VALUES);
queueEvent(PhaseId.INVOKE_APPLICATION);
}
@@ -97,6 +104,7 @@
String cid = getList().getClientId(FacesContext.getCurrentInstance());
if (!cid.equals(((Event) event).getClientId())) {
System.out.println(cid + " !!! " + ((Event) event).getClientId());
+ System.out.println(phaseId + " " + event.getPhaseId());
FacesMessage message = new FacesMessage("Client ids mismatch: " + cid + " !!! " + ((Event) event).getClientId());
message.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(cid, message);
@@ -107,6 +115,7 @@
Object rd = list.getRowData();
if (!rd.equals(((Event) event).getValue())) {
System.out.println(rd + " !!! " + ((Event) event).getValue());
+ System.out.println(phaseId + " " + event.getPhaseId());
FacesMessage message = new FacesMessage("Data mismatch: " + rd + " !!! " + ((Event) event).getValue());
message.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(cid, message);
Modified: branches/3.1.x/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-04 05:21:32 UTC (rev 4433)
+++ branches/3.1.x/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-04 05:21:42 UTC (rev 4434)
@@ -21,4 +21,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.OptionItemConverter</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-12-04 05:21:32 UTC (rev 4433)
+++ branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-12-04 05:21:42 UTC (rev 4434)
@@ -40,6 +40,7 @@
<h:panelGrid columns="2" columnClasses="columnClass">
<h:panelGroup>
<ol:orderingList id="orderingList1"
+ converter="#{converter}"
value="#{demoBean.items}" var="item"
captionLabel="#{demoBean.captionLabel}"
controlsType="#{demoBean.controlsType}"
@@ -186,7 +187,7 @@
<h:commandButton value="Clear list" action="#{demoBean.clear}"></h:commandButton>
<h:panelGrid columns="3" >
<a4j:repeat value="#{bean.lists}" var="list" id="repeat">
- <ol:orderingList value="#{list.items}" var="item" >
+ <ol:orderingList value="#{list.items}" var="item" converter="#{converter}">
<h:column>
<f:facet name="header">
<h:outputText value="Name" />
More information about the richfaces-svn-commits
mailing list