Author: konstantin.mishin
Date: 2009-06-26 14:23:44 -0400 (Fri, 26 Jun 2009)
New Revision: 14736
Modified:
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
branches/community/3.3.X/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
branches/community/3.3.X/ui/inplaceInput/src/main/templates/inplaceinput.jspx
branches/community/3.3.X/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js
branches/community/3.3.X/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
branches/community/3.3.X/ui/inplaceSelect/src/test/java/org/richfaces/component/InplaceSelectComponentTest.java
Log:
RF-7443
Modified:
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
---
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2009-06-26
18:23:44 UTC (rev 14736)
@@ -28,8 +28,12 @@
var listOptions = options.listOptions || {};
listOptions.listWidth = listOptions.listWidth || this.getCurrentWidth();
- this.comboList = new Richfaces.ComboBoxList(id, this.filterNewValues,
this.classes.combolist, listOptions);
-
+ this.comboList = new Richfaces.ComboBoxList(id, this.filterNewValues,
this.classes.combolist, listOptions, "comboboxField");
+ if (Richfaces.browser.isIE6) {
+ this.comboList.createIframe(this.comboList.listParent.parentNode,
this.comboList.listWidth, id,
+ "rich-combobox-list-width rich-combobox-list-scroll
rich-combobox-list-position");
+ }
+
if (options.value) {
var item = this.comboList.findItemBySubstr(options.value);
if (item) {
Modified:
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
===================================================================
---
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2009-06-26
18:23:44 UTC (rev 14736)
@@ -9,18 +9,15 @@
showDelay : 0,
hideDelay : 0,
- initialize: function(id, filterNewValues, classes, options) {
+ initialize: function(id, filterNewValues, classes, options, fieldElemIdSuffix) {
Object.extend(this, options);
this.list = document.getElementById(id + "list");
this.listParent = $(id + "listParent");
this.listParentContainer = this.listParent.parentNode;
this.iframe = null;
- this.fieldElem = document.getElementById(id + "comboboxField");
- //this.itemsText = itemsText || [];
+ this.fieldElem = document.getElementById(id + fieldElemIdSuffix);
this.shadowElem = document.getElementById(id + "shadow");
- //this.onlistcall = onlistcall;
- //this.onlistclose = onlistclose;
if (this.onlistcall) {
this.listParent.observe("rich:onlistcall", this.onlistcall);
@@ -40,19 +37,11 @@
this.selectedItem = null;
this.activeItem = null;
- //this.showDelay = showDelay;
- //this.hideDelay = hideDelay;
this.classes = classes;
- //this.listWidth = width;
- //this.listHeight = height;
this.initDimensions();
this.scrollElements = null;
this.eventOnScroll = this.eventOnScroll.bindAsEventListener(this);
- if (Richfaces.browser.isIE6) {
- this.createIframe(this.listParent.parentNode, this.listWidth, id,
- "rich-combobox-list-width rich-combobox-list-scroll
rich-combobox-list-position");
- }
},
initDimensions : function() {
Modified:
branches/community/3.3.X/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
===================================================================
---
branches/community/3.3.X/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2009-06-26
18:23:44 UTC (rev 14736)
@@ -7,7 +7,9 @@
Richfaces.InplaceInput.prototype = {
- //TODO: remove $$$$$
+ commonStyles : new Richfaces.InplaceInputStyles().getCommonStyles(),
+
+ //TODO: remove $$$$$
initialize: function(clientId, options) {
if(!options) {
options = {};
@@ -46,7 +48,7 @@
this.initHandlers();
this.initEvents();
- this.classes = Richfaces.mergeStyles(options.userStyles,new
Richfaces.InplaceInputStyles().getCommonStyles());
+ this.classes = Richfaces.mergeStyles(options.userStyles, this.commonStyles);
this["rich:destructor"] = "destroy";
this.skipSwitching = false;
Modified: branches/community/3.3.X/ui/inplaceInput/src/main/templates/inplaceinput.jspx
===================================================================
---
branches/community/3.3.X/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2009-06-26
18:23:44 UTC (rev 14736)
@@ -16,8 +16,8 @@
new org.ajax4jsf.javascript.PrototypeScript(),
scripts/comboboxUtils.js,
scripts/utils.js,
- scripts/inplaceinput.js,
- scripts/inplaceinputstyles.js
+ scripts/inplaceinputstyles.js,
+ scripts/inplaceinput.js
</h:scripts>
<f:resource var="saveIcon"
name="org.richfaces.renderkit.html.images.SaveControlIcon"/>
<f:resource var="cancelIcon"
name="org.richfaces.renderkit.html.images.CancelControlIcon"/>
Modified:
branches/community/3.3.X/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
---
branches/community/3.3.X/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2009-06-26
18:23:44 UTC (rev 14736)
@@ -164,35 +164,14 @@
}
}
- public String encodeScriptAttributes(FacesContext context, UIComponent component) {
- StringBuilder attributes = new StringBuilder();
- attributes.append("var attributes = ");
+ public String getDefaultLabel(FacesContext context, UIComponent component) {
+ String defaultLabel =
(String)component.getAttributes().get("defaultLabel");
+ if (defaultLabel == null || defaultLabel.trim().equals("")) {
+ defaultLabel = EMPTY_DEFAULT_LABEL;
+ }
+ return defaultLabel;
+ }
- ScriptOptions options = new ScriptOptions(component);
-
- String defaultLabel = (String)component.getAttributes().get("defaultLabel");
-
- if (defaultLabel == null || defaultLabel.trim().equals("")) {
- defaultLabel = EMPTY_DEFAULT_LABEL;
- }
-
- options.addOption("defaultLabel", defaultLabel);
- options.addOption("showControls");
- options.addOption("editEvent");
- options.addOption("verticalPosition",
component.getAttributes().get("controlsVerticalPosition"));
- options.addOption("horizontalPosition",
component.getAttributes().get("controlsHorizontalPosition"));
- options.addOption("inputWidth",component.getAttributes().get("selectWidth")
);
- options.addOption("minInputWidth",
component.getAttributes().get("minSelectWidth"));
- options.addOption("maxInputWidth",
component.getAttributes().get("maxSelectWidth") );
- options.addOption("openOnEdit");
- options.addOption("showValueInView");
- options.addOption("closeOnSelect", true);
-
- attributes.append(options.toScript());
-
- return attributes.toString();
- }
-
public void encodeControlsFacet(FacesContext context, UIComponent component) throws
IOException {
UIComponent facet = component.getFacet(CONTROLS_FACET);
if ((facet != null) && (facet.isRendered())) {
@@ -234,15 +213,6 @@
// return selectedItemLabel;
// }
- public String getAsEventHandler(FacesContext context, UIComponent component, String
attributeName) {
- JSFunctionDefinition script = getUtils().getAsEventHandler(context, component,
attributeName, null);
- return ScriptUtils.toScript(script);
- }
-
- public String encodeJS(Object object) {
- return ScriptUtils.toScript(object);
- }
-
protected String getItemLabel(FacesContext context, UIInplaceSelect component, Object
value) {
String itemLabel = null;
boolean equivValues;
Modified:
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
===================================================================
---
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2009-06-26
18:23:44 UTC (rev 14736)
@@ -1,12 +1,25 @@
if(!window.Richfaces) window.Richfaces = {};
Richfaces.InplaceSelect = Class.create(Richfaces.InplaceInput, {
- initialize : function($super, listObj, clientId, temValueKeepId, valueKeepId, tabberId,
attributes, events, userStyles, commonStyles, barParams, buttonId) {
- this.button = $(buttonId);
- this.comboList = listObj;
- this.showValueInView = attributes.showValueInView;
- $super(clientId, temValueKeepId, valueKeepId, tabberId, attributes, events, userStyles,
commonStyles, barParams);
+ commonStyles : new Richfaces.InplaceSelectStyles().getCommonStyles(),
+
+ initialize : function($super, id, options) {
+ options = options || {};
+ this.button = $(id + "inselArrow");
+ this.showValueInView = options.showValueInView;
+ var attributes = {
+ minInputWidth : "100px",
+ maxInputWidth : "200px",
+ openOnEdit : true
+ };
+ Object.extend(attributes, options.attributes);
+ options.attributes = attributes;
+ this.classes = Richfaces.mergeStyles(options.userStyles, this.commonStyles);
+ var listOptions = options.listOptions || {};
+ listOptions.selectFirstOnUpdate = true;
+ this.comboList = new Richfaces.InplaceSelectList(id, this.classes.combolist,
listOptions, "tempValue", options.fieldValue);
+ $super(id, options);
this.clickOnBar = false;
- this.inplaceSelect = $(clientId);
+ this.inplaceSelect = $(id);
this.inplaceSelect.component = this;
this.currentItemValue = this.value;
@@ -168,7 +181,7 @@
save : function($super,e) {
this.applyTmpValue();
this.comboList.hide();
- if (((this.attributes.closeOnSelect && !this.attributes.showControls)
&& this.comboList.isList)
+ if ((!this.attributes.showControls && this.comboList.isList)
|| (this.clickOnBar || !this.comboList.isList)) {
var unescapedValue = this.currentItemValue;
this.setValue(unescapedValue);
Modified:
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js
===================================================================
---
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselectlist.js 2009-06-26
18:23:44 UTC (rev 14736)
@@ -1,8 +1,10 @@
if(!window.Richfaces) window.Richfaces = {};
Richfaces.InplaceSelectList = Class.create(Richfaces.ComboBoxList, {
- initialize : function($super, listId, parentListId, selectFirstOnUpdate, userStyles,
commonStyles, width, height, itemsText, onlistcall, fieldId, shadowId, showDelay,
hideDelay, value) {
- this.classes = Richfaces.mergeStyles(userStyles, commonStyles);
- $super(listId, parentListId, selectFirstOnUpdate, null, this.classes, width, height,
itemsText, onlistcall, null /* onlistclose */, fieldId, shadowId, showDelay, hideDelay);
+
+ listWidth : "200px",
+
+ initialize : function($super, id, classes, options, fieldElemIdSuffix, value) {
+ $super(id, null, classes, options, fieldElemIdSuffix);
this.wrappingItems(value);
this.isListOpened = false;
},
@@ -12,7 +14,7 @@
field.show();
if (Richfaces.browser.isIE6 && !this.iframe) {
- this.createIframe(this.listParent.parentNode, this.width, this.list.id,
"");
+ this.createIframe(this.listParent.parentNode, this.listWidth, this.list.id,
"");
}
$super(fieldTop, fieldLeft, field.offsetHeight);
Modified: branches/community/3.3.X/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
---
branches/community/3.3.X/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2009-06-26
18:23:44 UTC (rev 14736)
@@ -19,10 +19,11 @@
/org/richfaces/renderkit/html/scripts/jquery/jquery.js,
scripts/comboboxUtils.js ,
scripts/combolist.js ,
+ scripts/inplaceinputstyles.js,
scripts/inplaceinput.js ,
+ scripts/inplaceselectstyles.js,
scripts/inplaceselectlist.js,
scripts/inplaceselect.js,
- scripts/inplaceselectstyles.js,
/org/richfaces/renderkit/html/scripts/utils.js
</h:scripts>
@@ -69,12 +70,9 @@
fieldInputLabel = fieldLabel;
}
- String encodedFieldValue = encodeJS(fieldValue);
-
variables.setVariable("fieldLabel", fieldLabel);
variables.setVariable("fieldValue", fieldValue);
variables.setVariable("fieldInputLabel", fieldInputLabel);
- variables.setVariable("encodedFieldValue", encodedFieldValue);
String saveIcon =
(String)component.getAttributes().get("saveControlIcon");
if (saveIcon != null && saveIcon.length() != 0 ) {
@@ -99,15 +97,15 @@
String changedClass =
(String)component.getAttributes().get("changedClass");
changedClass = (changedClass != null ? changedClass.trim() : "") + "
" + styleClass;
- variables.setVariable("changedClass", changedClass);
+ variables.setVariable("changedClass", changedClass.trim());
String viewClass = (String)component.getAttributes().get("viewClass");
viewClass = (viewClass != null ? viewClass.trim() : "") + " " +
styleClass;
- variables.setVariable("viewClass", viewClass);
+ variables.setVariable("viewClass", viewClass.trim());
String editClass = (String)component.getAttributes().get("editClass");
editClass = (editClass != null ? editClass.trim() : "") + " " +
styleClass;
- variables.setVariable("editClass", editClass);
+ variables.setVariable("editClass", editClass.trim());
String layout = (String)component.getAttributes().get("layout");
@@ -135,7 +133,7 @@
<jsp:scriptlet>
}
</jsp:scriptlet>
- <input id="#{clientId}inplaceTmpValue"
+ <input id="#{clientId}tempValue"
type="text"
style='clip:rect(0px 0px 0px 0px)'
value="#{fieldInputLabel}"
@@ -159,7 +157,7 @@
/>
<input id="#{clientId}inselArrow" readonly="readonly"
type="text" value="" class="rich-inplace-select-arrow"
style='display:none;'/>
- <input autocomplete="off" id='#{clientId}inplaceValue'
name='#{clientId}' type='hidden' value='#{fieldValue}'
+ <input autocomplete="off" id='#{clientId}value'
name='#{clientId}' type='hidden' value='#{fieldValue}'
onchange='#{component.attributes["onchange"]}'>
</input>
<div id="#{clientId}bar" class="rich-inplace-select-control-set"
style="display:none;">
@@ -247,38 +245,49 @@
</div>
+ <c:scriptObject var="attributes">
+ <c:scriptOption name="defaultLabel"
value="#{this:getDefaultLabel(context, component)}"
defaultValue="\u00a0\u00a0\u00a0" />
+ <c:scriptOption attributes="showControls" />
+ <c:scriptOption attributes="editEvent"
defaultValue="onclick"/>
+ <c:scriptOption name="verticalPosition"
value="#{component.attributes['controlsVerticalPosition']}"
defaultValue="center" />
+ <c:scriptOption name="horizontalPosition"
value="#{component.attributes['controlsHorizontalPosition']}"
defaultValue="right" />
+ <c:scriptOption name="inputWidth"
value="#{component.attributes['selectWidth']}" />
+ <c:scriptOption name="minInputWidth"
value="#{component.attributes['minSelectWidth']}"
defaultValue="100px" />
+ <c:scriptOption name="maxInputWidth"
value="#{component.attributes['maxSelectWidth']}"
defaultValue="200px" />
+ <c:scriptOption attributes="openOnEdit"
defaultValue="true"/>
+ </c:scriptObject>
+ <c:scriptObject var="events">
+ <c:scriptOption attributes="oneditactivation, onviewactivation,
oneditactivated, onviewactivated, onchange" wrapper="eventHandler" />
+ </c:scriptObject>
+ <c:scriptObject var="view">
+ <c:scriptOption name="normal" value="#{viewClass}" />
+ <c:scriptOption name="hovered"
value="#{component.attributes['viewHoverClass']}" />
+ </c:scriptObject>
+ <c:scriptObject var="changed">
+ <c:scriptOption name="normal" value="#{changedClass}" />
+ <c:scriptOption name="hovered"
value="#{component.attributes['changedHoverClass']}" />
+ </c:scriptObject>
+ <c:scriptObject var="componentStyles">
+ <c:scriptOption variables="view, changed" />
+ <c:scriptOption name="editable" value="#{editClass}" />
+ </c:scriptObject>
+ <c:scriptObject var="userStyles">
+ <c:scriptOption name="component" value="#{componentStyles}"
/>
+ </c:scriptObject>
+ <c:scriptObject var="listOptions">
+ <c:scriptOption attributes="listWidth, listHeight"
defaultValue="200px"/>
+ <c:scriptOption name="itemsText" value="#{preparedItems}"
/>
+ </c:scriptObject>
+ <c:scriptObject var="options">
+ <c:scriptOption attributes="showValueInView" />
+ <c:scriptOption variables="attributes, events, userStyles, fieldValue,
listOptions" />
+ </c:scriptObject>
<script type="text/javascript">
- #{this:encodeScriptAttributes(context, component)};
-
- var inplaceSelectUserStyles = {
-
- combolist: {
- list: { classes: {active:'#{listClass}'}},
- item: { normal:'#{itemClass}', selected:'#{itemSelectedClass}'}
- },
-
- component: {
- changed :{normal:'#{changedClass}'
,hovered:'#{component.attributes["changedHoverClass"]}'},
- view :
{normal:'#{viewClass}',hovered:'#{component.attributes["viewHoverClass"]}'},
- editable:'#{editClass}'
- }
- };
-
- var inplaceSelectCommonStyles = new Richfaces.InplaceSelectStyles();
-
- new Richfaces.InplaceSelect(new
Richfaces.InplaceSelectList('#{clientId}list', '#{clientId}listParent',
true,
- inplaceSelectUserStyles.combolist,
inplaceSelectCommonStyles.getCommonStyles().combolist,
'#{component.attributes["listWidth"]}',
'#{component.attributes["listHeight"]}',
#{this:encodeJS(preparedItems)}, null,
- '#{clientId}inplaceTmpValue', '#{clientId}shadow', 0, 0,
#{encodedFieldValue}),
- '#{clientId}', '#{clientId}inplaceTmpValue',
- '#{clientId}inplaceValue', '#{clientId}tabber',
- attributes,
- {oneditactivation : #{this:getAsEventHandler(context, component,
"oneditactivation")},
- onviewactivation : #{this:getAsEventHandler(context, component,
"onviewactivation")},
- oneditactivated : #{this:getAsEventHandler(context, component,
"oneditactivated")},
- onviewactivated : #{this:getAsEventHandler(context, component,
"onviewactivated")},
- onchange : #{this:getAsEventHandler(context, component,
"onchange")}},
- inplaceSelectUserStyles, inplaceSelectCommonStyles,
- ['#{clientId}bar', '#{clientId}ok',
'#{clientId}cancel', '#{clientId}buttons',
'#{clientId}btns_shadow'], '#{clientId}inselArrow');
+ new Richfaces.InplaceSelect('#{clientId}'
+ <c:if test="#{not empty options}">
+ , <f:writeAsScript value="#{options}" />
+ </c:if>
+ );
</script>
</div>
Modified:
branches/community/3.3.X/ui/inplaceSelect/src/test/java/org/richfaces/component/InplaceSelectComponentTest.java
===================================================================
---
branches/community/3.3.X/ui/inplaceSelect/src/test/java/org/richfaces/component/InplaceSelectComponentTest.java 2009-06-26
17:10:37 UTC (rev 14735)
+++
branches/community/3.3.X/ui/inplaceSelect/src/test/java/org/richfaces/component/InplaceSelectComponentTest.java 2009-06-26
18:23:44 UTC (rev 14736)
@@ -58,6 +58,7 @@
javaScripts.add("scripts/comboboxUtils.js");
javaScripts.add("scripts/combolist.js");
javaScripts.add("scripts/inplaceinput.js");
+ javaScripts.add("scripts/inplaceinputstyles.js");
javaScripts.add("scripts/inplaceselectlist.js");
javaScripts.add("scripts/inplaceselectstyles.js");
javaScripts.add("scripts/inplaceselect.js");
@@ -135,9 +136,7 @@
String srcAttr = item.getSrcAttribute();
if (item.getFirstDomChild() != null) {
String scriptBodyString = item.getFirstDomChild().toString();
- assertTrue(scriptBodyString.contains("Richfaces.InplaceSelectList"));
assertTrue(scriptBodyString.contains("Richfaces.InplaceSelect"));
- assertTrue(scriptBodyString.contains("inplaceSelectUserStyles"));
}
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;