Author: nbelaevski
Date: 2007-11-11 17:43:38 -0500 (Sun, 11 Nov 2007)
New Revision: 3892
Modified:
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp
Log:
more features for orderingList implemented
Modified: trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java
===================================================================
---
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java 2007-11-11
16:52:54 UTC (rev 3891)
+++
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/Bean.java 2007-11-11
22:43:38 UTC (rev 3892)
@@ -24,6 +24,16 @@
import java.util.ArrayList;
import java.util.List;
+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$
*
@@ -34,6 +44,97 @@
"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) {
+ new Event(this, getList().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());
+ }
+
+ Object rd = getList().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());
@@ -55,4 +156,26 @@
public void setSimpleItems(String[] simpleItems) {
this.simpleItems = simpleItems;
}
+
+ private UIComponent eventsBouncer;
+
+ public UIComponent getEventsBouncer() {
+ if (eventsBouncer == null) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIComponent output =
facesContext.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
+ UIOutput o = new UIEventsOutput();
+
+ o.getAttributes().put("escape", Boolean.FALSE);
+ output.getChildren().add(o);
+
+ eventsBouncer = output;
+ }
+
+ return eventsBouncer;
+ }
+
+ public void setEventsBouncer(UIComponent component) {
+ this.eventsBouncer = component;
+ }
+
}
\ No newline at end of file
Modified:
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
===================================================================
---
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-11
16:52:54 UTC (rev 3891)
+++
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-11
22:43:38 UTC (rev 3892)
@@ -103,4 +103,5 @@
this.onbottomclick = onbottomclick;
}
+
}
Modified: trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-11
16:52:54 UTC (rev 3891)
+++ trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-11
22:43:38 UTC (rev 3892)
@@ -35,12 +35,7 @@
orderControlsVisible="#{demoBean.orderControlsVisible}"
fastOrderControlsVisible="#{demoBean.fastOrderControlsVisible}"
- ontopclick="#{demoBean.ontopclick}"
- onbottomclick="#{demoBean.onbottomclick}"
- onorderchanged="alert('onorderchanged');"
- ondownclick="alert('ondownclick');"
- onheaderclick="alert('onheaderclick');"
- onupclick="alert('onupclick');" >
+ >
<h:column>
<f:facet name="header">
@@ -66,6 +61,9 @@
<h:outputText value="Server Action" />
</f:facet>
<h:commandLink value="Server Action"
action="#{item.action}" />
+ </h:column>
+ <h:column>
+ <h:outputText
binding="#{bean.eventsBouncer}"></h:outputText>
</h:column>
</ol:orderingList>
Show replies by date