Author: abelevich
Date: 2008-12-08 14:03:13 -0500 (Mon, 08 Dec 2008)
New Revision: 11656
Modified:
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
https://jira.jboss.org/jira/browse/RF-5275
Modified:
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
---
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-12-08
18:27:05 UTC (rev 11655)
+++
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-12-08
19:03:13 UTC (rev 11656)
@@ -126,36 +126,34 @@
return UIInplaceSelect.class;
}
- public String getSelectedItemLabel(FacesContext context, UIInplaceSelect component)
{
- String selectedItemLabel = (String)component.getSubmittedValue();
- if(selectedItemLabel == null) {
- Object value = component.getAttributes().get("value");
- if (value == null || "".equals(value)) {
- selectedItemLabel = createDefaultLabel(component);
- } else {
- selectedItemLabel = getItemLabel(context, component, value);
- }
- }
- return selectedItemLabel;
- }
+// public String getSelectedItemLabel(FacesContext context, UIInplaceSelect component)
{
+// String selectedItemLabel = (String)component.getSubmittedValue();
+// if(selectedItemLabel == null || !component.isValid()) {
+// Object value = component.getAttributes().get("value");
+// if (value == null || "".equals(value)) {
+// selectedItemLabel = createDefaultLabel(component);
+// } else {
+// selectedItemLabel = getItemLabel(context, component, value);
+// }
+// }
+// return selectedItemLabel;
+// }
protected String getItemLabel(FacesContext context, UIInplaceSelect component, Object
value) {
String itemLabel = null;
// TODO: SelectUtils.getSelectItems is called minimum twice during encode
- List<SelectItem> selectItems = SelectUtils.getSelectItems(context, component);
- if (!selectItems.isEmpty()) {
- for (SelectItem item : selectItems) {
- if (value.equals(item.getValue())) {
- itemLabel = component.isShowValueInView() ? getConvertedStringValue(context,
component, item.getValue()) : item.getLabel();
- break;
+ if(value != null) {
+ List<SelectItem> selectItems = SelectUtils.getSelectItems(context, component);
+ if (!selectItems.isEmpty()) {
+ for (SelectItem item : selectItems) {
+ if (value.equals(item.getValue())) {
+ itemLabel = component.isShowValueInView() ? getConvertedStringValue(context,
component, item.getValue()) : item.getLabel();
+ break;
+ }
+ }
}
- }
}
-
- if (itemLabel == null) {
- itemLabel = createDefaultLabel(component);
- }
-
+
return itemLabel;
}
Modified:
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
===================================================================
---
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2008-12-08
18:27:05 UTC (rev 11655)
+++
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2008-12-08
19:03:13 UTC (rev 11656)
@@ -199,9 +199,9 @@
getParameters : function (args) {
var result = {};
- var label = args[1]['label'];
+ var label = args[1]['itemLabel'];
if(label) {
- var value = args[1]['value'];
+ var value = args[1]['itemValue'];
result.itemLabel = label;
result.itemValue = value;
} else {
Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-12-08 18:27:05 UTC
(rev 11655)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-12-08 19:03:13 UTC
(rev 11656)
@@ -32,19 +32,22 @@
<jsp:scriptlet>
<![CDATA[
- Object value = component.getSubmittedValue();
- if(value == null) {
- value = component.getAttributes().get("value");
- value = getConvertedStringValue(context, component,value);
- }
-
- String fieldValue = (String)value;
- String fieldLabel = getSelectedItemLabel(context, component);
+ Object value = component.getAttributes().get("value");
+ value = getConvertedStringValue(context, component,value);
+
+ String selectedItemLabel = getItemLabel(context, component, value);
- if (value == null || value.equals("")) {
- fieldValue = "";
- }
-
+ String fieldValue = null;
+ String fieldLabel = null;
+
+ if (selectedItemLabel == null) {
+ fieldValue = null;
+ fieldLabel = createDefaultLabel(component);
+ } else {
+ fieldValue = (String)value;
+ fieldLabel = selectedItemLabel;
+ }
+
String encodedFieldValue = encodeValue(fieldValue);
variables.setVariable("fieldLabel", fieldLabel);