JBoss Rich Faces SVN: r19525 - in trunk/ui/input: ui/src/main/java/org/richfaces/renderkit and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-11 14:04:10 -0400 (Mon, 11 Oct 2010)
New Revision: 19525
Modified:
trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
Log:
add disable state (RF-9348)
Modified: trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 18:04:10 UTC (rev 19525)
@@ -31,5 +31,6 @@
public enum InplaceState {
ready,
edit,
- changed
+ changed,
+ disable
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 18:04:10 UTC (rev 19525)
@@ -43,148 +43,202 @@
* @author Anton Belevich
*
*/
-@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-event.js"),
- @ResourceDependency(name = "richfaces-base-component.js"),
- @ResourceDependency(library="org.richfaces", name = "inplaceBase.js"),
- @ResourceDependency(library="org.richfaces", name = "inplaceInput.js"),
- @ResourceDependency(library="org.richfaces", name = "inplaceInput.ecss") })
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(library = "org.richfaces", name = "inplaceBase.js"),
+ @ResourceDependency(library = "org.richfaces", name = "inplaceInput.js"),
+ @ResourceDependency(library = "org.richfaces", name = "inplaceInput.ecss") })
public class InplaceInputBaseRenderer extends InputRendererBase {
-
+
public static final String OPTIONS_EDIT_EVENT = "editEvent";
+ public static final String OPTIONS_STATE = "state";
+
public static final String OPTIONS_EDIT_CONTAINER = "editContainer";
-
+
public static final String OPTIONS_INPUT = "input";
-
+
public static final String OPTIONS_FOCUS = "focusElement";
-
+
public static final String OPTIONS_BUTTON_OK = "okbtn";
-
+
public static final String OPTIONS_LABEL = "label";
-
+
public static final String OPTIONS_DEFAULT_LABEL = "defaultLabel";
-
+
public static final String OPTIONS_BUTTON_CANCEL = "cancelbtn";
-
+
public static final String OPTIONS_SHOWCONTROLS = "showControls";
-
+
public static final String OPTIONS_NONE_CSS = "noneCss";
-
+
public static final String OPTIONS_CHANGED_CSS = "changedCss";
+ public static final String OPTIONS_EDIT_CSS = "editCss";
+
public static final String OPTIONS_INITIAL_VALUE = "initialValue";
-
+
public static final String OPTIONS_SAVE_ON_BLUR = "saveOnBlur";
-
private static final Map<String, ComponentAttribute> INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
- .unmodifiableMap(ComponentAttribute.createMap(
- new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE).setEventNames("inputclick").
- setComponentAttributeName("oninputclick"),
- new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE).setEventNames("inputdblclick").
- setComponentAttributeName("oninputdblclick"),
- new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputmousedown").
- setComponentAttributeName("oninputmousedown"),
- new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE).setEventNames("inputmouseup").
- setComponentAttributeName("oninputmouseup"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputmouseover").
- setComponentAttributeName("oninputmouseover"),
- new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputmousemove").
- setComponentAttributeName("oninputmousemove"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputmouseout").
- setComponentAttributeName("oninputmouseout"),
- new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE).setEventNames("inputkeypress").
- setComponentAttributeName("oninputkeypress"),
- new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE).setEventNames("inputkeydown").
- setComponentAttributeName("oninputkeydown"),
- new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE).setEventNames("inputkeyup").
- setComponentAttributeName("oninputkeyup"),
- new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE).setEventNames("inputblur").
- setComponentAttributeName("oninputblur"),
- new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE).setEventNames("inputfocus").
- setComponentAttributeName("oninputfocus"),
- new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE).setEventNames("change").
- setComponentAttributeName("onchange"),
- new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE).setEventNames("select").
- setComponentAttributeName("onselect")
- ));
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
+ .setEventNames("inputclick")
+ .setComponentAttributeName("oninputclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
+ .setEventNames("inputdblclick")
+ .setComponentAttributeName("oninputdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
+ .setEventNames("inputmousedown")
+ .setComponentAttributeName("oninputmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
+ .setEventNames("inputmouseup")
+ .setComponentAttributeName("oninputmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
+ .setEventNames("inputmouseover")
+ .setComponentAttributeName("oninputmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
+ .setEventNames("inputmousemove")
+ .setComponentAttributeName("oninputmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
+ .setEventNames("inputmouseout")
+ .setComponentAttributeName("oninputmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
+ .setEventNames("inputkeypress")
+ .setComponentAttributeName("oninputkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
+ .setEventNames("inputkeydown")
+ .setComponentAttributeName("oninputkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
+ .setEventNames("inputkeyup")
+ .setComponentAttributeName("oninputkeyup"),
+ new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE)
+ .setEventNames("inputblur")
+ .setComponentAttributeName("oninputblur"),
+ new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE)
+ .setEventNames("inputfocus")
+ .setComponentAttributeName("oninputfocus"),
+ new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE)
+ .setEventNames("change").setComponentAttributeName(
+ "onchange"),
+ new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE)
+ .setEventNames("select").setComponentAttributeName(
+ "onselect")));
- protected void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
- RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACEINPUT_HANDLER_ATTRIBUTES);
+ protected void renderInputHandlers(FacesContext facesContext,
+ UIComponent component) throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext,
+ component, INPLACEINPUT_HANDLER_ATTRIBUTES);
}
-
+
public InplaceState getInplaceState(UIComponent component) {
return ((InplaceComponent) component).getState();
}
public String getValue(FacesContext facesContext, UIComponent component) throws IOException {
String value = getInputValue(facesContext, component);
- if(value == null || "".equals(value)) {
- value = ((InplaceComponent)component).getDefaultLabel();
+ if (!isDisable(getInplaceState(component)) && (value == null || "".equals(value)) ) {
+ value = ((InplaceComponent) component).getDefaultLabel();
}
return value;
}
-
+
public String getResourcePath(FacesContext context, String resourceName) {
if (resourceName != null) {
- ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
+ ResourceHandler resourceHandler = context.getApplication()
+ .getResourceHandler();
Resource resource = resourceHandler.createResource(resourceName);
return resource.getRequestPath();
}
return null;
}
- public String getReadyStyleClass(UIComponent component, InplaceState inplaceState) {
- return (InplaceState.changed != inplaceState) ? getReadyStateCss() : HtmlUtil.concatClasses(getReadyStateCss(), getChangedStateCss());
+ public String getStateStyleClass(UIComponent component,
+ InplaceState inplaceState) {
+ String style = getReadyStateCss();
+ switch (inplaceState) {
+ case edit:
+ style = HtmlUtil.concatClasses(style, getEditStateCss());
+ break;
+
+ case changed:
+ style = HtmlUtil.concatClasses(style, getChangedStateCss());
+ break;
+
+ case disable:
+ style = getDisableStateCss();
+ break;
+
+ default:
+ break;
+ }
+
+ return style;
}
- public String getEditStyleClass(UIComponent component, InplaceState inplaceState) {
- return (InplaceState.edit != inplaceState)? HtmlUtil.concatClasses(getEditStateCss(), getNoneCss()) : getEditStateCss();
+ public boolean isDisable(InplaceState currentState) {
+ return (InplaceState.disable == currentState);
}
- public String getReadyClientId(FacesContext facesContext, UIComponent component, InplaceState inplaceState) {
+
+ public String getEditStyleClass(UIComponent component,
+ InplaceState inplaceState) {
+ return (InplaceState.edit != inplaceState) ? HtmlUtil.concatClasses(getEditCss(), getNoneCss()) : getEditCss();
+ }
+
+ public String getReadyClientId(FacesContext facesContext,
+ UIComponent component, InplaceState inplaceState) {
String clientId = component.getClientId(facesContext);
return getId(clientId, InplaceState.ready, inplaceState);
}
- public String getChangedClientId(FacesContext facesContext, UIComponent component, InplaceState inplaceState) {
+ public String getChangedClientId(FacesContext facesContext,
+ UIComponent component, InplaceState inplaceState) {
String clientId = component.getClientId(facesContext);
return getId(clientId, InplaceState.changed, inplaceState);
}
- private String getId(String clientId, InplaceState expect, InplaceState current) {
+ private String getId(String clientId, InplaceState expect,
+ InplaceState current) {
String result = clientId;
if (expect != current) {
result = clientId + ":" + expect;
}
return result;
}
-
- public void buildScript(ResponseWriter writer, FacesContext facesContext, UIComponent component, Object additional) throws IOException {
- if(!(component instanceof InplaceComponent)) {
+
+ public void buildScript(ResponseWriter writer, FacesContext facesContext,
+ UIComponent component, Object additional) throws IOException {
+ if (!(component instanceof InplaceComponent)) {
return;
}
String scriptName = getScriptName();
JSFunction function = new JSFunction(scriptName);
String clientId = component.getClientId(facesContext);
- Map<String, Object> options = createInplaceComponentOptions(clientId, (InplaceComponent)component);
+ Map<String, Object> options = createInplaceComponentOptions(clientId,
+ (InplaceComponent) component);
addToOptions(facesContext, component, options, additional);
function.addParameter(clientId);
function.addParameter(options);
writer.write(function.toString());
}
-
+
protected String getScriptName() {
return "new RichFaces.ui.InplaceInput";
}
-
- private Map<String, Object> createInplaceComponentOptions(String clientId, InplaceComponent inplaceComponent) {
+
+ private Map<String, Object> createInplaceComponentOptions(String clientId,
+ InplaceComponent inplaceComponent) {
Map<String, Object> options = new HashMap<String, Object>();
options.put(OPTIONS_EDIT_EVENT, inplaceComponent.getEditEvent());
+ options.put(OPTIONS_STATE, inplaceComponent.getState());
options.put(OPTIONS_NONE_CSS, getNoneCss());
options.put(OPTIONS_CHANGED_CSS, getChangedStateCss());
+ options.put(OPTIONS_EDIT_CSS, getEditStateCss());
options.put(OPTIONS_EDIT_CONTAINER, clientId + ":edit");
options.put(OPTIONS_INPUT, clientId + ":input");
options.put(OPTIONS_LABEL, clientId + ":label");
@@ -193,31 +247,40 @@
options.put(OPTIONS_SAVE_ON_BLUR, inplaceComponent.isSaveOnBlur());
boolean showControls = inplaceComponent.isShowControls();
-
+
options.put(OPTIONS_SHOWCONTROLS, showControls);
- if(showControls) {
+ if (showControls) {
options.put(OPTIONS_BUTTON_OK, clientId + ":okbtn");
options.put(OPTIONS_BUTTON_CANCEL, clientId + ":cancelbtn");
}
return options;
}
- public void addToOptions(FacesContext facesContext, UIComponent component, Map<String, Object> options, Object additional) {
- //override this method if you need additional options
+ public void addToOptions(FacesContext facesContext, UIComponent component,
+ Map<String, Object> options, Object additional) {
+ // override this method if you need additional options
}
-
+
public String getReadyStateCss() {
return "rf-ii-d-s";
}
-
+
public String getEditStateCss() {
return "rf-ii-e-s";
}
-
+
public String getChangedStateCss() {
return "rf-ii-c-s";
}
-
+
+ public String getDisableStateCss() {
+ return "rf-ii-dis-s";
+ }
+
+ public String getEditCss() {
+ return "rf-ii-edit";
+ }
+
public String getNoneCss() {
return "rf-ii-none";
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 18:04:10 UTC (rev 19525)
@@ -198,7 +198,7 @@
UIComponent component) {
AbstractInplaceSelect select = (AbstractInplaceSelect) component;
String label = getSelectInputLabel(facesContext, select);
- if (label == null) {
+ if (!isDisable(getInplaceState(component)) && (label == null)) {
label = select.getDefaultLabel();
}
return label;
@@ -240,6 +240,14 @@
return "rf-is-c-s";
}
+ public String getDisableStateCss() {
+ return "rf-is-dis-s";
+ }
+
+ public String getEditCss() {
+ return "rf-is-edit";
+ }
+
public String getNoneCss() {
return "rf-is-none";
}
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 18:04:10 UTC (rev 19525)
@@ -33,13 +33,15 @@
this.noneCss = options.noneCss;
this.changedCss = options.changedCss;
this.defaultLabel = options.defaultLabel;
+ this.state = options.state;
this.element = $(document.getElementById(id));
this.editContainer = $(document.getElementById(options.editContainer));
+ this.state = options.state;
- this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
-
- this.isSaved = false;
+ this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
+
+ this.isSaved = false;
this.useDefaultLabel = false;
};
@@ -48,7 +50,14 @@
var $super = rf.ui.InplaceBase.$super;
$.extend(rf.ui.InplaceBase.prototype, ( function () {
-
+
+ var STATE = {
+ READY : 'ready',
+ CHANGED: 'changed',
+ DISABLE: 'disable',
+ EDIT: 'edit'
+ };
+
return {
getName: function() {
},
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-10-11 18:04:10 UTC (rev 19525)
@@ -14,6 +14,17 @@
font-size : inherit;
}
+.rf-ii-edit {
+ position : absolute;
+ top : 0px;
+ left : 0px;
+ display : inline-block;
+ width: 100%;
+}
+
+.rf-ii-dis-s {
+}
+
.rf-ii-lbl {
white-space : nowrap;
}
@@ -39,11 +50,6 @@
}
.rf-ii-e-s {
- position : absolute;
- top : 0px;
- left : 0px;
- display : inline-block;
- width: 100%;
}
.rf-ii-fld {
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-11 18:04:10 UTC (rev 19525)
@@ -19,6 +19,17 @@
clip: rect(0px, 0px, 1px, 1px);
}
+.rf-is-dis-s {
+}
+
+.rf-is-edit {
+ position : absolute;
+ top : 0px;
+ left : 0px;
+ width : 100px;
+ background-color : '#{richSkin.editBackgroundColor}';
+}
+
.rf-is-fnt {
}
@@ -42,11 +53,6 @@
}
.rf-is-e-s {
- position : absolute;
- top : 0px;
- left : 0px;
- width : 100px;
- background-color : '#{richSkin.editBackgroundColor}';
}
.rf-is-fld {
Modified: trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-10-11 18:04:10 UTC (rev 19525)
@@ -41,47 +41,50 @@
<cc:implementation>
<cdk:object type="org.richfaces.component.InplaceState" name="inplaceState" value="#{getInplaceState(component)}" />
<cdk:object type="java.lang.String" name="inplaceValue" value="#{getValue(facesContext, component)}" />
-
- <span id="#{clientId}" class="#{getReadyStyleClass(component, inplaceState)}" cdk:passThroughWithExclusions="id class">
+
+ <span id="#{clientId}" class="#{getStateStyleClass(component, inplaceState)}" cdk:passThroughWithExclusions="id class">
<span id="#{clientId}:label" class="rf-ii-lbl">
#{inplaceValue}
</span>
- <input id="#{clientId}:focus" type="image" style="position: absolute; top: 0px; left: 0px; outline-style: none;" class="rf-ii-none"/>
- <span id="#{clientId}:edit" class="#{getEditStyleClass(component, inplaceState)}">
- <input id="#{clientId}:input" autocomplete="off" name="#{clientId}"
- type="text" value="#{getInputValue(facesContext, component)}" class="rf-ii-fld" style="width: #{component.attributes['inputWidth']};" cdk:passThrough="tabIndex">
- <cdk:call expression="renderInputHandlers(facesContext, component);"/>
- </input>
- <c:if test="#{component.attributes['showControls']}">
- <span class="rf-ii-btn-prepos">
- <span class="rf-ii-btn-pos">
- <span id="#{clientId}:btnshadow" class="rf-ii-btn-shadow">
- <span class="rf-ii-btn-shdw-t"></span>
- <span class="rf-ii-btn-shdw-l"></span>
- <span class="rf-ii-btn-shdw-r"></span>
- <span class="rf-ii-btn-shdw-b"></span>
-
- <span id="#{clientId}:btn" style="position : relative">
- <input type="image"
- id="#{clientId}:okbtn"
- src="#{getResourcePath(facesContext, 'org.richfaces/ico_ok.gif')}"
- class="rf-ii-btn" onmousedown="this.className='rf-ii-btn-p'"
- onmouseout="this.className='rf-ii-btn'" onmouseup="this.className='rf-ii-btn'" />
- <input type="image"
- id="#{clientId}:cancelbtn"
- src="#{getResourcePath(facesContext,'org.richfaces/ico_cancel.gif')}"
- class="rf-ii-btn" onmousedown="this.className='rf-ii-btn-press'"
- onmouseout="this.className='rf-ii-btn'" onmouseup="this.className='rf-ii-btn'" />
- <br />
+
+ <c:if test="#{!isDisable(inplaceState)}">
+ <input id="#{clientId}:focus" type="image" style="position: absolute; top: 0px; left: 0px; outline-style: none;" class="rf-ii-none"/>
+ <span id="#{clientId}:edit" class="#{getEditStyleClass(component, inplaceState)}">
+ <input id="#{clientId}:input" autocomplete="off" name="#{clientId}"
+ type="text" value="#{getInputValue(facesContext, component)}" class="rf-ii-fld" style="width: #{component.attributes['inputWidth']};" cdk:passThrough="tabIndex">
+ <cdk:call expression="renderInputHandlers(facesContext, component);"/>
+ </input>
+ <c:if test="#{component.attributes['showControls']}">
+ <span class="rf-ii-btn-prepos">
+ <span class="rf-ii-btn-pos">
+ <span id="#{clientId}:btnshadow" class="rf-ii-btn-shadow">
+ <span class="rf-ii-btn-shdw-t"></span>
+ <span class="rf-ii-btn-shdw-l"></span>
+ <span class="rf-ii-btn-shdw-r"></span>
+ <span class="rf-ii-btn-shdw-b"></span>
+
+ <span id="#{clientId}:btn" style="position : relative">
+ <input type="image"
+ id="#{clientId}:okbtn"
+ src="#{getResourcePath(facesContext, 'org.richfaces/ico_ok.gif')}"
+ class="rf-ii-btn" onmousedown="this.className='rf-ii-btn-p'"
+ onmouseout="this.className='rf-ii-btn'" onmouseup="this.className='rf-ii-btn'" />
+ <input type="image"
+ id="#{clientId}:cancelbtn"
+ src="#{getResourcePath(facesContext,'org.richfaces/ico_cancel.gif')}"
+ class="rf-ii-btn" onmousedown="this.className='rf-ii-btn-press'"
+ onmouseout="this.className='rf-ii-btn'" onmouseup="this.className='rf-ii-btn'" />
+ <br />
+ </span>
</span>
</span>
</span>
- </span>
- </c:if>
- </span>
- <script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component, null);"/>
- </script>
+ </c:if>
+ </span>
+ <script type="text/javascript">
+ <cdk:call expression="buildScript(responseWriter, facesContext, component, null);"/>
+ </script>
+ </c:if>
</span>
</cc:implementation>
</cdk:root>
\ No newline at end of file
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-11 18:04:10 UTC (rev 19525)
@@ -37,66 +37,68 @@
<cdk:object type="java.util.List" type-arguments="InplaceSelectBaseRenderer.ClientSelectItem" name="clientSelectItems"
value="#{getConvertedSelectItems(facesContext, component)}" />
- <span id="#{clientId}" class="#{getReadyStyleClass(component, inplaceState)}"
+ <span id="#{clientId}" class="#{getStateStyleClass(component, inplaceState)}"
cdk:passThroughWithExclusions="id class">
<span id="#{clientId}:label" class="rf-is-lbl">
#{inplaceValue}
</span>
- <input id="#{clientId}:focus" type="image" style="position: absolute; top: 0px; left: 0px; outline-style: none;" class="rf-is-none" />
-
- <span id="#{clientId}:edit" class="#{getEditStyleClass(component, inplaceState)}">
- <input id="#{clientId}selValue" name="#{clientId}" type="hidden" value="#{getValue(facesContext, component)}"/>
- <input id="#{clientId}:input" autocomplete="off"
- type="text" value="#{getSelectInputLabel(facesContext, component)}"
- class="rf-is-fld" style="width: #{component.attributes['inputWidth']};" readonly="readonly"
- cdk:passThrough="tabIndex">
- <cdk:call expression="renderInputHandlers(facesContext, component);" />
- </input>
- <c:if test="#{component.attributes['showControls']}">
- <span class="rf-is-btn-prepos">
- <span class="rf-is-btn-pos">
- <span id="#{clientId}:btnshadow" class="rf-is-shdw">
+ <c:if test="#{!isDisable(inplaceState)}">
+ <input id="#{clientId}:focus" type="image" style="position: absolute; top: 0px; left: 0px; outline-style: none;" class="rf-is-none" />
+
+ <span id="#{clientId}:edit" class="#{getEditStyleClass(component, inplaceState)}">
+ <input id="#{clientId}selValue" name="#{clientId}" type="hidden" value="#{getValue(facesContext, component)}"/>
+ <input id="#{clientId}:input" autocomplete="off"
+ type="text" value="#{getSelectInputLabel(facesContext, component)}"
+ class="rf-is-fld" style="width: #{component.attributes['inputWidth']};" readonly="readonly"
+ cdk:passThrough="tabIndex">
+ <cdk:call expression="renderInputHandlers(facesContext, component);" />
+ </input>
+ <c:if test="#{component.attributes['showControls']}">
+ <span class="rf-is-btn-prepos">
+ <span class="rf-is-btn-pos">
+ <span id="#{clientId}:btnshadow" class="rf-is-shdw">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+
+ <span id="#{clientId}:btn" style="position : relative;">
+ <input type="image" id="#{clientId}:okbtn"
+ src="#{getResourcePath(facesContext, 'org.richfaces/ico_ok.gif')}"
+ class="rf-is-btn" onmousedown="this.className='rf-is-btn-press'"
+ onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" />
+ <input type="image" id="#{clientId}:cancelbtn"
+ src="#{getResourcePath(facesContext,'org.richfaces/ico_cancel.gif')}"
+ class="rf-is-btn" onmousedown="this.className='rf-is-btn-press'"
+ onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" />
+ <br />
+ </span>
+ </span>
+ </span>
+ </span>
+ </c:if>
+ <span id="#{clientId}List" class="rf-is-none rf-is-lst-cord">
+ <span class="rf-is-lst-pos" style="width: #{component.attributes['listWidth']}">
+ <span class="rf-is-shdw">
<span class="rf-is-shdw-t"></span>
<span class="rf-is-shdw-l"></span>
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
-
- <span id="#{clientId}:btn" style="position : relative;">
- <input type="image" id="#{clientId}:okbtn"
- src="#{getResourcePath(facesContext, 'org.richfaces/ico_ok.gif')}"
- class="rf-is-btn" onmousedown="this.className='rf-is-btn-press'"
- onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" />
- <input type="image" id="#{clientId}:cancelbtn"
- src="#{getResourcePath(facesContext,'org.richfaces/ico_cancel.gif')}"
- class="rf-is-btn" onmousedown="this.className='rf-is-btn-press'"
- onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" />
- <br />
+ <span class="rf-is-lst-dec">
+ <span class="rf-is-lst-scrl" id="#{clientId}Items" style="height: #{component.attributes['listHeight']}">
+ <cdk:call expression="encodeOptions(facesContext, component, clientSelectItems);"/>
+ </span>
</span>
</span>
</span>
</span>
- </c:if>
- <span id="#{clientId}List" class="rf-is-none rf-is-lst-cord">
- <span class="rf-is-lst-pos" style="width: #{component.attributes['listWidth']}">
- <span class="rf-is-shdw">
- <span class="rf-is-shdw-t"></span>
- <span class="rf-is-shdw-l"></span>
- <span class="rf-is-shdw-r"></span>
- <span class="rf-is-shdw-b"></span>
- <span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="#{clientId}Items" style="height: #{component.attributes['listHeight']}">
- <cdk:call expression="encodeOptions(facesContext, component, clientSelectItems);"/>
- </span>
- </span>
- </span>
- </span>
</span>
- </span>
- <script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component, clientSelectItems);" />
- </script>
+ <script type="text/javascript">
+ <cdk:call expression="buildScript(responseWriter, facesContext, component, clientSelectItems);" />
+ </script>
+ </c:if>
</span>
</cc:implementation>
</cdk:root>
\ No newline at end of file
Modified: trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
===================================================================
--- trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-10-11 17:10:02 UTC (rev 19524)
+++ trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-10-11 18:04:10 UTC (rev 19525)
@@ -69,7 +69,7 @@
HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_default:edit']");
assertEquals("span", edit.getNodeName());
- assertEquals("rf-ii-e-s rf-ii-none", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
+ assertEquals("rf-ii-edit rf-ii-none", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
HtmlElement input = (HtmlElement)edit.getFirstChild();
assertEquals("input", input.getNodeName());
@@ -87,7 +87,7 @@
HtmlElement span = page.getFirstByXPath("//*[@id = 'form:input_edit']");
assertEquals("span", span.getNodeName());
- assertEquals("rf-ii-d-s", span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
+ assertEquals("rf-ii-d-s rf-ii-e-s", span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
HtmlElement label = (HtmlElement)span.getFirstChild();
assertEquals("span", label.getNodeName());
@@ -97,7 +97,7 @@
HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_edit:edit']");
assertEquals("span", edit.getNodeName());
- assertEquals("rf-ii-e-s", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
+ assertEquals("rf-ii-edit", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
HtmlElement input = (HtmlElement)edit.getFirstChild();
assertEquals("input", input.getNodeName());
@@ -145,7 +145,7 @@
HtmlElement span = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + "']");
span.click();
HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + ":edit']");
- assertEquals("rf-ii-e-s", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
+ assertEquals("rf-ii-edit", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
typeNewValue(page, inplaceInputId, value);
}
15 years, 7 months
JBoss Rich Faces SVN: r19524 - in branches/RF-8742: ui/input/api/src/main/java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-11 13:10:02 -0400 (Mon, 11 Oct 2010)
New Revision: 19524
Modified:
branches/RF-8742/
branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
Log:
Merged revisions 19517-19519 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r19517 | abelevich | 2010-10-11 05:22:58 -0700 (Mon, 11 Oct 2010) | 1 line
refactor scripts
.......
r19518 | abelevich | 2010-10-11 06:16:22 -0700 (Mon, 11 Oct 2010) | 1 line
https://jira.jboss.org/browse/RF-9431
.......
r19519 | abelevich | 2010-10-11 07:13:05 -0700 (Mon, 11 Oct 2010) | 1 line
add license headers, add events for the inplaceSelect component
.......
Property changes on: branches/RF-8742
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-19508
+ /trunk:1-19522
Modified: branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
===================================================================
--- branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -1,6 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
+/**
+ * @author Anton Belevich
+ *
+ */
public interface InplaceComponent {
public String getDefaultLabel();
Modified: branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
===================================================================
--- branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -19,8 +19,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+
package org.richfaces.component;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
public enum InplaceState {
ready,
edit,
Modified: branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -103,41 +103,41 @@
@Attribute(events=@EventName("mouseup"))
public abstract String getOnmouseup();
- @Attribute(events=@EventName("inputClick"))
- public abstract String getOnInputClick();
+ @Attribute(events=@EventName("inputclick"))
+ public abstract String getOninputclick();
- @Attribute(events=@EventName("inputDblclick"))
- public abstract String getOnInputDblclick();
+ @Attribute(events=@EventName("inputdblclick"))
+ public abstract String getOninputdblclick();
- @Attribute(events=@EventName("inputMousedown"))
- public abstract String getOnInputMousedown();
+ @Attribute(events=@EventName("inputmousedown"))
+ public abstract String getOninputmousedown();
- @Attribute(events=@EventName("inputMousemove"))
- public abstract String getOnInputMousemove();
+ @Attribute(events=@EventName("inputmousemove"))
+ public abstract String getOninputmousemove();
- @Attribute(events=@EventName("inputMouseout"))
- public abstract String getOnInputMouseout();
+ @Attribute(events=@EventName("inputmouseout"))
+ public abstract String getOninputmouseout();
- @Attribute(events=@EventName("inputMouseover"))
- public abstract String getOnInputMouseover();
+ @Attribute(events=@EventName("inputmouseover"))
+ public abstract String getOninputmouseover();
- @Attribute(events=@EventName("inputMouseup"))
- public abstract String getOnInputMouseup();
+ @Attribute(events=@EventName("inputmouseup"))
+ public abstract String getOninputmouseup();
- @Attribute(events=@EventName("inputKeydown"))
- public abstract String getOnInputKeydown();
+ @Attribute(events=@EventName("inputkeydown"))
+ public abstract String getOninputkeydown();
- @Attribute(events=@EventName("inputKeypress"))
- public abstract String getOnInputKeypress();
+ @Attribute(events=@EventName("inputkeypress"))
+ public abstract String getOninputkeypress();
- @Attribute(events=@EventName("oninputKeyup"))
- public abstract String getOnInputKeypup();
+ @Attribute(events=@EventName("oninputkeyup"))
+ public abstract String getOninputkeypup();
- @Attribute(events=@EventName("inputFocus"))
- public abstract String getOnInputFocus();
+ @Attribute(events=@EventName("inputfocus"))
+ public abstract String getOninputfocus();
- @Attribute(events=@EventName("inputBlur"))
- public abstract String getOnInputBlur();
+ @Attribute(events=@EventName("inputblur"))
+ public abstract String getOninputblur();
@Attribute(events=@EventName("select"))
public abstract String getOnselect();
Modified: branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
import javax.faces.component.UISelectOne;
@@ -3,4 +25,5 @@
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -46,4 +69,47 @@
@Attribute(defaultValue="click")
public abstract String getEditEvent();
+
+ @Attribute(events=@EventName("blur"))
+ public abstract String getOnblur();
+
+ @Attribute(events=@EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events=@EventName("ondblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events=@EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events=@EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events=@EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events=@EventName("keyup"))
+ public abstract String getOnkeypup();
+
+ @Attribute(events=@EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events=@EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events=@EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events=@EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events=@EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Attribute(events=@EventName("select"))
+ public abstract String getOnselect();
+
+ @Attribute(events=@EventName("change"))
+ public abstract String getOnchange();
+
}
Modified: branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -81,30 +81,30 @@
private static final Map<String, ComponentAttribute> INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
.unmodifiableMap(ComponentAttribute.createMap(
- new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE).setEventNames("inputClick").
- setComponentAttributeName("onInputClick"),
- new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE).setEventNames("inputDblclick").
- setComponentAttributeName("onInputDblclick"),
- new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputMousedown").
- setComponentAttributeName("onInputMousedown"),
- new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE).setEventNames("inputMouseup").
- setComponentAttributeName("onInputMouseup"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputMouseover").
- setComponentAttributeName("onInputMouseover"),
- new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputMousemove").
- setComponentAttributeName("onInputMousemove"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputMouseout").
- setComponentAttributeName("onInputMouseout"),
- new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE).setEventNames("inputKeypress").
- setComponentAttributeName("onInputKeypress"),
- new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE).setEventNames("inputKeydown").
- setComponentAttributeName("onInputKeydown"),
- new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE).setEventNames("inputKeyup").
- setComponentAttributeName("onInputKeyup"),
- new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE).setEventNames("inputBlur").
- setComponentAttributeName("onInputBlur"),
- new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE).setEventNames("inputFocus").
- setComponentAttributeName("onInputFocus"),
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE).setEventNames("inputclick").
+ setComponentAttributeName("oninputclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE).setEventNames("inputdblclick").
+ setComponentAttributeName("oninputdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputmousedown").
+ setComponentAttributeName("oninputmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE).setEventNames("inputmouseup").
+ setComponentAttributeName("oninputmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputmouseover").
+ setComponentAttributeName("oninputmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputmousemove").
+ setComponentAttributeName("oninputmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputmouseout").
+ setComponentAttributeName("oninputmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE).setEventNames("inputkeypress").
+ setComponentAttributeName("oninputkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE).setEventNames("inputkeydown").
+ setComponentAttributeName("oninputkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE).setEventNames("inputkeyup").
+ setComponentAttributeName("oninputkeyup"),
+ new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE).setEventNames("inputblur").
+ setComponentAttributeName("oninputblur"),
+ new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE).setEventNames("inputfocus").
+ setComponentAttributeName("oninputfocus"),
new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE).setEventNames("change").
setComponentAttributeName("onchange"),
new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE).setEventNames("select").
Modified: branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 17:10:02 UTC (rev 19524)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit;
import java.io.IOException;
@@ -2,2 +24,3 @@
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
@@ -95,7 +118,16 @@
+ "}";
}
}
+
+ private static final Map<String, ComponentAttribute> INPLACESELECT_HANDLER_ATTRIBUTES = Collections
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE).setEventNames("change").
+ setComponentAttributeName("onchange"),
+ new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE).setEventNames("select").
+ setComponentAttributeName("onselect")
+ ));
+
@Override
protected String getScriptName() {
return "new RichFaces.ui.InplaceSelect";
@@ -116,8 +148,13 @@
}
return clientSelectItems;
}
-
+
@Override
+ protected void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACESELECT_HANDLER_ATTRIBUTES);
+ }
+
+ @Override
public void addToOptions(FacesContext facesContext, UIComponent component,
Map<String, Object> options, Object additional) {
options.put(OPTIONS_ITEM_CLASS, "rf-is-opt");
Modified: branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 17:10:02 UTC (rev 19524)
@@ -32,7 +32,6 @@
this.editEvent = options.editEvent;
this.noneCss = options.noneCss;
this.changedCss = options.changedCss;
- this.showControls = options.showControls;
this.defaultLabel = options.defaultLabel;
this.element = $(document.getElementById(id));
@@ -43,12 +42,6 @@
this.isSaved = false;
this.useDefaultLabel = false;
- if(this.showControls) {
- this.okbtn = $(document.getElementById(options.okbtn));
- this.cancelbtn = $(document.getElementById(options.cancelbtn));
- this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
- this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler, this));
- }
};
rf.BaseComponent.extend(rf.ui.InplaceBase);
@@ -84,6 +77,10 @@
getNamespace: function() {
},
+ isValueSaved: function() {
+ return this.isSaved;
+ },
+
save: function() {
var value = this.getValue()
if(value.length > 0) {
@@ -99,14 +96,6 @@
this.__hide();
},
- __applyChangedStyles: function() {
- if(this.isValueChanged()) {
- this.element.addClass(this.changedCss);
- } else {
- this.element.removeClass(this.changedCss);
- }
- },
-
cancel: function(){
var text = "";
if(!this.useDefaultLabel) {
@@ -117,14 +106,14 @@
this.__hide();
},
- isValueSaved: function() {
- return this.isSaved;
+ __applyChangedStyles: function() {
+ if(this.isValueChanged()) {
+ this.element.addClass(this.changedCss);
+ } else {
+ this.element.removeClass(this.changedCss);
+ }
},
- __saveValue: function(value) {
-
- },
-
__show: function() {
this.scrollElements = rf.Event.bindScrollEventHandlers(this.id, this.__scrollHandler, this);
this.onshow();
@@ -143,18 +132,7 @@
this.isSaved = false;
this.editContainer.removeClass(this.noneCss);
this.__show();
- },
-
- __saveBtnHandler: function(e) {
- this.save();
- return false;
- },
-
- __cancelBtnHandler: function(e) {
- this.cancel();
- return false;
- },
-
+ },
__scrollHandler: function(e) {
this.cancel();
},
Modified: branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-11 16:35:28 UTC (rev 19523)
+++ branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-11 17:10:02 UTC (rev 19524)
@@ -12,12 +12,20 @@
var inputLabel = this.input.val();
this.initialValue = (label == inputLabel) ? label : "";
this.saveOnBlur = options.saveOnBlur;
+ this.showControls = options.showControls;
this.input.bind("focus", $.proxy(this.__editHandler, this));
this.input.bind("change", $.proxy(this.__changeHandler, this));
this.input.bind("blur", $.proxy(this.__blurHandler, this));
this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
+ if(this.showControls) {
+ this.okbtn = $(document.getElementById(options.okbtn));
+ this.cancelbtn = $(document.getElementById(options.cancelbtn));
+ this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
+ this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler, this));
+ }
+
this.focusElement = $(document.getElementById(options.focusElement));
};
@@ -73,6 +81,16 @@
this.input.focus();
this.input.bind("focus", $.proxy(this.__editHandler, this));
},
+
+ __saveBtnHandler: function(e) {
+ this.save();
+ return false;
+ },
+
+ __cancelBtnHandler: function(e) {
+ this.cancel();
+ return false;
+ },
getValue: function() {
return this.input.val();
15 years, 7 months
JBoss Rich Faces SVN: r19522 - in branches/RF-7817: core/api/src/main/java/org/richfaces/application/push and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-11 12:26:25 -0400 (Mon, 11 Oct 2010)
New Revision: 19522
Added:
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSession.java
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSessionTracker.java
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/Request.java
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/RequestLifecycleListener.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/DefaultMessageSerializer.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/MessagesContextImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionTrackerImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/RequestImpl.java
Removed:
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java
branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java
Modified:
branches/RF-7817/push-redesign/pom.xml
branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java
Log:
https://jira.jboss.org/browse/RF-7817 - refactoring
Copied: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push (from rev 19499, branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push)
Copied: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSession.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java)
===================================================================
--- branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSession.java (rev 0)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSession.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+import java.io.IOException;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface PushSession {
+
+ public String getId();
+
+ public void subscribe(TopicKey[] topics);
+
+ public void connect(Request request);
+
+ public void writeMessages() throws IOException;
+
+ public void disconnect();
+
+ public void destroy();
+
+}
Copied: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSessionTracker.java (from rev 19521, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java)
===================================================================
--- branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSessionTracker.java (rev 0)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/PushSessionTracker.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface PushSessionTracker {
+
+ public PushSession createPushSession();
+
+ public PushSession getPushSession(String id);
+
+ public void removePushSession(String id);
+
+ public SubscriptionContext getSubscriptionContext();
+
+}
\ No newline at end of file
Copied: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/Request.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java)
===================================================================
--- branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/Request.java (rev 0)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/Request.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+import java.io.IOException;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface Request {
+
+ public void write(Message message) throws IOException;
+
+ public void suspend() throws IOException;
+
+ public void resume() throws IOException;
+
+ public void addListener(RequestLifecycleListener listener);
+
+ public void removeListener(RequestLifecycleListener listener);
+
+ public boolean isSuspended();
+
+}
Copied: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/RequestLifecycleListener.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java)
===================================================================
--- branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/RequestLifecycleListener.java (rev 0)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/RequestLifecycleListener.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface RequestLifecycleListener {
+
+ public void onSuspend(Request request);
+
+ public void onDisconnect(Request request);
+
+ public void onResume(Request request);
+
+}
Deleted: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java 2010-10-08 09:38:48 UTC (rev 19499)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.push;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface TopicQueueSettings {
-
- public void addMessageTransformer(MessageTransformer transformer);
-
- public void removeMessageTransformer(MessageTransformer transformer);
-
- public void setMessageSerializer(MessageSerializer serializer);
-
- public MessageSerializer getMessageSerializer();
-
- public void addMessageFilter(MessageFilter filter);
-
- public void removeMessageFilter(MessageFilter filter);
-
- public boolean isSessionAware();
-
- public void setSessionAware(boolean sessionAware);
-
- public boolean isFacesContextAware();
-
- public void setFacesContextAware(boolean facesContextAware);
-
- public TopicMode getDeliveryMode();
-
- public void setDeliveryMode(TopicMode mode);
-
- public int getCapacity();
-
- public void setCapacity(int capacity);
-
- //TODO - transport settings?
-
-}
Deleted: branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java 2010-10-08 09:38:48 UTC (rev 19499)
+++ branches/RF-7817/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.push;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface TopicQueuesContext {
-
- public TopicQueueSettings getTopicQueueSettings(TopicKey topicKey);
-
- public TopicQueueSettings getDefaultTopicQueueSettings();
-
-}
-
Modified: branches/RF-7817/push-redesign/pom.xml
===================================================================
--- branches/RF-7817/push-redesign/pom.xml 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/pom.xml 2010-10-11 16:26:25 UTC (rev 19522)
@@ -45,8 +45,8 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.richfaces.ui.core</groupId>
- <artifactId>richfaces-ui-core-api</artifactId>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.io.IOException;
-import java.util.concurrent.Executors;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.atmosphere.cpr.AtmosphereHandler;
-import org.atmosphere.cpr.AtmosphereResource;
-import org.atmosphere.cpr.AtmosphereResourceEvent;
-import org.richfaces.application.push.TopicKey;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class AtmospherePushHandler implements AtmosphereHandler<HttpServletRequest, HttpServletResponse> {
-
- private static final String PUSH_SESSION_ID_PARAM = "pushSessionId";
-
- private static final String PUSH_SESSION_ATTRIBUTE = "pushSession";
-
-// private PushSubscriberContext subscriberContext;
-//
-// private PushPublisherContext publisherContext;
-//
-// private Map<TopicKey, Broadcaster> broadcasters = new MapMaker().makeComputingMap(new Function<TopicKey, Broadcaster>() {
-// public Broadcaster apply(TopicKey from) {
-// return new DefaultBroadcaster(from.getTopicName());
-// };
-// });
-//
-
- private PushSessionTracker pushTracker;
-
- protected PushSessionTracker getPushTracker() {
- return pushTracker;
- }
-
- public AtmospherePushHandler(MessagesContextImpl messagesContext) {
- super();
-
- pushTracker = new PushSessionTrackerImpl(Executors.newFixedThreadPool(1), messagesContext);
- }
-
- /* (non-Javadoc)
- * @see org.atmosphere.cpr.AtmosphereHandler#onRequest(org.atmosphere.cpr.AtmosphereResource)
- */
- public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
- // TODO Auto-generated method stub
-
- HttpServletRequest req = resource.getRequest();
- HttpServletResponse resp = resource.getResponse();
-
- String pushSessionId = req.getParameter(PUSH_SESSION_ID_PARAM);
-
- PushSessionImpl pushSession = null;
-
- if (pushSessionId != null) {
- pushSession = getPushTracker().getPushSession(pushSessionId);
- }
-
- if (pushSession == null) {
- //TODO - debug log
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
- return;
- }
-
- resp.setContentType("text/plain");
-
- req.setAttribute(PUSH_SESSION_ATTRIBUTE, pushSession);
- pushSession.connect(new RequestImpl(resource));
- pushSession.writeMessages();
- }
-
- public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
- throws IOException {
- //do nothing
- }
-
- public PushSessionImpl doConnect(String[] topicNames) {
- PushSessionImpl pushSession = getPushTracker().createPushSession();
-
- TopicKey[] topicKeys = new TopicKey[topicNames.length];
- for (int i = 0; i < topicNames.length; i++) {
- String topicName = topicNames[i];
-
- topicKeys[i] = new TopicKey(topicName);
- }
-
- //TODO - check permissions for channels
- pushSession.subscribe(topicKeys);
- return pushSession;
- }
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,57 +0,0 @@
-///*
-// * JBoss, Home of Professional Open Source
-// * Copyright 2010, Red Hat, Inc. and individual contributors
-// * by the @authors tag. See the copyright.txt in the distribution for a
-// * full listing of individual contributors.
-// *
-// * This is free software; you can redistribute it and/or modify it
-// * under the terms of the GNU Lesser General Public License as
-// * published by the Free Software Foundation; either version 2.1 of
-// * the License, or (at your option) any later version.
-// *
-// * This software is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// * Lesser General Public License for more details.
-// *
-// * You should have received a copy of the GNU Lesser General Public
-// * License along with this software; if not, write to the Free
-// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-// */
-//package org.richfaces.application.impl;
-//
-//import java.util.HashMap;
-//import java.util.Map;
-//
-//import org.ajax4jsf.javascript.ScriptUtils;
-//import org.richfaces.Message;
-//import org.richfaces.application.MessageSerializer;
-//
-///**
-// * @author Nick Belaevski
-// *
-// */
-//public class DefaultMessageSerializer implements MessageSerializer {
-//
-// public static final String TOPIC_ATTRIBUTE = "topic";
-//
-// public static final String ATTRIBUTES_ATTRIBUTE = "attributes";
-//
-// public static final String DATA_ATTRIBUTE = "data";
-//
-// public String serialize(Message message) {
-// Map<String,Object> dataMap = new HashMap<String, Object>();
-//
-// dataMap.put(TOPIC_ATTRIBUTE, message.getTopicKey().getTopicName());
-//
-// if (message.hasAttributes()) {
-// dataMap.put(ATTRIBUTES_ATTRIBUTE, message.getAttributes());
-// }
-//
-// dataMap.put(DATA_ATTRIBUTE, message.getData());
-//
-// return ScriptUtils.toScript(dataMap);
-// }
-//
-//}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.servlet.ServletContext;
-
-import org.richfaces.application.push.Message;
-import org.richfaces.application.push.MessageListener;
-import org.richfaces.application.push.PublisherContext;
-import org.richfaces.application.push.SubscriptionContext;
-import org.richfaces.application.push.TopicKey;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class MessagesContextImpl implements SubscriptionContext, PublisherContext {
-
- private ConcurrentMap<TopicKey, List<MessageListener>> listenersMap = new ConcurrentHashMap<TopicKey, List<MessageListener>>();
-
- private MessagesContextImpl() {}
-
- public void addMessageListener(TopicKey topicKey, MessageListener listener) {
- List<MessageListener> listeners = listenersMap.get(topicKey);
- if (listeners == null) {
- List<MessageListener> newListenersList = new CopyOnWriteArrayList<MessageListener>();
-
- listeners = listenersMap.putIfAbsent(topicKey, newListenersList);
- if (listeners == null) {
- listeners = newListenersList;
- }
- }
-
- listeners.add(listener);
- }
-
- public void removeMessageListener(TopicKey topicKey, MessageListener listener) {
- List<MessageListener> listeners = listenersMap.get(topicKey);
- if (listeners != null) {
- listeners.remove(listener);
- }
- }
-
- public void publish(TopicKey topicKey, Object data) {
- Message message = new Message(topicKey);
- message.setData(data);
-
- publish(message);
- }
-
- public void publish(Message message) {
- List<MessageListener> listeners = listenersMap.get(message.getTopicKey());
- if (listeners != null) {
- for (MessageListener listener : listeners) {
- listener.onMessage(message);
- }
- }
- }
-
- public static MessagesContextImpl create(ServletContext servletContext) {
- MessagesContextImpl result = new MessagesContextImpl();
-
- servletContext.setAttribute(PublisherContext.ATTRIBUTE_NAME, result);
-
- return result;
- }
-
- public static void destroy(ServletContext servletContext) {
- servletContext.removeAttribute(PublisherContext.ATTRIBUTE_NAME);
- }
-
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.io.IOException;
-
-import org.richfaces.application.push.TopicKey;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface PushSession {
-
- public void subscribe(TopicKey[] topics);
-
- public void connect(Request request);
-
- public void writeMessages() throws IOException;
-
- public void disconnect();
-
- public void destroy();
-
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,190 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.io.IOException;
-import java.util.Queue;
-import java.util.concurrent.Delayed;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.richfaces.application.push.Message;
-import org.richfaces.application.push.MessageListener;
-import org.richfaces.application.push.SubscriptionContext;
-import org.richfaces.application.push.TopicKey;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class PushSessionImpl implements Delayed, PushSession {
-
- private static final long EXPIRATION_DELAY = 30 * 1000;
-
- private String id;
-
- private AtomicReference<Request> requestRef =
- new AtomicReference<Request>();
-
- private PushSessionTrackerImpl pushTracker;
-
- private volatile long expirationTime;
-
- private TopicKey[] topics;
-
- private Queue<Message> messagesQueue = new LinkedBlockingQueue<Message>();
-
- private MessageListener queueMessageListener = new MessageListener() {
-
- public void onMessage(Message message) {
- messagesQueue.add(message);
- Request request = requestRef.get();
-
- if (request != null && request.isSuspended()) {
- try {
- writeMessages();
- request.resume();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- };
-
- private RequestLifecycleListener requestLifecycleListener = new RequestLifecycleListener() {
-
- public void onSuspend(Request request) {
- try {
- writeMessages();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void onResume(Request request) {
- // TODO Auto-generated method stub
- }
-
- public void onDisconnect(Request request) {
- // TODO Auto-generated method stub
- PushSessionImpl.this.disconnect();
- }
- };
-
- public PushSessionImpl(PushSessionTrackerImpl pushTracker) {
- super();
- this.pushTracker = pushTracker;
- resetExpirationTime();
- }
-
- private void resetExpirationTime() {
- expirationTime = System.currentTimeMillis() + EXPIRATION_DELAY;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int compareTo(Delayed o) {
- return Long.valueOf(getDelay(TimeUnit.MILLISECONDS)).compareTo(o.getDelay(TimeUnit.MILLISECONDS));
- }
-
- public long getDelay(TimeUnit unit) {
- return unit.convert(expirationTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
- }
-
- public synchronized void subscribe(TopicKey[] topics) {
- SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
-
- if (this.topics != null) {
- for (TopicKey topicKey : topics) {
- subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
- }
- }
-
- this.topics = topics;
-
- for (TopicKey topicKey : topics) {
- subscriptionContext.addMessageListener(topicKey, queueMessageListener);
- }
-
- }
-
- public void connect(Request request) {
- if (this.requestRef.getAndSet(request) != null) {
- disconnect();
- }
-
- pushTracker.onRequestConnected(this);
- request.addListener(requestLifecycleListener);
- }
-
- public synchronized void writeMessages() throws IOException {
- Request request = requestRef.get();
-
- if (request == null) {
- return;
- }
-
- Message message = null;
-
- while (true) {
- message = messagesQueue.poll();
-
- if (message == null) {
- break;
- }
-
- request.write(message);
- }
-
- if (message == null) {
- request.suspend();
- } else {
- request.resume();
- }
- }
-
- public void disconnect() {
- Request request = this.requestRef.getAndSet(null);
- if (request == null) {
- return;
- }
-
- request.removeListener(requestLifecycleListener);
- pushTracker.onRequestDisconnected(this);
- }
-
- public synchronized void destroy() {
- SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
- for (TopicKey topicKey : topics) {
- subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
- }
- }
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import org.richfaces.application.push.SubscriptionContext;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface PushSessionTracker {
-
- public PushSessionImpl createPushSession();
-
- public PushSessionImpl getPushSession(String id);
-
- public void removePushSession(String id);
-
- public SubscriptionContext getSubscriptionContext();
-
-}
\ No newline at end of file
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.DelayQueue;
-import java.util.concurrent.ExecutorService;
-
-import org.richfaces.application.push.SubscriptionContext;
-
-import com.google.common.collect.MapMaker;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class PushSessionTrackerImpl implements PushSessionTracker {
-
- private final class SessionsExpirationRunnable implements Runnable {
- public void run() {
- while (true) {
- try {
- PushSessionImpl pushSession = expirationQueue.take();
- pushSessionMap.remove(pushSession.getId());
- pushSession.destroy();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
- }
-
- private SubscriptionContext subscriptionContext;
-
- private ConcurrentMap<String, PushSessionImpl> pushSessionMap = new MapMaker().makeMap();
-
- private DelayQueue<PushSessionImpl> expirationQueue = new DelayQueue<PushSessionImpl>();
-
- public PushSessionTrackerImpl(ExecutorService executorService, SubscriptionContext subscriptionContext) {
- executorService.submit(new SessionsExpirationRunnable());
-
- this.subscriptionContext = subscriptionContext;
- }
-
- public PushSessionImpl createPushSession() {
- PushSessionImpl pushSession = new PushSessionImpl(this);
- while (true) {
- String uuid = UUID.randomUUID().toString();
- pushSession.setId(uuid);
- if (pushSessionMap.putIfAbsent(uuid, pushSession) == null) {
- expirationQueue.put(pushSession);
-
- return pushSession;
- }
- }
- }
-
- public PushSessionImpl getPushSession(String id) {
- return pushSessionMap.get(id);
- }
-
- public void removePushSession(String id) {
- PushSessionImpl session = pushSessionMap.remove(id);
- if (session != null) {
- expirationQueue.remove(session);
- }
- }
-
- void onRequestConnected(PushSessionImpl pushSession) {
- expirationQueue.remove(pushSession);
- }
-
- void onRequestDisconnected(PushSessionImpl pushSession) {
- expirationQueue.add(pushSession);
- }
-
- public SubscriptionContext getSubscriptionContext() {
- return subscriptionContext;
- }
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.io.IOException;
-
-import org.richfaces.application.push.Message;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface Request {
-
- public void write(Message message) throws IOException;
-
- public void suspend() throws IOException;
-
- public void resume() throws IOException;
-
- public void addListener(RequestLifecycleListener listener);
-
- public void removeListener(RequestLifecycleListener listener);
-
- public boolean isSuspended();
-
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,171 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.javascript.ScriptUtils;
-import org.atmosphere.cpr.AtmosphereEventLifecycle;
-import org.atmosphere.cpr.AtmosphereResource;
-import org.atmosphere.cpr.AtmosphereResourceEvent;
-import org.atmosphere.cpr.AtmosphereResourceEventListener;
-import org.richfaces.application.push.Message;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class RequestImpl implements Request {
-
- private static final String DATA_WRAPPER_START = "[";
-
- private static final String DATA_WRAPPER_END = "]";
-
- private static final String DATA_BLANK = "";
-
- private AtmosphereResource<HttpServletRequest, HttpServletResponse> atmosphereResource;
-
- private List<RequestLifecycleListener> listeners = new ArrayList<RequestLifecycleListener>(2);
-
- private AtmosphereResourceEventListener atmosphereListener = new AtmosphereResourceEventListener() {
-
- public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
- for (RequestLifecycleListener listener : listeners) {
- listener.onSuspend(RequestImpl.this);
- }
- }
-
- public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
- for (RequestLifecycleListener listener : listeners) {
- listener.onResume(RequestImpl.this);
- }
-
- try {
- encodeRequestEndElement();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
- for (RequestLifecycleListener listener : listeners) {
- listener.onDisconnect(RequestImpl.this);
- }
- }
-
- public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
- // TODO Auto-generated method stub
-
- }
- };
-
- private boolean hasWrittenMessages = false;
-
-
- public RequestImpl(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) {
- super();
-
- this.atmosphereResource = resource;
- ((AtmosphereEventLifecycle) atmosphereResource).addEventListener(atmosphereListener);
- }
-
- public void addListener(RequestLifecycleListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(RequestLifecycleListener listener) {
- listeners.remove(listener);
- }
-
- public void write(Message message) throws IOException {
- HttpServletResponse response = atmosphereResource.getResponse();
-
- PrintWriter writer = response.getWriter();
-
- if (!hasWrittenMessages) {
- encodeRequestStartElement();
- }
-
- Map<String,Object> map = new HashMap<String, Object>();
-
- map.put("topic", message.getTopicKey().getTopicName());
- map.put("data", message.getData());
- map.put("attributes", message.getAttributes());
-
- //TODO use message serializer
- writer.write(ScriptUtils.toScript(map));
-
- if (hasWrittenMessages) {
- writer.write(", ");
- } else {
- hasWrittenMessages = true;
- }
-
- writer.flush();
-
- }
-
- public void suspend() throws IOException {
- if (!isSuspended()) {
- //TODO - customize interval
- atmosphereResource.suspend();
- }
- }
-
- public void resume() throws IOException {
- if (isSuspended()) {
- atmosphereResource.resume();
- }
- }
-
- public boolean isSuspended() {
- return atmosphereResource.getAtmosphereResourceEvent().isSuspended();
- }
-
- public void encodeRequestStartElement() throws IOException {
- write(DATA_WRAPPER_START);
- }
-
- public void encodeRequestEndElement() throws IOException {
- if (hasWrittenMessages) {
- write(DATA_WRAPPER_END);
- } else {
- write(DATA_BLANK);
- }
- }
-
- private void write(String s) throws IOException {
- HttpServletResponse response = atmosphereResource.getResponse();
-
- PrintWriter writer = response.getWriter();
- writer.write(s);
- }
-}
Deleted: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface RequestLifecycleListener {
-
- public void onSuspend(Request request);
-
- public void onDisconnect(Request request);
-
- public void onResume(Request request);
-
-}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java (from rev 19521, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+import java.util.concurrent.Executors;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.atmosphere.cpr.AtmosphereHandler;
+import org.atmosphere.cpr.AtmosphereResource;
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.richfaces.application.push.PushSession;
+import org.richfaces.application.push.PushSessionTracker;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AtmospherePushHandler implements AtmosphereHandler<HttpServletRequest, HttpServletResponse> {
+
+ private static final String PUSH_SESSION_ID_PARAM = "pushSessionId";
+
+ private static final String PUSH_SESSION_ATTRIBUTE = "pushSession";
+
+// private PushSubscriberContext subscriberContext;
+//
+// private PushPublisherContext publisherContext;
+//
+// private Map<TopicKey, Broadcaster> broadcasters = new MapMaker().makeComputingMap(new Function<TopicKey, Broadcaster>() {
+// public Broadcaster apply(TopicKey from) {
+// return new DefaultBroadcaster(from.getTopicName());
+// };
+// });
+//
+
+ private PushSessionTracker pushTracker;
+
+ protected PushSessionTracker getPushTracker() {
+ return pushTracker;
+ }
+
+ public AtmospherePushHandler(MessagesContextImpl messagesContext) {
+ super();
+
+ pushTracker = new PushSessionTrackerImpl(Executors.newFixedThreadPool(1), messagesContext);
+ }
+
+ /* (non-Javadoc)
+ * @see org.atmosphere.cpr.AtmosphereHandler#onRequest(org.atmosphere.cpr.AtmosphereResource)
+ */
+ public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
+ // TODO Auto-generated method stub
+
+ HttpServletRequest req = resource.getRequest();
+ HttpServletResponse resp = resource.getResponse();
+
+ String pushSessionId = req.getParameter(PUSH_SESSION_ID_PARAM);
+
+ PushSession pushSession = null;
+
+ if (pushSessionId != null) {
+ pushSession = getPushTracker().getPushSession(pushSessionId);
+ }
+
+ if (pushSession == null) {
+ //TODO - debug log
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+
+ resp.setContentType("text/plain");
+
+ req.setAttribute(PUSH_SESSION_ATTRIBUTE, pushSession);
+ pushSession.connect(new RequestImpl(resource));
+ pushSession.writeMessages();
+ }
+
+ public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
+ throws IOException {
+ //do nothing
+ }
+
+ public PushSession doConnect(String[] topicNames) {
+ PushSession pushSession = getPushTracker().createPushSession();
+
+ TopicKey[] topicKeys = new TopicKey[topicNames.length];
+ for (int i = 0; i < topicNames.length; i++) {
+ String topicName = topicNames[i];
+
+ topicKeys[i] = new TopicKey(topicName);
+ }
+
+ //TODO - check permissions for channels
+ pushSession.subscribe(topicKeys);
+ return pushSession;
+ }
+}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/DefaultMessageSerializer.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/DefaultMessageSerializer.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/DefaultMessageSerializer.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,58 @@
+package org.richfaces.application.push.impl;
+///*
+// * JBoss, Home of Professional Open Source
+// * Copyright 2010, Red Hat, Inc. and individual contributors
+// * by the @authors tag. See the copyright.txt in the distribution for a
+// * full listing of individual contributors.
+// *
+// * This is free software; you can redistribute it and/or modify it
+// * under the terms of the GNU Lesser General Public License as
+// * published by the Free Software Foundation; either version 2.1 of
+// * the License, or (at your option) any later version.
+// *
+// * This software is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// * Lesser General Public License for more details.
+// *
+// * You should have received a copy of the GNU Lesser General Public
+// * License along with this software; if not, write to the Free
+// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+// */
+//package org.richfaces.application.impl;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//import org.ajax4jsf.javascript.ScriptUtils;
+//import org.richfaces.Message;
+//import org.richfaces.application.MessageSerializer;
+//
+///**
+// * @author Nick Belaevski
+// *
+// */
+//public class DefaultMessageSerializer implements MessageSerializer {
+//
+// public static final String TOPIC_ATTRIBUTE = "topic";
+//
+// public static final String ATTRIBUTES_ATTRIBUTE = "attributes";
+//
+// public static final String DATA_ATTRIBUTE = "data";
+//
+// public String serialize(Message message) {
+// Map<String,Object> dataMap = new HashMap<String, Object>();
+//
+// dataMap.put(TOPIC_ATTRIBUTE, message.getTopicKey().getTopicName());
+//
+// if (message.hasAttributes()) {
+// dataMap.put(ATTRIBUTES_ATTRIBUTE, message.getAttributes());
+// }
+//
+// dataMap.put(DATA_ATTRIBUTE, message.getData());
+//
+// return ScriptUtils.toScript(dataMap);
+// }
+//
+//}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/MessagesContextImpl.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/MessagesContextImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/MessagesContextImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.servlet.ServletContext;
+
+import org.richfaces.application.push.Message;
+import org.richfaces.application.push.MessageListener;
+import org.richfaces.application.push.PublisherContext;
+import org.richfaces.application.push.SubscriptionContext;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MessagesContextImpl implements SubscriptionContext, PublisherContext {
+
+ private ConcurrentMap<TopicKey, List<MessageListener>> listenersMap = new ConcurrentHashMap<TopicKey, List<MessageListener>>();
+
+ private MessagesContextImpl() {}
+
+ public void addMessageListener(TopicKey topicKey, MessageListener listener) {
+ List<MessageListener> listeners = listenersMap.get(topicKey);
+ if (listeners == null) {
+ List<MessageListener> newListenersList = new CopyOnWriteArrayList<MessageListener>();
+
+ listeners = listenersMap.putIfAbsent(topicKey, newListenersList);
+ if (listeners == null) {
+ listeners = newListenersList;
+ }
+ }
+
+ listeners.add(listener);
+ }
+
+ public void removeMessageListener(TopicKey topicKey, MessageListener listener) {
+ List<MessageListener> listeners = listenersMap.get(topicKey);
+ if (listeners != null) {
+ listeners.remove(listener);
+ }
+ }
+
+ public void publish(TopicKey topicKey, Object data) {
+ Message message = new Message(topicKey);
+ message.setData(data);
+
+ publish(message);
+ }
+
+ public void publish(Message message) {
+ List<MessageListener> listeners = listenersMap.get(message.getTopicKey());
+ if (listeners != null) {
+ for (MessageListener listener : listeners) {
+ listener.onMessage(message);
+ }
+ }
+ }
+
+ public static MessagesContextImpl create(ServletContext servletContext) {
+ MessagesContextImpl result = new MessagesContextImpl();
+
+ servletContext.setAttribute(PublisherContext.ATTRIBUTE_NAME, result);
+
+ return result;
+ }
+
+ public static void destroy(ServletContext servletContext) {
+ servletContext.removeAttribute(PublisherContext.ATTRIBUTE_NAME);
+ }
+
+}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionImpl.java (from rev 19521, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+import java.util.Queue;
+import java.util.concurrent.Delayed;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.richfaces.application.push.Message;
+import org.richfaces.application.push.MessageListener;
+import org.richfaces.application.push.PushSession;
+import org.richfaces.application.push.Request;
+import org.richfaces.application.push.RequestLifecycleListener;
+import org.richfaces.application.push.SubscriptionContext;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushSessionImpl implements Delayed, PushSession {
+
+ private static final long EXPIRATION_DELAY = 30 * 1000;
+
+ private String id;
+
+ private AtomicReference<Request> requestRef =
+ new AtomicReference<Request>();
+
+ private PushSessionTrackerImpl pushTracker;
+
+ private volatile long expirationTime;
+
+ private TopicKey[] topics;
+
+ private Queue<Message> messagesQueue = new LinkedBlockingQueue<Message>();
+
+ private MessageListener queueMessageListener = new MessageListener() {
+
+ public void onMessage(Message message) {
+ messagesQueue.add(message);
+ Request request = requestRef.get();
+
+ if (request != null && request.isSuspended()) {
+ try {
+ writeMessages();
+ request.resume();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+
+ private RequestLifecycleListener requestLifecycleListener = new RequestLifecycleListener() {
+
+ public void onSuspend(Request request) {
+ try {
+ writeMessages();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void onResume(Request request) {
+ // TODO Auto-generated method stub
+ }
+
+ public void onDisconnect(Request request) {
+ // TODO Auto-generated method stub
+ PushSessionImpl.this.disconnect();
+ }
+ };
+
+ public PushSessionImpl(PushSessionTrackerImpl pushTracker) {
+ super();
+ this.pushTracker = pushTracker;
+ resetExpirationTime();
+ }
+
+ private void resetExpirationTime() {
+ expirationTime = System.currentTimeMillis() + EXPIRATION_DELAY;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int compareTo(Delayed o) {
+ return Long.valueOf(getDelay(TimeUnit.MILLISECONDS)).compareTo(o.getDelay(TimeUnit.MILLISECONDS));
+ }
+
+ public long getDelay(TimeUnit unit) {
+ return unit.convert(expirationTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+ }
+
+ public synchronized void subscribe(TopicKey[] topics) {
+ SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
+
+ if (this.topics != null) {
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
+ }
+ }
+
+ this.topics = topics;
+
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.addMessageListener(topicKey, queueMessageListener);
+ }
+
+ }
+
+ public void connect(Request request) {
+ if (this.requestRef.getAndSet(request) != null) {
+ disconnect();
+ }
+
+ pushTracker.onRequestConnected(this);
+ request.addListener(requestLifecycleListener);
+ }
+
+ public synchronized void writeMessages() throws IOException {
+ Request request = requestRef.get();
+
+ if (request == null) {
+ return;
+ }
+
+ Message message = null;
+
+ while (true) {
+ message = messagesQueue.poll();
+
+ if (message == null) {
+ break;
+ }
+
+ request.write(message);
+ }
+
+ if (message == null) {
+ request.suspend();
+ } else {
+ request.resume();
+ }
+ }
+
+ public void disconnect() {
+ Request request = this.requestRef.getAndSet(null);
+ if (request == null) {
+ return;
+ }
+
+ request.removeListener(requestLifecycleListener);
+ pushTracker.onRequestDisconnected(this);
+ }
+
+ public synchronized void destroy() {
+ SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
+ }
+ }
+}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionTrackerImpl.java (from rev 19521, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionTrackerImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushSessionTrackerImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.DelayQueue;
+import java.util.concurrent.ExecutorService;
+
+import org.richfaces.application.push.PushSessionTracker;
+import org.richfaces.application.push.SubscriptionContext;
+
+import com.google.common.collect.MapMaker;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushSessionTrackerImpl implements PushSessionTracker {
+
+ private final class SessionsExpirationRunnable implements Runnable {
+ public void run() {
+ while (true) {
+ try {
+ PushSessionImpl pushSession = expirationQueue.take();
+ pushSessionMap.remove(pushSession.getId());
+ pushSession.destroy();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+ }
+
+ private SubscriptionContext subscriptionContext;
+
+ private ConcurrentMap<String, PushSessionImpl> pushSessionMap = new MapMaker().makeMap();
+
+ private DelayQueue<PushSessionImpl> expirationQueue = new DelayQueue<PushSessionImpl>();
+
+ public PushSessionTrackerImpl(ExecutorService executorService, SubscriptionContext subscriptionContext) {
+ executorService.submit(new SessionsExpirationRunnable());
+
+ this.subscriptionContext = subscriptionContext;
+ }
+
+ public PushSessionImpl createPushSession() {
+ PushSessionImpl pushSession = new PushSessionImpl(this);
+ while (true) {
+ String uuid = UUID.randomUUID().toString();
+ pushSession.setId(uuid);
+ if (pushSessionMap.putIfAbsent(uuid, pushSession) == null) {
+ expirationQueue.put(pushSession);
+
+ return pushSession;
+ }
+ }
+ }
+
+ public PushSessionImpl getPushSession(String id) {
+ return pushSessionMap.get(id);
+ }
+
+ public void removePushSession(String id) {
+ PushSessionImpl session = pushSessionMap.remove(id);
+ if (session != null) {
+ expirationQueue.remove(session);
+ }
+ }
+
+ void onRequestConnected(PushSessionImpl pushSession) {
+ expirationQueue.remove(pushSession);
+ }
+
+ void onRequestDisconnected(PushSessionImpl pushSession) {
+ expirationQueue.add(pushSession);
+ }
+
+ public SubscriptionContext getSubscriptionContext() {
+ return subscriptionContext;
+ }
+}
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/RequestImpl.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/RequestImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/RequestImpl.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.atmosphere.cpr.AtmosphereEventLifecycle;
+import org.atmosphere.cpr.AtmosphereResource;
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.atmosphere.cpr.AtmosphereResourceEventListener;
+import org.richfaces.application.push.Message;
+import org.richfaces.application.push.Request;
+import org.richfaces.application.push.RequestLifecycleListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RequestImpl implements Request {
+
+ private static final String DATA_WRAPPER_START = "[";
+
+ private static final String DATA_WRAPPER_END = "]";
+
+ private static final String DATA_BLANK = "";
+
+ private AtmosphereResource<HttpServletRequest, HttpServletResponse> atmosphereResource;
+
+ private List<RequestLifecycleListener> listeners = new ArrayList<RequestLifecycleListener>(2);
+
+ private AtmosphereResourceEventListener atmosphereListener = new AtmosphereResourceEventListener() {
+
+ public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onSuspend(RequestImpl.this);
+ }
+ }
+
+ public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onResume(RequestImpl.this);
+ }
+
+ try {
+ encodeRequestEndElement();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onDisconnect(RequestImpl.this);
+ }
+ }
+
+ public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ private boolean hasWrittenMessages = false;
+
+
+ public RequestImpl(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) {
+ super();
+
+ this.atmosphereResource = resource;
+ ((AtmosphereEventLifecycle) atmosphereResource).addEventListener(atmosphereListener);
+ }
+
+ public void addListener(RequestLifecycleListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(RequestLifecycleListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void write(Message message) throws IOException {
+ HttpServletResponse response = atmosphereResource.getResponse();
+
+ PrintWriter writer = response.getWriter();
+
+ if (!hasWrittenMessages) {
+ encodeRequestStartElement();
+ }
+
+ Map<String,Object> map = new HashMap<String, Object>();
+
+ map.put("topic", message.getTopicKey().getTopicName());
+ map.put("data", message.getData());
+ map.put("attributes", message.getAttributes());
+
+ //TODO use message serializer
+ writer.write(ScriptUtils.toScript(map));
+
+ if (hasWrittenMessages) {
+ writer.write(", ");
+ } else {
+ hasWrittenMessages = true;
+ }
+
+ writer.flush();
+
+ }
+
+ public void suspend() throws IOException {
+ if (!isSuspended()) {
+ //TODO - customize interval
+ atmosphereResource.suspend();
+ }
+ }
+
+ public void resume() throws IOException {
+ if (isSuspended()) {
+ atmosphereResource.resume();
+ }
+ }
+
+ public boolean isSuspended() {
+ return atmosphereResource.getAtmosphereResourceEvent().isSuspended();
+ }
+
+ public void encodeRequestStartElement() throws IOException {
+ write(DATA_WRAPPER_START);
+ }
+
+ public void encodeRequestEndElement() throws IOException {
+ if (hasWrittenMessages) {
+ write(DATA_WRAPPER_END);
+ } else {
+ write(DATA_BLANK);
+ }
+ }
+
+ private void write(String s) throws IOException {
+ HttpServletResponse response = atmosphereResource.getResponse();
+
+ PrintWriter writer = response.getWriter();
+ writer.write(s);
+ }
+}
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java 2010-10-11 16:13:31 UTC (rev 19521)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java 2010-10-11 16:26:25 UTC (rev 19522)
@@ -31,9 +31,9 @@
import javax.servlet.http.HttpServletResponse;
import org.atmosphere.cpr.AtmosphereServlet;
-import org.richfaces.application.impl.AtmospherePushHandler;
-import org.richfaces.application.impl.MessagesContextImpl;
-import org.richfaces.application.impl.PushSessionImpl;
+import org.richfaces.application.push.PushSession;
+import org.richfaces.application.push.impl.AtmospherePushHandler;
+import org.richfaces.application.push.impl.MessagesContextImpl;
/**
* @author Nick Belaevski
@@ -79,10 +79,10 @@
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String[] topicNames = req.getParameterValues(PUSH_TOPIC_PARAM);
- PushSessionImpl pushData = pushHandler.doConnect(topicNames);
+ PushSession pushSession = pushHandler.doConnect(topicNames);
resp.setStatus(HttpServletResponse.SC_OK);
- resp.getWriter().write(pushData.getId());
+ resp.getWriter().write(pushSession.getId());
}
@Override
15 years, 7 months
JBoss Rich Faces SVN: r19521 - in branches/RF-7817/push-redesign/src/main: resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-11 12:13:31 -0400 (Mon, 11 Oct 2010)
New Revision: 19521
Added:
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java
Modified:
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js
Log:
https://jira.jboss.org/browse/RF-7817
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 16:06:07 UTC (rev 19520)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 16:13:31 UTC (rev 19521)
@@ -62,7 +62,7 @@
public AtmospherePushHandler(MessagesContextImpl messagesContext) {
super();
- pushTracker = new PushSessionTracker(Executors.newFixedThreadPool(1), messagesContext);
+ pushTracker = new PushSessionTrackerImpl(Executors.newFixedThreadPool(1), messagesContext);
}
/* (non-Javadoc)
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java 2010-10-11 16:06:07 UTC (rev 19520)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
@@ -46,7 +46,7 @@
private AtomicReference<Request> requestRef =
new AtomicReference<Request>();
- private PushSessionTracker pushTracker;
+ private PushSessionTrackerImpl pushTracker;
private volatile long expirationTime;
@@ -93,7 +93,7 @@
}
};
- public PushSessionImpl(PushSessionTracker pushTracker) {
+ public PushSessionImpl(PushSessionTrackerImpl pushTracker) {
super();
this.pushTracker = pushTracker;
resetExpirationTime();
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java 2010-10-11 16:06:07 UTC (rev 19520)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java 2010-10-11 16:13:31 UTC (rev 19521)
@@ -21,82 +21,20 @@
*/
package org.richfaces.application.impl;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.DelayQueue;
-import java.util.concurrent.ExecutorService;
-
import org.richfaces.application.push.SubscriptionContext;
-import com.google.common.collect.MapMaker;
-
/**
* @author Nick Belaevski
*
*/
-public class PushSessionTracker {
+public interface PushSessionTracker {
- private final class SessionsExpirationRunnable implements Runnable {
- public void run() {
- while (true) {
- try {
- PushSessionImpl pushSession = expirationQueue.take();
- pushSessionMap.remove(pushSession.getId());
- pushSession.destroy();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ public PushSessionImpl createPushSession();
- }
- }
-
- private SubscriptionContext subscriptionContext;
-
- private ConcurrentMap<String, PushSessionImpl> pushSessionMap = new MapMaker().makeMap();
-
- private DelayQueue<PushSessionImpl> expirationQueue = new DelayQueue<PushSessionImpl>();
-
- public PushSessionTracker(ExecutorService executorService, SubscriptionContext subscriptionContext) {
- executorService.submit(new SessionsExpirationRunnable());
-
- this.subscriptionContext = subscriptionContext;
- }
-
- public PushSessionImpl createPushSession() {
- PushSessionImpl pushSession = new PushSessionImpl(this);
- while (true) {
- String uuid = UUID.randomUUID().toString();
- pushSession.setId(uuid);
- if (pushSessionMap.putIfAbsent(uuid, pushSession) == null) {
- expirationQueue.put(pushSession);
-
- return pushSession;
- }
- }
- }
-
- public PushSessionImpl getPushSession(String id) {
- return pushSessionMap.get(id);
- }
+ public PushSessionImpl getPushSession(String id);
- public void removePushSession(String id) {
- PushSessionImpl session = pushSessionMap.remove(id);
- if (session != null) {
- expirationQueue.remove(session);
- }
- }
-
- void onRequestConnected(PushSessionImpl pushSession) {
- expirationQueue.remove(pushSession);
- }
-
- void onRequestDisconnected(PushSessionImpl pushSession) {
- expirationQueue.add(pushSession);
- }
-
- public SubscriptionContext getSubscriptionContext() {
- return subscriptionContext;
- }
-}
+ public void removePushSession(String id);
+
+ public SubscriptionContext getSubscriptionContext();
+
+}
\ No newline at end of file
Copied: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java (from rev 19520, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java)
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTrackerImpl.java 2010-10-11 16:13:31 UTC (rev 19521)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.DelayQueue;
+import java.util.concurrent.ExecutorService;
+
+import org.richfaces.application.push.SubscriptionContext;
+
+import com.google.common.collect.MapMaker;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushSessionTrackerImpl implements PushSessionTracker {
+
+ private final class SessionsExpirationRunnable implements Runnable {
+ public void run() {
+ while (true) {
+ try {
+ PushSessionImpl pushSession = expirationQueue.take();
+ pushSessionMap.remove(pushSession.getId());
+ pushSession.destroy();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+ }
+
+ private SubscriptionContext subscriptionContext;
+
+ private ConcurrentMap<String, PushSessionImpl> pushSessionMap = new MapMaker().makeMap();
+
+ private DelayQueue<PushSessionImpl> expirationQueue = new DelayQueue<PushSessionImpl>();
+
+ public PushSessionTrackerImpl(ExecutorService executorService, SubscriptionContext subscriptionContext) {
+ executorService.submit(new SessionsExpirationRunnable());
+
+ this.subscriptionContext = subscriptionContext;
+ }
+
+ public PushSessionImpl createPushSession() {
+ PushSessionImpl pushSession = new PushSessionImpl(this);
+ while (true) {
+ String uuid = UUID.randomUUID().toString();
+ pushSession.setId(uuid);
+ if (pushSessionMap.putIfAbsent(uuid, pushSession) == null) {
+ expirationQueue.put(pushSession);
+
+ return pushSession;
+ }
+ }
+ }
+
+ public PushSessionImpl getPushSession(String id) {
+ return pushSessionMap.get(id);
+ }
+
+ public void removePushSession(String id) {
+ PushSessionImpl session = pushSessionMap.remove(id);
+ if (session != null) {
+ expirationQueue.remove(session);
+ }
+ }
+
+ void onRequestConnected(PushSessionImpl pushSession) {
+ expirationQueue.remove(pushSession);
+ }
+
+ void onRequestDisconnected(PushSessionImpl pushSession) {
+ expirationQueue.add(pushSession);
+ }
+
+ public SubscriptionContext getSubscriptionContext() {
+ return subscriptionContext;
+ }
+}
Modified: branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js
===================================================================
--- branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-10-11 16:06:07 UTC (rev 19520)
+++ branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-10-11 16:13:31 UTC (rev 19521)
@@ -7,8 +7,13 @@
__callback: function(response) {
var dataString = response.responseBody.replace(suspendMessageEndMarker, "");
if (dataString) {
- var data = jQuery.parseJSON(dataString);
- alert(data[0].data);
+ var messages = jQuery.parseJSON(dataString);
+ if (messages) {
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ alert(message.data);
+ }
+ }
}
},
15 years, 7 months
JBoss Rich Faces SVN: r19520 - in branches/RF-7817: push-redesign and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-11 12:06:07 -0400 (Mon, 11 Oct 2010)
New Revision: 19520
Added:
branches/RF-7817/push-redesign-app/
branches/RF-7817/push-redesign-app/pom.xml
branches/RF-7817/push-redesign-app/src/
branches/RF-7817/push-redesign-app/src/main/
branches/RF-7817/push-redesign-app/src/main/java/
branches/RF-7817/push-redesign-app/src/main/java/demo/
branches/RF-7817/push-redesign-app/src/main/java/demo/Bean.java
branches/RF-7817/push-redesign-app/src/main/resources/
branches/RF-7817/push-redesign-app/src/main/webapp/
branches/RF-7817/push-redesign-app/src/main/webapp/META-INF/
branches/RF-7817/push-redesign-app/src/main/webapp/META-INF/MANIFEST.MF
branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/
branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/faces-config.xml
branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/lib/
branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/web.xml
branches/RF-7817/push-redesign-app/src/main/webapp/index.xhtml
branches/RF-7817/push-redesign-app/src/main/webapp/resources/
branches/RF-7817/push-redesign/pom.xml
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java
branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/MessageListener.java
branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/SubscriptionContext.java
Removed:
branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java
branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java
Modified:
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/renderkit/html/PushRenderer.java
branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java
branches/RF-7817/push-redesign/src/main/resources/META-INF/faces-config.xml
branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js
branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/PublisherContext.java
Log:
https://jira.jboss.org/browse/RF-7817
Added: branches/RF-7817/push-redesign/pom.xml
===================================================================
--- branches/RF-7817/push-redesign/pom.xml (rev 0)
+++ branches/RF-7817/push-redesign/pom.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,58 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>push-redesign</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>push-redesign</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>3.0-alpha-1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-api</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <version>0.6.2</version>
+ </dependency>
+ </dependencies>
+</project>
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/AtmospherePushHandler.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -21,99 +21,97 @@
*/
package org.richfaces.application.impl;
-import static org.richfaces.application.PushPublisherContext.PUBLISHER_ATTRIBUTE_NAME;
-import static org.richfaces.component.PushSubscriberContext.SUBSCRIBER_ATTRIBUTE_NAME;
-
import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Map;
+import java.util.concurrent.Executors;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.atmosphere.cpr.AtmosphereHandler;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceEvent;
-import org.atmosphere.cpr.AtmosphereServlet.AtmosphereHandlerWrapper;
-import org.atmosphere.cpr.Broadcaster;
-import org.atmosphere.cpr.DefaultBroadcaster;
-import org.richfaces.SubscriberKey;
-import org.richfaces.TopicKey;
-import org.richfaces.application.MessagePublisher;
-import org.richfaces.application.PushPublisherContext;
-import org.richfaces.component.PushSubscriberContext;
-import org.richfaces.component.Subscription;
+import org.richfaces.application.push.TopicKey;
-import com.google.common.base.Function;
-import com.google.common.collect.MapMaker;
-
/**
* @author Nick Belaevski
*
*/
-public class AtmospherePushHandler implements AtmosphereHandler<HttpServletRequest, HttpServletResponse>, MessagePublisher {
+public class AtmospherePushHandler implements AtmosphereHandler<HttpServletRequest, HttpServletResponse> {
- private PushSubscriberContext subscriberContext;
+ private static final String PUSH_SESSION_ID_PARAM = "pushSessionId";
- private PushPublisherContext publisherContext;
+ private static final String PUSH_SESSION_ATTRIBUTE = "pushSession";
+
+// private PushSubscriberContext subscriberContext;
+//
+// private PushPublisherContext publisherContext;
+//
+// private Map<TopicKey, Broadcaster> broadcasters = new MapMaker().makeComputingMap(new Function<TopicKey, Broadcaster>() {
+// public Broadcaster apply(TopicKey from) {
+// return new DefaultBroadcaster(from.getTopicName());
+// };
+// });
+//
- private Map<TopicKey, Broadcaster> broadcasters = new MapMaker().makeComputingMap(new Function<TopicKey, Broadcaster>() {
- public Broadcaster apply(TopicKey from) {
- return new DefaultBroadcaster(from.getTopicName());
- };
- });
+ private PushSessionTracker pushTracker;
- public AtmospherePushHandler(ServletContext servletContext) {
+ protected PushSessionTracker getPushTracker() {
+ return pushTracker;
+ }
+
+ public AtmospherePushHandler(MessagesContextImpl messagesContext) {
super();
- subscriberContext = new PushSubscriberContextImpl();
- publisherContext = new PushPublisherContextImpl(this);
-
- servletContext.setAttribute(SUBSCRIBER_ATTRIBUTE_NAME, subscriberContext);
- servletContext.setAttribute(PUBLISHER_ATTRIBUTE_NAME, publisherContext);
+ pushTracker = new PushSessionTracker(Executors.newFixedThreadPool(1), messagesContext);
}
- protected SubscriberKey getSubscriberKey(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) {
- return new SubscriberKey(resource.getRequest().getParameter("pid"));
- }
-
- public void publish(TopicKey topicKey, String message) {
- Broadcaster broadcaster = broadcasters.get(topicKey);
- broadcaster.broadcast(message);
- }
-
+ /* (non-Javadoc)
+ * @see org.atmosphere.cpr.AtmosphereHandler#onRequest(org.atmosphere.cpr.AtmosphereResource)
+ */
public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
- SubscriberKey subscriberKey = getSubscriberKey(resource);
+ // TODO Auto-generated method stub
+
+ HttpServletRequest req = resource.getRequest();
+ HttpServletResponse resp = resource.getResponse();
- Subscription[] subscriptions = subscriberContext.getSubscriptions(subscriberKey);
- if (subscriptions == null) {
- //TODO - handle
+ String pushSessionId = req.getParameter(PUSH_SESSION_ID_PARAM);
+
+ PushSessionImpl pushSession = null;
+
+ if (pushSessionId != null) {
+ pushSession = getPushTracker().getPushSession(pushSessionId);
}
- subscriberContext.onRequestStarted(subscriberKey);
+ if (pushSession == null) {
+ //TODO - debug log
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
- //TODO - ONLY FOR TESTING!!!
- Broadcaster broadcaster = broadcasters.get(subscriptions[0].getTopicKey());
- broadcaster.addAtmosphereResource(resource);
+ resp.setContentType("text/plain");
- //TODO - review
- resource.getAtmosphereConfig().mapBroadcasterToAtmosphereHandler(broadcaster, new AtmosphereHandlerWrapper(this, broadcaster));
-
- resource.suspend();
+ req.setAttribute(PUSH_SESSION_ATTRIBUTE, pushSession);
+ pushSession.connect(new RequestImpl(resource));
+ pushSession.writeMessages();
}
public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
throws IOException {
+ //do nothing
+ }
- if (event.isCancelled()) {
- SubscriberKey subscriberKey = getSubscriberKey(event.getResource());
- subscriberContext.onRequestFinished(subscriberKey);
- } else {
- PrintWriter responseWriter = event.getResource().getResponse().getWriter();
- responseWriter.write(event.getMessage().toString());
- responseWriter.flush();
+ public PushSessionImpl doConnect(String[] topicNames) {
+ PushSessionImpl pushSession = getPushTracker().createPushSession();
+
+ TopicKey[] topicKeys = new TopicKey[topicNames.length];
+ for (int i = 0; i < topicNames.length; i++) {
+ String topicName = topicNames[i];
+
+ topicKeys[i] = new TopicKey(topicName);
}
+
+ //TODO - check permissions for channels
+ pushSession.subscribe(topicKeys);
+ return pushSession;
}
-
}
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/DefaultMessageSerializer.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ajax4jsf.javascript.ScriptUtils;
-import org.richfaces.Message;
-import org.richfaces.application.MessageSerializer;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class DefaultMessageSerializer implements MessageSerializer {
-
- public static final String TOPIC_ATTRIBUTE = "topic";
-
- public static final String ATTRIBUTES_ATTRIBUTE = "attributes";
-
- public static final String DATA_ATTRIBUTE = "data";
-
- public String serialize(Message message) {
- Map<String,Object> dataMap = new HashMap<String, Object>();
-
- dataMap.put(TOPIC_ATTRIBUTE, message.getTopicKey().getTopicName());
-
- if (message.hasAttributes()) {
- dataMap.put(ATTRIBUTES_ATTRIBUTE, message.getAttributes());
- }
-
- dataMap.put(DATA_ATTRIBUTE, message.getData());
-
- return ScriptUtils.toScript(dataMap);
- }
-
-}
+///*
+// * JBoss, Home of Professional Open Source
+// * Copyright 2010, Red Hat, Inc. and individual contributors
+// * by the @authors tag. See the copyright.txt in the distribution for a
+// * full listing of individual contributors.
+// *
+// * This is free software; you can redistribute it and/or modify it
+// * under the terms of the GNU Lesser General Public License as
+// * published by the Free Software Foundation; either version 2.1 of
+// * the License, or (at your option) any later version.
+// *
+// * This software is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// * Lesser General Public License for more details.
+// *
+// * You should have received a copy of the GNU Lesser General Public
+// * License along with this software; if not, write to the Free
+// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+// */
+//package org.richfaces.application.impl;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//import org.ajax4jsf.javascript.ScriptUtils;
+//import org.richfaces.Message;
+//import org.richfaces.application.MessageSerializer;
+//
+///**
+// * @author Nick Belaevski
+// *
+// */
+//public class DefaultMessageSerializer implements MessageSerializer {
+//
+// public static final String TOPIC_ATTRIBUTE = "topic";
+//
+// public static final String ATTRIBUTES_ATTRIBUTE = "attributes";
+//
+// public static final String DATA_ATTRIBUTE = "data";
+//
+// public String serialize(Message message) {
+// Map<String,Object> dataMap = new HashMap<String, Object>();
+//
+// dataMap.put(TOPIC_ATTRIBUTE, message.getTopicKey().getTopicName());
+//
+// if (message.hasAttributes()) {
+// dataMap.put(ATTRIBUTES_ATTRIBUTE, message.getAttributes());
+// }
+//
+// dataMap.put(DATA_ATTRIBUTE, message.getData());
+//
+// return ScriptUtils.toScript(dataMap);
+// }
+//
+//}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/MessagesContextImpl.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.servlet.ServletContext;
+
+import org.richfaces.application.push.Message;
+import org.richfaces.application.push.MessageListener;
+import org.richfaces.application.push.PublisherContext;
+import org.richfaces.application.push.SubscriptionContext;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MessagesContextImpl implements SubscriptionContext, PublisherContext {
+
+ private ConcurrentMap<TopicKey, List<MessageListener>> listenersMap = new ConcurrentHashMap<TopicKey, List<MessageListener>>();
+
+ private MessagesContextImpl() {}
+
+ public void addMessageListener(TopicKey topicKey, MessageListener listener) {
+ List<MessageListener> listeners = listenersMap.get(topicKey);
+ if (listeners == null) {
+ List<MessageListener> newListenersList = new CopyOnWriteArrayList<MessageListener>();
+
+ listeners = listenersMap.putIfAbsent(topicKey, newListenersList);
+ if (listeners == null) {
+ listeners = newListenersList;
+ }
+ }
+
+ listeners.add(listener);
+ }
+
+ public void removeMessageListener(TopicKey topicKey, MessageListener listener) {
+ List<MessageListener> listeners = listenersMap.get(topicKey);
+ if (listeners != null) {
+ listeners.remove(listener);
+ }
+ }
+
+ public void publish(TopicKey topicKey, Object data) {
+ Message message = new Message(topicKey);
+ message.setData(data);
+
+ publish(message);
+ }
+
+ public void publish(Message message) {
+ List<MessageListener> listeners = listenersMap.get(message.getTopicKey());
+ if (listeners != null) {
+ for (MessageListener listener : listeners) {
+ listener.onMessage(message);
+ }
+ }
+ }
+
+ public static MessagesContextImpl create(ServletContext servletContext) {
+ MessagesContextImpl result = new MessagesContextImpl();
+
+ servletContext.setAttribute(PublisherContext.ATTRIBUTE_NAME, result);
+
+ return result;
+ }
+
+ public static void destroy(ServletContext servletContext) {
+ servletContext.removeAttribute(PublisherContext.ATTRIBUTE_NAME);
+ }
+
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSession.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.io.IOException;
+
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface PushSession {
+
+ public void subscribe(TopicKey[] topics);
+
+ public void connect(Request request);
+
+ public void writeMessages() throws IOException;
+
+ public void disconnect();
+
+ public void destroy();
+
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionImpl.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.io.IOException;
+import java.util.Queue;
+import java.util.concurrent.Delayed;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.richfaces.application.push.Message;
+import org.richfaces.application.push.MessageListener;
+import org.richfaces.application.push.SubscriptionContext;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushSessionImpl implements Delayed, PushSession {
+
+ private static final long EXPIRATION_DELAY = 30 * 1000;
+
+ private String id;
+
+ private AtomicReference<Request> requestRef =
+ new AtomicReference<Request>();
+
+ private PushSessionTracker pushTracker;
+
+ private volatile long expirationTime;
+
+ private TopicKey[] topics;
+
+ private Queue<Message> messagesQueue = new LinkedBlockingQueue<Message>();
+
+ private MessageListener queueMessageListener = new MessageListener() {
+
+ public void onMessage(Message message) {
+ messagesQueue.add(message);
+ Request request = requestRef.get();
+
+ if (request != null && request.isSuspended()) {
+ try {
+ writeMessages();
+ request.resume();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+
+ private RequestLifecycleListener requestLifecycleListener = new RequestLifecycleListener() {
+
+ public void onSuspend(Request request) {
+ try {
+ writeMessages();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void onResume(Request request) {
+ // TODO Auto-generated method stub
+ }
+
+ public void onDisconnect(Request request) {
+ // TODO Auto-generated method stub
+ PushSessionImpl.this.disconnect();
+ }
+ };
+
+ public PushSessionImpl(PushSessionTracker pushTracker) {
+ super();
+ this.pushTracker = pushTracker;
+ resetExpirationTime();
+ }
+
+ private void resetExpirationTime() {
+ expirationTime = System.currentTimeMillis() + EXPIRATION_DELAY;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int compareTo(Delayed o) {
+ return Long.valueOf(getDelay(TimeUnit.MILLISECONDS)).compareTo(o.getDelay(TimeUnit.MILLISECONDS));
+ }
+
+ public long getDelay(TimeUnit unit) {
+ return unit.convert(expirationTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+ }
+
+ public synchronized void subscribe(TopicKey[] topics) {
+ SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
+
+ if (this.topics != null) {
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
+ }
+ }
+
+ this.topics = topics;
+
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.addMessageListener(topicKey, queueMessageListener);
+ }
+
+ }
+
+ public void connect(Request request) {
+ if (this.requestRef.getAndSet(request) != null) {
+ disconnect();
+ }
+
+ pushTracker.onRequestConnected(this);
+ request.addListener(requestLifecycleListener);
+ }
+
+ public synchronized void writeMessages() throws IOException {
+ Request request = requestRef.get();
+
+ if (request == null) {
+ return;
+ }
+
+ Message message = null;
+
+ while (true) {
+ message = messagesQueue.poll();
+
+ if (message == null) {
+ break;
+ }
+
+ request.write(message);
+ }
+
+ if (message == null) {
+ request.suspend();
+ } else {
+ request.resume();
+ }
+ }
+
+ public void disconnect() {
+ Request request = this.requestRef.getAndSet(null);
+ if (request == null) {
+ return;
+ }
+
+ request.removeListener(requestLifecycleListener);
+ pushTracker.onRequestDisconnected(this);
+ }
+
+ public synchronized void destroy() {
+ SubscriptionContext subscriptionContext = pushTracker.getSubscriptionContext();
+ for (TopicKey topicKey : topics) {
+ subscriptionContext.removeMessageListener(topicKey, queueMessageListener);
+ }
+ }
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/PushSessionTracker.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.DelayQueue;
+import java.util.concurrent.ExecutorService;
+
+import org.richfaces.application.push.SubscriptionContext;
+
+import com.google.common.collect.MapMaker;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushSessionTracker {
+
+ private final class SessionsExpirationRunnable implements Runnable {
+ public void run() {
+ while (true) {
+ try {
+ PushSessionImpl pushSession = expirationQueue.take();
+ pushSessionMap.remove(pushSession.getId());
+ pushSession.destroy();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+ }
+
+ private SubscriptionContext subscriptionContext;
+
+ private ConcurrentMap<String, PushSessionImpl> pushSessionMap = new MapMaker().makeMap();
+
+ private DelayQueue<PushSessionImpl> expirationQueue = new DelayQueue<PushSessionImpl>();
+
+ public PushSessionTracker(ExecutorService executorService, SubscriptionContext subscriptionContext) {
+ executorService.submit(new SessionsExpirationRunnable());
+
+ this.subscriptionContext = subscriptionContext;
+ }
+
+ public PushSessionImpl createPushSession() {
+ PushSessionImpl pushSession = new PushSessionImpl(this);
+ while (true) {
+ String uuid = UUID.randomUUID().toString();
+ pushSession.setId(uuid);
+ if (pushSessionMap.putIfAbsent(uuid, pushSession) == null) {
+ expirationQueue.put(pushSession);
+
+ return pushSession;
+ }
+ }
+ }
+
+ public PushSessionImpl getPushSession(String id) {
+ return pushSessionMap.get(id);
+ }
+
+ public void removePushSession(String id) {
+ PushSessionImpl session = pushSessionMap.remove(id);
+ if (session != null) {
+ expirationQueue.remove(session);
+ }
+ }
+
+ void onRequestConnected(PushSessionImpl pushSession) {
+ expirationQueue.remove(pushSession);
+ }
+
+ void onRequestDisconnected(PushSessionImpl pushSession) {
+ expirationQueue.add(pushSession);
+ }
+
+ public SubscriptionContext getSubscriptionContext() {
+ return subscriptionContext;
+ }
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/Request.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.io.IOException;
+
+import org.richfaces.application.push.Message;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface Request {
+
+ public void write(Message message) throws IOException;
+
+ public void suspend() throws IOException;
+
+ public void resume() throws IOException;
+
+ public void addListener(RequestLifecycleListener listener);
+
+ public void removeListener(RequestLifecycleListener listener);
+
+ public boolean isSuspended();
+
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestImpl.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.atmosphere.cpr.AtmosphereEventLifecycle;
+import org.atmosphere.cpr.AtmosphereResource;
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.atmosphere.cpr.AtmosphereResourceEventListener;
+import org.richfaces.application.push.Message;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RequestImpl implements Request {
+
+ private static final String DATA_WRAPPER_START = "[";
+
+ private static final String DATA_WRAPPER_END = "]";
+
+ private static final String DATA_BLANK = "";
+
+ private AtmosphereResource<HttpServletRequest, HttpServletResponse> atmosphereResource;
+
+ private List<RequestLifecycleListener> listeners = new ArrayList<RequestLifecycleListener>(2);
+
+ private AtmosphereResourceEventListener atmosphereListener = new AtmosphereResourceEventListener() {
+
+ public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onSuspend(RequestImpl.this);
+ }
+ }
+
+ public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onResume(RequestImpl.this);
+ }
+
+ try {
+ encodeRequestEndElement();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ for (RequestLifecycleListener listener : listeners) {
+ listener.onDisconnect(RequestImpl.this);
+ }
+ }
+
+ public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ private boolean hasWrittenMessages = false;
+
+
+ public RequestImpl(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) {
+ super();
+
+ this.atmosphereResource = resource;
+ ((AtmosphereEventLifecycle) atmosphereResource).addEventListener(atmosphereListener);
+ }
+
+ public void addListener(RequestLifecycleListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(RequestLifecycleListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void write(Message message) throws IOException {
+ HttpServletResponse response = atmosphereResource.getResponse();
+
+ PrintWriter writer = response.getWriter();
+
+ if (!hasWrittenMessages) {
+ encodeRequestStartElement();
+ }
+
+ Map<String,Object> map = new HashMap<String, Object>();
+
+ map.put("topic", message.getTopicKey().getTopicName());
+ map.put("data", message.getData());
+ map.put("attributes", message.getAttributes());
+
+ //TODO use message serializer
+ writer.write(ScriptUtils.toScript(map));
+
+ if (hasWrittenMessages) {
+ writer.write(", ");
+ } else {
+ hasWrittenMessages = true;
+ }
+
+ writer.flush();
+
+ }
+
+ public void suspend() throws IOException {
+ if (!isSuspended()) {
+ //TODO - customize interval
+ atmosphereResource.suspend();
+ }
+ }
+
+ public void resume() throws IOException {
+ if (isSuspended()) {
+ atmosphereResource.resume();
+ }
+ }
+
+ public boolean isSuspended() {
+ return atmosphereResource.getAtmosphereResourceEvent().isSuspended();
+ }
+
+ public void encodeRequestStartElement() throws IOException {
+ write(DATA_WRAPPER_START);
+ }
+
+ public void encodeRequestEndElement() throws IOException {
+ if (hasWrittenMessages) {
+ write(DATA_WRAPPER_END);
+ } else {
+ write(DATA_BLANK);
+ }
+ }
+
+ private void write(String s) throws IOException {
+ HttpServletResponse response = atmosphereResource.getResponse();
+
+ PrintWriter writer = response.getWriter();
+ writer.write(s);
+ }
+}
Added: branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java (rev 0)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/impl/RequestLifecycleListener.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.impl;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface RequestLifecycleListener {
+
+ public void onSuspend(Request request);
+
+ public void onDisconnect(Request request);
+
+ public void onResume(Request request);
+
+}
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/renderkit/html/PushRenderer.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/renderkit/html/PushRenderer.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/renderkit/html/PushRenderer.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -21,12 +21,10 @@
*/
package org.richfaces.renderkit.html;
-import static org.richfaces.component.PushSubscriberContext.SUBSCRIBER_ATTRIBUTE_NAME;
-
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -37,9 +35,6 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.SubscriberKey;
-import org.richfaces.TopicKey;
-import org.richfaces.component.PushSubscriberContext;
import org.richfaces.component.UIPush;
import org.richfaces.renderkit.HtmlConstants;
@@ -54,32 +49,14 @@
})
public class PushRenderer extends Renderer {
- private static final String PUSH_PID_ATTRIBUTE = "org.richfaces.PushPID";
-
- private String getPushId(FacesContext context) {
- Map<String, Object> viewMap = context.getViewRoot().getViewMap();
- String pid = (String) viewMap.get(PUSH_PID_ATTRIBUTE);
- if (pid == null) {
- pid = UUID.randomUUID().toString();
- viewMap.put(PUSH_PID_ATTRIBUTE, pid);
- }
-
- return pid;
- }
-
- private String getPushUrl(FacesContext context, String pushId) {
+ private String getPushUrl(FacesContext context) {
ExternalContext ec = context.getExternalContext();
- return MessageFormat.format("{0}://{1}:{2,number,#####}{3}/atmosphere/?pid={4}",
+ return MessageFormat.format("{0}://{1}:{2,number,#####}{3}/push",
ec.getRequestScheme(), ec.getRequestServerName(),
- ec.getRequestServerPort(), ec.getRequestContextPath(),
- pushId);
+ ec.getRequestServerPort(), ec.getRequestContextPath());
}
- private PushSubscriberContext getPushSubscriberContext(FacesContext context) {
- return (PushSubscriberContext) context.getExternalContext().getApplicationMap().get(SUBSCRIBER_ATTRIBUTE_NAME);
- }
-
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
super.encodeEnd(context, component);
@@ -91,18 +68,17 @@
writer.startElement(HtmlConstants.SPAN_ELEM, component);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, component.getClientId(context), "id");
- String pushId = getPushId(context);
-
writer.startElement(HtmlConstants.SCRIPT_ELEM, component);
writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.TEXT_JAVASCRIPT_TYPE, null);
- writer.writeText(new JSFunction("Push.connect", getPushUrl(context, pushId)).toScript(), null);
+ Map<String,Object> options = new HashMap<String, Object>();
+ options.put("topics", new String[] {push.getTopic(), "meta"});
+
+ writer.writeText(new JSFunction("Push.connect", getPushUrl(context), options).toScript(), null);
writer.endElement(HtmlConstants.SCRIPT_ELEM);
writer.endElement(HtmlConstants.SPAN_ELEM);
-
- getPushSubscriberContext(context).subscribe(new SubscriberKey(pushId), new TopicKey(push.getTopic()));
}
}
Modified: branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java
===================================================================
--- branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushServlet.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -21,15 +21,19 @@
*/
package org.richfaces.webapp;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URLClassLoader;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.atmosphere.cpr.AtmosphereServlet;
-import org.atmosphere.cpr.DefaultBroadcaster;
import org.richfaces.application.impl.AtmospherePushHandler;
+import org.richfaces.application.impl.MessagesContextImpl;
+import org.richfaces.application.impl.PushSessionImpl;
/**
* @author Nick Belaevski
@@ -37,19 +41,62 @@
*/
public class PushServlet extends AtmosphereServlet {
+ /**
+ *
+ */
+ private static final String PUSH_HUB_MAPPING = "/push/hub/*";
+
private static final long serialVersionUID = 7616370505508715222L;
- public PushServlet() {
- super();
- }
+ private static final String PUSH_TOPIC_PARAM = "pushTopic[]";
+ private AtmospherePushHandler pushHandler;
+
+ private ServletContext servletContext;
+
@Override
- protected void autoDetectAtmosphereHandlers(ServletContext sc, URLClassLoader c) throws MalformedURLException,
- URISyntaxException {
- super.autoDetectAtmosphereHandlers(sc, c);
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
- addAtmosphereHandler("/atmosphere/*", new AtmospherePushHandler(sc), new DefaultBroadcaster());
+ servletContext = config.getServletContext();
+ MessagesContextImpl messagesContext = MessagesContextImpl.create(servletContext);
+
+ pushHandler = new AtmospherePushHandler(messagesContext);
+ addAtmosphereHandler(PUSH_HUB_MAPPING, pushHandler);
+
}
+ @Override
+ public void destroy() {
+ super.destroy();
+
+ MessagesContextImpl.destroy(servletContext);
+
+ pushHandler = null;
+ removeAtmosphereHandler(PUSH_HUB_MAPPING);
+ }
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ String[] topicNames = req.getParameterValues(PUSH_TOPIC_PARAM);
+ PushSessionImpl pushData = pushHandler.doConnect(topicNames);
+
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.getWriter().write(pushData.getId());
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
+ doCometSupport(req, res);
+ }
+
+ /* (non-Javadoc)
+ * @see org.atmosphere.cpr.AtmosphereServlet#detectSupportedFramework(javax.servlet.ServletConfig)
+ */
+ @Override
+ protected boolean detectSupportedFramework(ServletConfig sc) throws ClassNotFoundException, IllegalAccessException,
+ InstantiationException, NoSuchMethodException, InvocationTargetException {
+
+ return false;
+ }
}
Modified: branches/RF-7817/push-redesign/src/main/resources/META-INF/faces-config.xml
===================================================================
--- branches/RF-7817/push-redesign/src/main/resources/META-INF/faces-config.xml 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/resources/META-INF/faces-config.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -3,12 +3,6 @@
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
- <managed-bean eager="true">
- <managed-bean-name>__pushSubscriberContext</managed-bean-name>
- <managed-bean-class>org.richfaces.application.impl.PushSubscriberContextImpl</managed-bean-class>
- <managed-bean-scope>application</managed-bean-scope>
- </managed-bean>
-
<component>
<component-type>org.richfaces.Push</component-type>
<component-class>org.richfaces.component.UIPush</component-class>
Modified: branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js
===================================================================
--- branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-10-11 16:06:07 UTC (rev 19520)
@@ -1,22 +1,79 @@
Push = (function() {
+
+ var suspendMessageEndMarker = /(<!--[^>]+-->\s*)+/;
- var connected = false;
-
return {
__callback: function(response) {
- alert(response.responseBody);
- response.responseBody = "";
+ var dataString = response.responseBody.replace(suspendMessageEndMarker, "");
+ if (dataString) {
+ var data = jQuery.parseJSON(dataString);
+ alert(data[0].data);
+ }
},
+
+ __startPoll: function() {
+ //TODO separate URLs
+
+ var pushSessionId = this.getPushSessionId();
+
+ jQuery.atmosphere.subscribe(this.getUrl() + "/hub?pushSessionId=" + pushSessionId,
+ jQuery.proxy(this.__callback, this));
+ },
+
+ __stopPoll: function() {
+ //TODO implement
+ },
+ getUrl: function() {
+ return this.__url;
+ },
+
+ setUrl: function(url) {
+ this.__url = url;
+ },
+
+ getInterval: function() {
+ return this.__interval;
+ },
+
+ setInterval: function(interval) {
+ this.__interval = interval;
+ },
+
+ getPushSessionId: function(id) {
+ return this.__pushSessionId;
+ },
+
+ setPushSessionId: function(id) {
+ this.__pushSessionId = id;
+ },
+
connect: function(url, opts) {
- if (connected) {
- return ;
+ if (this.__connected) {
+ this.disconnect();
}
+
+ opts = opts || {};
- $.atmosphere.subscribe(url, this.__callback, opts);
+ this.setUrl(url);
- connected = true;
+ var connectionResponseHandler = jQuery.proxy(function(data) {
+ this.setPushSessionId(data);
+ this.__startPoll();
+ }, this);
+
+ //TODO handle request errors
+ //TODO separate URLs
+ jQuery.post(url + "/connect", {"pushTopic": opts.topics}, connectionResponseHandler, 'text');
+
+ this.__connected = true;
+ },
+
+ disconnect: function() {
+ this.__connected = false;
+ this.__stopPoll();
+ this.setPushSessionId(null);
}
}
Added: branches/RF-7817/push-redesign-app/pom.xml
===================================================================
--- branches/RF-7817/push-redesign-app/pom.xml (rev 0)
+++ branches/RF-7817/push-redesign-app/pom.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>push-redesign-app</artifactId>
+ <packaging>war</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>push-redesign-app Maven Webapp</name>
+ <url>http://maven.apache.org</url>
+
+ <repositories>
+ <repository>
+ <id>sonatype.snapshots</id>
+ <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>3.0-alpha-1</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>8.0.0.M1</version>
+ </dependency -->
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <version>0.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>push-redesign</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-ui</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>push-redesign-app</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>8.0.0.M1</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: branches/RF-7817/push-redesign-app/src/main/java/demo/Bean.java
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/java/demo/Bean.java (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/java/demo/Bean.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.RequestScoped;
+
+import org.richfaces.application.push.PublisherContext;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@RequestScoped
+public class Bean {
+
+ private String message;
+
+ @ManagedProperty("#{" + PublisherContext.ATTRIBUTE_NAME + "}")
+ private PublisherContext publisherContext;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public void say() {
+ publisherContext.publish(new TopicKey("chat"), message);
+ }
+
+ /**
+ * @param publisherContext the publisherContext to set
+ */
+ public void setPublisherContext(PublisherContext publisherContext) {
+ this.publisherContext = publisherContext;
+ }
+}
Added: branches/RF-7817/push-redesign-app/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/webapp/META-INF/MANIFEST.MF 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
Added: branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/faces-config.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ version="2.0">
+
+</faces-config>
\ No newline at end of file
Added: branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/jboss-scanning.xml (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,11 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+<!--
+ For JBoss AS 6 integration there is a conflict with guava, and
+ google-collections. JBAS-8361
+-->
+ <path name="WEB-INF/classes"></path>
+
+ <path name="WEB-INF/lib/guava-r05.jar">
+ <exclude name="com.google.common.collect" />
+ </path>
+</scanning>
\ No newline at end of file
Added: branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/webapp/WEB-INF/web.xml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
+
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>push</servlet-name>
+ <servlet-class>org.richfaces.webapp.PushServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ <async-supported>true</async-supported>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>push</servlet-name>
+ <url-pattern>/push/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Added: branches/RF-7817/push-redesign-app/src/main/webapp/index.xhtml
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/index.xhtml (rev 0)
+++ branches/RF-7817/push-redesign-app/src/main/webapp/index.xhtml 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:p="http://richfaces.org/push">
+
+ <h:head>
+ </h:head>
+ <h:body>
+ <p:push topic="chat" />
+
+ <h:outputText id="text" />
+
+ <h:form>
+ <h:inputText value="#{bean.message}" />
+
+ <h:commandLink value="ajax" action="#{bean.say}">
+ <f:ajax render=":text" execute="@form" />
+ </h:commandLink>
+ </h:form>
+
+ </h:body>
+</html>
\ No newline at end of file
Added: branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/MessageListener.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/MessageListener.java (rev 0)
+++ branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/MessageListener.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface MessageListener {
+
+ public void onMessage(Message message);
+
+}
Modified: branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/PublisherContext.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/PublisherContext.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/PublisherContext.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -29,6 +29,8 @@
*/
public interface PublisherContext {
+ public static final String ATTRIBUTE_NAME = "__publisherContxt";
+
//TODO - return Future?
//TODO - use topic key?
public void publish(TopicKey topic, Object data);
Added: branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/SubscriptionContext.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/SubscriptionContext.java (rev 0)
+++ branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/SubscriptionContext.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface SubscriptionContext {
+
+ public void addMessageListener(TopicKey topicKey, MessageListener listener);
+
+ public void removeMessageListener(TopicKey topicKey, MessageListener listener);
+
+}
Deleted: branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueueSettings.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.push;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface TopicQueueSettings {
-
- public void addMessageTransformer(MessageTransformer transformer);
-
- public void removeMessageTransformer(MessageTransformer transformer);
-
- public void setMessageSerializer(MessageSerializer serializer);
-
- public MessageSerializer getMessageSerializer();
-
- public void addMessageFilter(MessageFilter filter);
-
- public void removeMessageFilter(MessageFilter filter);
-
- public boolean isSessionAware();
-
- public void setSessionAware(boolean sessionAware);
-
- public boolean isFacesContextAware();
-
- public void setFacesContextAware(boolean facesContextAware);
-
- public TopicMode getDeliveryMode();
-
- public void setDeliveryMode(TopicMode mode);
-
- public int getCapacity();
-
- public void setCapacity(int capacity);
-
- //TODO - transport settings?
-
-}
Deleted: branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java
===================================================================
--- branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java 2010-10-11 14:13:05 UTC (rev 19519)
+++ branches/RF-7817/ui/core/api/src/main/java/org/richfaces/application/push/TopicQueuesContext.java 2010-10-11 16:06:07 UTC (rev 19520)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application.push;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface TopicQueuesContext {
-
- public TopicQueueSettings getTopicQueueSettings(TopicKey topicKey);
-
- public TopicQueueSettings getDefaultTopicQueueSettings();
-
-}
-
15 years, 7 months
JBoss Rich Faces SVN: r19519 - in trunk/ui/input: ui/src/main/java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-11 10:13:05 -0400 (Mon, 11 Oct 2010)
New Revision: 19519
Modified:
trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
Log:
add license headers, add events for the inplaceSelect component
Modified: trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-11 13:16:22 UTC (rev 19518)
+++ trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-11 14:13:05 UTC (rev 19519)
@@ -1,6 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
+/**
+ * @author Anton Belevich
+ *
+ */
public interface InplaceComponent {
public String getDefaultLabel();
Modified: trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 13:16:22 UTC (rev 19518)
+++ trunk/ui/input/api/src/main/java/org/richfaces/component/InplaceState.java 2010-10-11 14:13:05 UTC (rev 19519)
@@ -19,8 +19,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+
package org.richfaces.component;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
public enum InplaceState {
ready,
edit,
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-11 13:16:22 UTC (rev 19518)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-11 14:13:05 UTC (rev 19519)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
import javax.faces.component.UISelectOne;
@@ -3,4 +25,5 @@
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -46,4 +69,47 @@
@Attribute(defaultValue="click")
public abstract String getEditEvent();
+
+ @Attribute(events=@EventName("blur"))
+ public abstract String getOnblur();
+
+ @Attribute(events=@EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events=@EventName("ondblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events=@EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events=@EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events=@EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events=@EventName("keyup"))
+ public abstract String getOnkeypup();
+
+ @Attribute(events=@EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events=@EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events=@EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events=@EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events=@EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Attribute(events=@EventName("select"))
+ public abstract String getOnselect();
+
+ @Attribute(events=@EventName("change"))
+ public abstract String getOnchange();
+
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 13:16:22 UTC (rev 19518)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-11 14:13:05 UTC (rev 19519)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit;
import java.io.IOException;
@@ -2,2 +24,3 @@
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
@@ -95,7 +118,16 @@
+ "}";
}
}
+
+ private static final Map<String, ComponentAttribute> INPLACESELECT_HANDLER_ATTRIBUTES = Collections
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE).setEventNames("change").
+ setComponentAttributeName("onchange"),
+ new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE).setEventNames("select").
+ setComponentAttributeName("onselect")
+ ));
+
@Override
protected String getScriptName() {
return "new RichFaces.ui.InplaceSelect";
@@ -116,8 +148,13 @@
}
return clientSelectItems;
}
-
+
@Override
+ protected void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, INPLACESELECT_HANDLER_ATTRIBUTES);
+ }
+
+ @Override
public void addToOptions(FacesContext facesContext, UIComponent component,
Map<String, Object> options, Object additional) {
options.put(OPTIONS_ITEM_CLASS, "rf-is-opt");
15 years, 7 months
JBoss Rich Faces SVN: r19518 - in trunk/ui/input/ui/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-11 09:16:22 -0400 (Mon, 11 Oct 2010)
New Revision: 19518
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
Log:
https://jira.jboss.org/browse/RF-9431
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-11 12:22:58 UTC (rev 19517)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-11 13:16:22 UTC (rev 19518)
@@ -103,41 +103,41 @@
@Attribute(events=@EventName("mouseup"))
public abstract String getOnmouseup();
- @Attribute(events=@EventName("inputClick"))
- public abstract String getOnInputClick();
+ @Attribute(events=@EventName("inputclick"))
+ public abstract String getOninputclick();
- @Attribute(events=@EventName("inputDblclick"))
- public abstract String getOnInputDblclick();
+ @Attribute(events=@EventName("inputdblclick"))
+ public abstract String getOninputdblclick();
- @Attribute(events=@EventName("inputMousedown"))
- public abstract String getOnInputMousedown();
+ @Attribute(events=@EventName("inputmousedown"))
+ public abstract String getOninputmousedown();
- @Attribute(events=@EventName("inputMousemove"))
- public abstract String getOnInputMousemove();
+ @Attribute(events=@EventName("inputmousemove"))
+ public abstract String getOninputmousemove();
- @Attribute(events=@EventName("inputMouseout"))
- public abstract String getOnInputMouseout();
+ @Attribute(events=@EventName("inputmouseout"))
+ public abstract String getOninputmouseout();
- @Attribute(events=@EventName("inputMouseover"))
- public abstract String getOnInputMouseover();
+ @Attribute(events=@EventName("inputmouseover"))
+ public abstract String getOninputmouseover();
- @Attribute(events=@EventName("inputMouseup"))
- public abstract String getOnInputMouseup();
+ @Attribute(events=@EventName("inputmouseup"))
+ public abstract String getOninputmouseup();
- @Attribute(events=@EventName("inputKeydown"))
- public abstract String getOnInputKeydown();
+ @Attribute(events=@EventName("inputkeydown"))
+ public abstract String getOninputkeydown();
- @Attribute(events=@EventName("inputKeypress"))
- public abstract String getOnInputKeypress();
+ @Attribute(events=@EventName("inputkeypress"))
+ public abstract String getOninputkeypress();
- @Attribute(events=@EventName("oninputKeyup"))
- public abstract String getOnInputKeypup();
+ @Attribute(events=@EventName("oninputkeyup"))
+ public abstract String getOninputkeypup();
- @Attribute(events=@EventName("inputFocus"))
- public abstract String getOnInputFocus();
+ @Attribute(events=@EventName("inputfocus"))
+ public abstract String getOninputfocus();
- @Attribute(events=@EventName("inputBlur"))
- public abstract String getOnInputBlur();
+ @Attribute(events=@EventName("inputblur"))
+ public abstract String getOninputblur();
@Attribute(events=@EventName("select"))
public abstract String getOnselect();
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 12:22:58 UTC (rev 19517)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-11 13:16:22 UTC (rev 19518)
@@ -81,30 +81,30 @@
private static final Map<String, ComponentAttribute> INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
.unmodifiableMap(ComponentAttribute.createMap(
- new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE).setEventNames("inputClick").
- setComponentAttributeName("onInputClick"),
- new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE).setEventNames("inputDblclick").
- setComponentAttributeName("onInputDblclick"),
- new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputMousedown").
- setComponentAttributeName("onInputMousedown"),
- new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE).setEventNames("inputMouseup").
- setComponentAttributeName("onInputMouseup"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputMouseover").
- setComponentAttributeName("onInputMouseover"),
- new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputMousemove").
- setComponentAttributeName("onInputMousemove"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputMouseout").
- setComponentAttributeName("onInputMouseout"),
- new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE).setEventNames("inputKeypress").
- setComponentAttributeName("onInputKeypress"),
- new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE).setEventNames("inputKeydown").
- setComponentAttributeName("onInputKeydown"),
- new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE).setEventNames("inputKeyup").
- setComponentAttributeName("onInputKeyup"),
- new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE).setEventNames("inputBlur").
- setComponentAttributeName("onInputBlur"),
- new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE).setEventNames("inputFocus").
- setComponentAttributeName("onInputFocus"),
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE).setEventNames("inputclick").
+ setComponentAttributeName("oninputclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE).setEventNames("inputdblclick").
+ setComponentAttributeName("oninputdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE).setEventNames("inputmousedown").
+ setComponentAttributeName("oninputmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE).setEventNames("inputmouseup").
+ setComponentAttributeName("oninputmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE).setEventNames("inputmouseover").
+ setComponentAttributeName("oninputmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE).setEventNames("inputmousemove").
+ setComponentAttributeName("oninputmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE).setEventNames("inputmouseout").
+ setComponentAttributeName("oninputmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE).setEventNames("inputkeypress").
+ setComponentAttributeName("oninputkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE).setEventNames("inputkeydown").
+ setComponentAttributeName("oninputkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE).setEventNames("inputkeyup").
+ setComponentAttributeName("oninputkeyup"),
+ new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE).setEventNames("inputblur").
+ setComponentAttributeName("oninputblur"),
+ new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE).setEventNames("inputfocus").
+ setComponentAttributeName("oninputfocus"),
new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE).setEventNames("change").
setComponentAttributeName("onchange"),
new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE).setEventNames("select").
15 years, 7 months
JBoss Rich Faces SVN: r19517 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-11 08:22:58 -0400 (Mon, 11 Oct 2010)
New Revision: 19517
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
Log:
refactor scripts
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 09:51:48 UTC (rev 19516)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11 12:22:58 UTC (rev 19517)
@@ -32,7 +32,6 @@
this.editEvent = options.editEvent;
this.noneCss = options.noneCss;
this.changedCss = options.changedCss;
- this.showControls = options.showControls;
this.defaultLabel = options.defaultLabel;
this.element = $(document.getElementById(id));
@@ -43,12 +42,6 @@
this.isSaved = false;
this.useDefaultLabel = false;
- if(this.showControls) {
- this.okbtn = $(document.getElementById(options.okbtn));
- this.cancelbtn = $(document.getElementById(options.cancelbtn));
- this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
- this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler, this));
- }
};
rf.BaseComponent.extend(rf.ui.InplaceBase);
@@ -84,6 +77,10 @@
getNamespace: function() {
},
+ isValueSaved: function() {
+ return this.isSaved;
+ },
+
save: function() {
var value = this.getValue()
if(value.length > 0) {
@@ -99,14 +96,6 @@
this.__hide();
},
- __applyChangedStyles: function() {
- if(this.isValueChanged()) {
- this.element.addClass(this.changedCss);
- } else {
- this.element.removeClass(this.changedCss);
- }
- },
-
cancel: function(){
var text = "";
if(!this.useDefaultLabel) {
@@ -117,14 +106,14 @@
this.__hide();
},
- isValueSaved: function() {
- return this.isSaved;
+ __applyChangedStyles: function() {
+ if(this.isValueChanged()) {
+ this.element.addClass(this.changedCss);
+ } else {
+ this.element.removeClass(this.changedCss);
+ }
},
- __saveValue: function(value) {
-
- },
-
__show: function() {
this.scrollElements = rf.Event.bindScrollEventHandlers(this.id, this.__scrollHandler, this);
this.onshow();
@@ -143,18 +132,7 @@
this.isSaved = false;
this.editContainer.removeClass(this.noneCss);
this.__show();
- },
-
- __saveBtnHandler: function(e) {
- this.save();
- return false;
- },
-
- __cancelBtnHandler: function(e) {
- this.cancel();
- return false;
- },
-
+ },
__scrollHandler: function(e) {
this.cancel();
},
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-11 09:51:48 UTC (rev 19516)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-11 12:22:58 UTC (rev 19517)
@@ -12,12 +12,20 @@
var inputLabel = this.input.val();
this.initialValue = (label == inputLabel) ? label : "";
this.saveOnBlur = options.saveOnBlur;
+ this.showControls = options.showControls;
this.input.bind("focus", $.proxy(this.__editHandler, this));
this.input.bind("change", $.proxy(this.__changeHandler, this));
this.input.bind("blur", $.proxy(this.__blurHandler, this));
this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
+ if(this.showControls) {
+ this.okbtn = $(document.getElementById(options.okbtn));
+ this.cancelbtn = $(document.getElementById(options.cancelbtn));
+ this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
+ this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler, this));
+ }
+
this.focusElement = $(document.getElementById(options.focusElement));
};
@@ -73,6 +81,16 @@
this.input.focus();
this.input.bind("focus", $.proxy(this.__editHandler, this));
},
+
+ __saveBtnHandler: function(e) {
+ this.save();
+ return false;
+ },
+
+ __cancelBtnHandler: function(e) {
+ this.cancel();
+ return false;
+ },
getValue: function() {
return this.input.val();
15 years, 7 months
JBoss Rich Faces SVN: r19516 - in modules/tests/metamer/trunk/application/src/main/webapp/components: richTogglePanelItem and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-11 05:51:48 -0400 (Mon, 11 Oct 2010)
New Revision: 19516
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richToggleControl/simple.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richTogglePanelItem/simple.xhtml
Log:
* ID removed from all toggle controls
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richToggleControl/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richToggleControl/simple.xhtml 2010-10-11 09:46:58 UTC (rev 19515)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richToggleControl/simple.xhtml 2010-10-11 09:51:48 UTC (rev 19516)
@@ -44,37 +44,36 @@
<h:panelGrid id="panel1Controls" columns="6">
panel1:
<h:commandLink id="tcLink11" value="Toggle Panel Item 1">
- <rich:toggleControl id="tc11" targetPanel="panel1" targetItem="item1" />
+ <rich:toggleControl targetPanel="panel1" targetItem="item1" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink12" value="Toggle Panel Item 2">
- <rich:toggleControl id="tc12" targetPanel="panel1" targetItem="item2" />
+ <rich:toggleControl targetPanel="panel1" targetItem="item2" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink13" value="Toggle Panel Item 3">
- <rich:toggleControl id="tc13" targetPanel="panel1" targetItem="item3" />
+ <rich:toggleControl targetPanel="panel1" targetItem="item3" />
</h:commandLink>
</h:panelGrid>
<h:panelGrid id="panel2Controls" columns="6">
panel2:
<h:commandLink id="tcLink21" value="Toggle Panel Item 1">
- <rich:toggleControl id="tc21" targetPanel="panel2" targetItem="item1" />
+ <rich:toggleControl targetPanel="panel2" targetItem="item1" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink22" value="Toggle Panel Item 2">
- <rich:toggleControl id="tc22" targetPanel="panel2" targetItem="item2" />
+ <rich:toggleControl targetPanel="panel2" targetItem="item2" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink23" value="Toggle Panel Item 3">
- <rich:toggleControl id="tc23" targetPanel="panel2" targetItem="item3" />
+ <rich:toggleControl targetPanel="panel2" targetItem="item3" />
</h:commandLink>
</h:panelGrid>
universal toggle control (settings below)
<h:commandLink id="toggleControlLink" value="Toggle Panel Item">
- <rich:toggleControl id="richToggleControl"
- targetPanel="#{richToggleControlBean.attributes['targetPanel'].value}"
+ <rich:toggleControl targetPanel="#{richToggleControlBean.attributes['targetPanel'].value}"
targetItem="#{richToggleControlBean.attributes['targetItem'].value}"
/>
</h:commandLink>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richTogglePanelItem/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richTogglePanelItem/simple.xhtml 2010-10-11 09:46:58 UTC (rev 19515)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richTogglePanelItem/simple.xhtml 2010-10-11 09:51:48 UTC (rev 19516)
@@ -42,15 +42,15 @@
<ui:define name="component">
<h:commandLink id="tcLink1" value="Toggle Panel Item 1">
- <rich:toggleControl id="toggleControl1" targetPanel="richTogglePanel" targetItem="item1" />
+ <rich:toggleControl targetPanel="richTogglePanel" targetItem="item1" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink2" value="Toggle Panel Item 2">
- <rich:toggleControl id="toggleControl2" targetPanel="richTogglePanel" targetItem="item2" />
+ <rich:toggleControl targetPanel="richTogglePanel" targetItem="item2" />
</h:commandLink>
<h:outputText value=" | " />
<h:commandLink id="tcLink3" value="Toggle Panel Item 3">
- <rich:toggleControl id="toggleControl3" targetPanel="richTogglePanel" targetItem="item3" />
+ <rich:toggleControl targetPanel="richTogglePanel" targetItem="item3" />
</h:commandLink>
<br/><br/>
15 years, 7 months