Author: nbelaevski
Date: 2007-11-27 21:27:28 -0500 (Tue, 27 Nov 2007)
New Revision: 4305
Added:
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java
Modified:
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp
Log:
latest changes for orderingList & listShuttle
Modified: branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java
===================================================================
---
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java 2007-11-28
02:27:22 UTC (rev 4304)
+++
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java 2007-11-28
02:27:28 UTC (rev 4305)
@@ -28,12 +28,7 @@
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.richfaces.component.UIOrderingList;
/**
* @author $Autor$
@@ -45,103 +40,6 @@
"First", "Second", "Third", "Fourth"
};
- public static final class UIEventsOutput 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 UIOrderingList getList() {
- UIComponent component = getParent();
- while (component != null && !(component instanceof UIOrderingList)) {
- component = component.getParent();
- }
-
- return (UIOrderingList) component;
- }
-
- private void queueEvent(PhaseId phaseId) {
- UIOrderingList 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());
- }
-
- UIOrderingList list = getList();
- if (list.isRowAvailable()) {
- Object rd = list.getRowData();
- if (!rd.equals(((Event) event).getValue())) {
- System.out.println(rd + " !!! " + ((Event) event).getValue());
- }
- }
- } else {
- super.broadcast(event);
- }
- }
- }
-
public Bean() {
for (int i = 0; i < 3; i++) {
lists.add(new OrderingListDemoBean());
@@ -170,7 +68,7 @@
if (eventsBouncer == null) {
FacesContext facesContext = FacesContext.getCurrentInstance();
UIComponent output =
facesContext.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
- UIOutput o = new UIEventsOutput();
+ UIOutput o = new UIEventsBouncer();
o.getAttributes().put("escape", Boolean.FALSE);
output.getChildren().add(o);
Modified:
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
===================================================================
---
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-28
02:27:22 UTC (rev 4304)
+++
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-28
02:27:28 UTC (rev 4305)
@@ -13,7 +13,7 @@
private String controlsType = "link";
private String controlsHorizontalAlign = "right";
private String controlsVerticalAlign = "center";
- private String headerLabel = "headerLabel";
+ private String captionLabel = "Caption";
private String ontopclick = "new Effect.Highlight('form:ontopclickDiv',
{startcolor:'#FF0000', endcolor:'#FF0000', restorecolor:
'green'});";
private String onbottomclick = "new
Effect.Highlight('form:onbottomclickDiv', {startcolor:'#FF0000',
endcolor:'#FF0000', restorecolor: 'green'});";
@@ -59,12 +59,12 @@
this.controlsVerticalAlign = controlsVerticalAlign;
}
- public String getHeaderLabel() {
- return headerLabel;
+ public String getCaptionLabel() {
+ return captionLabel;
}
- public void setHeaderLabel(String headerLabel) {
- this.headerLabel = headerLabel;
+ public void setCaptionLabel(String captionLabel) {
+ this.captionLabel = captionLabel;
}
public boolean isOrderControlsVisible() {
Added:
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
(rev 0)
+++
branches/3.1.x/samples/orderingListDemo/src/main/java/org/richfaces/UIEventsBouncer.java 2007-11-28
02:27:28 UTC (rev 4305)
@@ -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/samples/orderingListDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-28
02:27:22 UTC (rev 4304)
+++ branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-28
02:27:28 UTC (rev 4305)
@@ -41,7 +41,7 @@
<h:panelGroup>
<ol:orderingList id="orderingList1"
value="#{demoBean.items}" var="item"
- headerLabel="#{demoBean.headerLabel}"
+ captionLabel="#{demoBean.captionLabel}"
controlsType="#{demoBean.controlsType}"
controlsHorizontalAlign="#{demoBean.controlsHorizontalAlign}"
controlsVerticalAlign="#{demoBean.controlsVerticalAlign}"
@@ -113,8 +113,8 @@
<h:outputText value="Item Clicked: " />
<h:outputText value="#{demoBean.actionResult}"
id="actionResult" />
- <h:outputText value="Header Label" />
- <h:inputText value="#{demoBean.headerLabel}" >
+ <h:outputText value="Caption Label" />
+ <h:inputText value="#{demoBean.captionLabel}" >
<a4j:support event="onchange" reRender="orderingList1"
/>
</h:inputText>
@@ -165,8 +165,6 @@
<a4j:support event="onchange" reRender="orderingList1"
/>
</h:inputText>
- <h:commandButton value="Submit" />
- <h:commandButton value="Submit immediate" immediate="true"
/>
</h:panelGrid>
</h:panelGroup>
<h:panelGroup>
@@ -181,6 +179,8 @@
</ol:orderingList>
</h:panelGroup>
</h:panelGrid>
+ <h:commandButton value="Submit" />
+ <h:commandButton value="Submit immediate" immediate="true"
/>
<h3>Ordering lists within a4j:repeat</h3>
<a4j:commandButton reRender="repeat" value="Rerender
a4j:repeat" />
<h:commandButton value="Clear list"
action="#{demoBean.clear}"></h:commandButton>