Author: nbelaevski
Date: 2007-11-27 21:27:14 -0500 (Tue, 27 Nov 2007)
New Revision: 4303
Added:
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoRequestBean.java
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/UIEventsBouncer.java
Modified:
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
Log:
latest changes for orderingList & listShuttle
Added:
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoRequestBean.java
===================================================================
---
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoRequestBean.java
(rev 0)
+++
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoRequestBean.java 2007-11-28
02:27:14 UTC (rev 4303)
@@ -0,0 +1,29 @@
+package org.richfaces;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+
+public class ListShuttleDemoRequestBean {
+
+ private UIComponent eventsBouncer;
+
+ public UIComponent getEventsBouncer() {
+ if (eventsBouncer == null) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIComponent output =
facesContext.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
+ UIOutput o = new UIEventsBouncer();
+
+ o.getAttributes().put("escape", Boolean.FALSE);
+ output.getChildren().add(o);
+
+ eventsBouncer = output;
+ }
+
+ return eventsBouncer;
+ }
+
+ public void setEventsBouncer(UIComponent component) {
+ this.eventsBouncer = component;
+ }
+}
Added:
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/UIEventsBouncer.java
===================================================================
---
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/UIEventsBouncer.java
(rev 0)
+++
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/java/org/richfaces/UIEventsBouncer.java 2007-11-28
02:27:14 UTC (rev 4303)
@@ -0,0 +1,119 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.component.UIDataAdaptor;
+import org.richfaces.component.UIOrderingList;
+
+public final class UIEventsBouncer extends UIOutput {
+ final class Event extends FacesEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1390611902280951049L;
+
+ private Object value;
+
+ private String clientId;
+
+ public Event(UIComponent component, Object value, String clientId, PhaseId phaseId) {
+ super(component);
+
+ this.value = value;
+ this.clientId = clientId;
+
+ setPhaseId(phaseId);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+ }
+
+ private UIDataAdaptor getList() {
+ UIComponent component = getParent();
+ while (component != null && !(component instanceof UIDataAdaptor)) {
+ component = component.getParent();
+ }
+
+ return (UIDataAdaptor) component;
+ }
+
+ private void queueEvent(PhaseId phaseId) {
+ UIDataAdaptor list = getList();
+ if (list.isRowAvailable()) {
+ new Event(this, list.getRowData(),
+ getList().getClientId(FacesContext.getCurrentInstance()), phaseId).queue();
+ }
+ }
+
+ public void processDecodes(FacesContext context) {
+ super.processDecodes(context);
+
+ queueEvent(PhaseId.PROCESS_VALIDATIONS);
+ queueEvent(PhaseId.UPDATE_MODEL_VALUES);
+ queueEvent(PhaseId.INVOKE_APPLICATION);
+ }
+
+ public void processUpdates(FacesContext context) {
+ super.processUpdates(context);
+
+ queueEvent(PhaseId.INVOKE_APPLICATION);
+ }
+
+ public void processValidators(FacesContext context) {
+ super.processValidators(context);
+
+ queueEvent(PhaseId.UPDATE_MODEL_VALUES);
+ queueEvent(PhaseId.INVOKE_APPLICATION);
+ }
+
+ public void broadcast(FacesEvent event)
+ throws AbortProcessingException {
+ if (event instanceof Event) {
+ String cid = getList().getClientId(FacesContext.getCurrentInstance());
+ if (!cid.equals(((Event) event).getClientId())) {
+ System.out.println(cid + " !!! " + ((Event) event).getClientId());
+ FacesMessage message = new FacesMessage("Client ids mismatch: " + cid +
" !!! " + ((Event) event).getClientId());
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ FacesContext.getCurrentInstance().addMessage(cid, message);
+ }
+
+ UIDataAdaptor list = getList();
+ if (list.isRowAvailable()) {
+ Object rd = list.getRowData();
+ if (!rd.equals(((Event) event).getValue())) {
+ System.out.println(rd + " !!! " + ((Event) event).getValue());
+ FacesMessage message = new FacesMessage("Data mismatch: " + rd + "
!!! " + ((Event) event).getValue());
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ FacesContext.getCurrentInstance().addMessage(cid, message);
+ }
+ }
+ } else {
+ super.broadcast(event);
+ }
+ }
+}
\ No newline at end of file
Modified:
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-11-28
02:27:04 UTC (rev 4302)
+++
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-11-28
02:27:14 UTC (rev 4303)
@@ -7,4 +7,10 @@
<managed-bean-class>org.richfaces.ListShuttleDemoBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>listShuttleDemoRequestBean</managed-bean-name>
+
<managed-bean-class>org.richfaces.ListShuttleDemoRequestBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
===================================================================
---
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-11-28
02:27:04 UTC (rev 4302)
+++
branches/3.1.x/sandbox/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-11-28
02:27:14 UTC (rev 4303)
@@ -24,6 +24,8 @@
<h:outputText value="Action Links" />
</f:facet>
<h:commandLink value="Server Action" action="#{item.action}"
/>
+
+ <h:outputText binding="#{listShuttleDemoRequestBean.eventsBouncer}"
/>
</h:column>
</ls:listShuttle>
Show replies by date