JBoss Rich Faces SVN: r7760 - in trunk/ui/inplaceInput/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 07:46:07 -0400 (Fri, 11 Apr 2008)
New Revision: 7760
Modified:
trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx
Log:
apply review TODO
Modified: trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
===================================================================
--- trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-04-11 10:52:33 UTC (rev 7759)
+++ trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-04-11 11:46:07 UTC (rev 7760)
@@ -20,7 +20,7 @@
public static final String COMPONENT_TYPE = "org.richfaces.InplaceInput";
final static public String COMPONENT_FAMILY = "org.richfaces.InplaceInput";
- public static final String VALUE_SUFFIX = "value";
+// public static final String VALUE_SUFFIX = "value";
public abstract String getDefaultLabel();
public abstract void setDefaultLabel(String label);
}
\ No newline at end of file
Modified: trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-04-11 10:52:33 UTC (rev 7759)
+++ trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-04-11 11:46:07 UTC (rev 7760)
@@ -125,7 +125,6 @@
//TODO:
//Should use clientId instead?
- clientId = clientId + UIInplaceInput.VALUE_SUFFIX;
Map <String, String> request = context.getExternalContext().getRequestParameterMap();
String newValue = (String)request.get(clientId);
Modified: trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx
===================================================================
--- trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2008-04-11 10:52:33 UTC (rev 7759)
+++ trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2008-04-11 11:46:07 UTC (rev 7760)
@@ -108,7 +108,7 @@
onmouseup='#{component.attributes["oninputmouseup"]}'
/>
- <input id='#{clientId}value' name='#{clientId}value' type='hidden' value='#{fieldValue}'/>
+ <input id='#{clientId}value' name='#{clientId}' type='hidden' value='#{fieldValue}'/>
<div id="#{clientId}bar" class="rich-inplace-input-controls-set" style="display:none;">
<jsp:scriptlet>
<![CDATA[
16 years, 9 months
JBoss Rich Faces SVN: r7759 - in trunk/ui/fileUpload/src/main: resources/org/richfaces/renderkit/html/js and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-04-11 06:52:33 -0400 (Fri, 11 Apr 2008)
New Revision: 7759
Modified:
trunk/ui/fileUpload/src/main/config/component/fileUpload.xml
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
RF-3023
Modified: trunk/ui/fileUpload/src/main/config/component/fileUpload.xml
===================================================================
--- trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-04-11 10:19:07 UTC (rev 7758)
+++ trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-04-11 10:52:33 UTC (rev 7759)
@@ -213,6 +213,14 @@
<defaultvalue>false</defaultvalue>
</property>
<property>
+ <name>noDuplicate</name>
+ <classname>boolean</classname>
+ <description>
+ Defines if component should allow to add files that was already in list
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
<name>acceptedTypes</name>
<classname>java.lang.String</classname>
<description>
Modified: trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
--- trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-04-11 10:19:07 UTC (rev 7758)
+++ trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-04-11 10:52:33 UTC (rev 7759)
@@ -552,10 +552,21 @@
}
return false;
},
+
+ checkDuplicated: function (elt) {
+ if (!this.options.noDuplicate) return true;
+ var fileName = elt.value;
+ for (var i = 0; i < this.entries.length; i++) {
+ if (fileName == this.entries[i].fileInput.value) {
+ return false;
+ }
+ }
+ return true;
+ },
add: function(elt) {
if (this.disabled) return;
- if (!this.checkFileType(elt.value)) {
+ if (!this.checkFileType(elt.value) || !this.checkDuplicated(elt)) {
if(this.events.ontyperejected) {
this.element.fire("rich:ontyperejected", {});
}
Modified: trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-04-11 10:19:07 UTC (rev 7758)
+++ trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-04-11 10:52:33 UTC (rev 7759)
@@ -183,7 +183,7 @@
onclear : #{this:getAsEventHandler(context, component, "onclear")}
};
- new FileUpload('#{clientId}','#{formId}','#{actionUrl}',#{this:getStopScript(context, component)}, #{this:getFileSizeScript(context, component)} ,'#{this:getProgressBarId(context, component)}', FileUpload.CLASSES, #{this:getLabelMarkup(context, component)}, #{maxCount}, events, #{component.attributes["disabled"]}, #{this:getAcceptedTypes(context, component)}, {'autoclear':#{component.attributes["autoclear"]},'autoUpload':#{component.attributes["immediateUpload"]}},#{this:_getLabels(labels)},#{this:getChildrenParams(context, component)});
+ new FileUpload('#{clientId}','#{formId}','#{actionUrl}',#{this:getStopScript(context, component)}, #{this:getFileSizeScript(context, component)} ,'#{this:getProgressBarId(context, component)}', FileUpload.CLASSES, #{this:getLabelMarkup(context, component)}, #{maxCount}, events, #{component.attributes["disabled"]}, #{this:getAcceptedTypes(context, component)}, {'autoclear':#{component.attributes["autoclear"]},'autoUpload':#{component.attributes["immediateUpload"]},'noDuplicate':#{component.attributes["noDuplicate"]}},#{this:_getLabels(labels)},#{this:getChildrenParams(context, component)});
</script>
</span>
<f:call name="utils.encodeEndFormIfNessesary" />
16 years, 9 months
JBoss Rich Faces SVN: r7758 - trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 06:19:07 -0400 (Fri, 11 Apr 2008)
New Revision: 7758
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
Log:
getAsEventHandle now is static
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2008-04-11 10:12:05 UTC (rev 7757)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2008-04-11 10:19:07 UTC (rev 7758)
@@ -916,7 +916,7 @@
}
}
- public JSFunctionDefinition getAsEventHandler(FacesContext context, UIComponent component, String attributeName, String append) {
+ public static JSFunctionDefinition getAsEventHandler(FacesContext context, UIComponent component, String attributeName, String append) {
String event = (String) component.getAttributes().get(attributeName);
if (event != null) {
16 years, 9 months
JBoss Rich Faces SVN: r7757 - trunk/ui/combobox/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-04-11 06:12:05 -0400 (Fri, 11 Apr 2008)
New Revision: 7757
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
Log:
Fixed compilation problem.
Modified: trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-11 10:10:49 UTC (rev 7756)
+++ trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-11 10:12:05 UTC (rev 7757)
@@ -137,7 +137,7 @@
}
public String getAsEventHandler(FacesContext context, UIComponent component, String attributeName) {
- JSFunctionDefinition script = RendererUtils.getAsEventHandler(context, component, attributeName, null);
+ JSFunctionDefinition script = getUtils().getAsEventHandler(context, component, attributeName, null);
return ScriptUtils.toScript(script);
}
}
16 years, 9 months
JBoss Rich Faces SVN: r7756 - trunk/samples/fileUploadDemo/src/main/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-04-11 06:10:49 -0400 (Fri, 11 Apr 2008)
New Revision: 7756
Modified:
trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
Log:
RF-3032
Modified: trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-04-11 10:10:45 UTC (rev 7755)
+++ trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-04-11 10:10:49 UTC (rev 7756)
@@ -65,7 +65,7 @@
this.flag = flag;
}
- public void listener(UploadEvent event) throws IOException{
+ public void listener(UploadEvent event) throws Exception{
UploadItem item = event.getUploadItem();
System.out.println("File : '" + item.getFileName() + "' was uploaded");
if (item.isFile()) {
16 years, 9 months
JBoss Rich Faces SVN: r7755 - trunk/framework/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-04-11 06:10:45 -0400 (Fri, 11 Apr 2008)
New Revision: 7755
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java
Log:
RF-3032
Modified: trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java 2008-04-11 09:46:06 UTC (rev 7754)
+++ trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java 2008-04-11 10:10:45 UTC (rev 7755)
@@ -8,6 +8,8 @@
import java.io.File;
+import javax.faces.FacesException;
+
/**
* Class provides object holder for file uploaded.
* Instance of this type will be returned by UploadEvent after appropriate listener called after uploading has been completed.
@@ -52,14 +54,21 @@
/**
* @return the file
*/
- public File getFile() {
+ public File getFile() throws Exception {
+ if (!isFile()) {
+ throw new FacesException("This method should be called only if Ajax4Jsf filter's parameter 'createTempFiles' set up in TRUE value");
+ }
return file;
}
/**
* @return the bytes
+ * @throws Exception
*/
- public byte[] getData() {
+ public byte[] getData() throws Exception {
+ if (isFile()) {
+ throw new FacesException("This method should be called only if Ajax4Jsf filter's parameter 'createTempFiles' set up in FALSE value");
+ }
return bytes;
}
16 years, 9 months
JBoss Rich Faces SVN: r7754 - in trunk/ui/combobox/src/main: resources/org/richfaces/renderkit/html/css and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 05:46:06 -0400 (Fri, 11 Apr 2008)
New Revision: 7754
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss
trunk/ui/combobox/src/main/templates/combobox.jspx
Log:
applying review
Modified: trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-11 09:45:39 UTC (rev 7753)
+++ trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-11 09:46:06 UTC (rev 7754)
@@ -3,7 +3,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -14,10 +13,9 @@
import javax.faces.model.SelectItem;
import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptString;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.util.InputUtils;
import org.ajax4jsf.util.SelectUtils;
@@ -47,10 +45,15 @@
comboBox = (UIComboBox) component;
} else {
if (logger.isDebugEnabled()) {
- logger.debug("No decoding necessary since the component " + component.getId() + " is not an instance or a sub class of UIComboBox");
+ logger.debug("No decoding necessary since the component " + component.getId() + " is not an instance or a sub class of UIComboBox");
}
return;
}
+
+ String clientId = comboBox.getClientId(context);
+ if (clientId == null) {
+ throw new NullPointerException("component client id is NULL");
+ }
if (InputUtils.isDisabled(comboBox) || InputUtils.isReadOnly(comboBox)) {
if (logger.isDebugEnabled()) {
@@ -58,60 +61,55 @@
}
}
- String clientId = component.getClientId(context);
- if (clientId == null) {
- throw new NullPointerException("component " + comboBox.getClientId(context) + " client id is NULL");
- }
-
- clientId = clientId + "comboboxValue";
- Map request = context.getExternalContext().getRequestParameterMap();
- if (request.containsKey(clientId)) {
- String newValue = (String) request.get(clientId);
+ Map <String, String> request = context.getExternalContext().getRequestParameterMap();
+ String newValue = (String) request.get(clientId);
+ if (newValue != null) {
comboBox.setSubmittedValue(newValue);
}
}
- public List encodeItems(FacesContext context, UIComponent component) throws IOException {
- if (!isAcceptableComponent(component)) {
- return null;
- }
-
- UIComboBox comboBox = (UIComboBox) component;
- Object suggestionValues = comboBox.getSuggestionValues();
- ResponseWriter writer = context.getResponseWriter();
+ public List<Object> encodeItems(FacesContext context, UIComponent component) throws IOException, IllegalArgumentException {
+ if (!isAcceptableComponent(component)) {
+ return null;
+ }
- List values = new ArrayList();
-
- if (suggestionValues != null) {
- if (suggestionValues instanceof Collection) {
- for (Iterator iterator = ((Collection) suggestionValues).iterator(); iterator.hasNext();) {
- String value = getConvertedStringValue(context, comboBox, iterator.next());
- values.add(value);
- encodeSuggestion(writer, comboBox, value, RICH_COMBOBOX_ITEM_CLASSES);
- }
- } else if (suggestionValues.getClass().isArray()) {
- Object[] suggestions = (Object[]) suggestionValues;
- for (int i = 0; i < suggestions.length; i++) {
- String value = getConvertedStringValue(context, comboBox, suggestions[i]);
- values.add(value);
- encodeSuggestion(writer, comboBox, value, RICH_COMBOBOX_ITEM_CLASSES);
- }
- } else {
- throw new IllegalArgumentException("suggestionValues should be Collection or array");
- }
-
+ UIComboBox comboBox = (UIComboBox) component;
+ Object suggestionValues = comboBox.getSuggestionValues();
+ ResponseWriter writer = context.getResponseWriter();
+ List <Object>values = encodeSuggestionValues(context, component, writer, suggestionValues);
+ List<SelectItem> selectItems = SelectUtils.getSelectItems(context, component);
+ for (SelectItem selectItem : selectItems) {
+ String value = getConvertedStringValue(context, comboBox, selectItem.getValue());
+ values.add(value);
+ encodeSuggestion(writer, comboBox, value, RICH_COMBOBOX_ITEM_CLASSES);
+
+ }
+ return values;
+ }
+
+ public List<Object> encodeSuggestionValues(FacesContext context, UIComponent component, ResponseWriter writer,
+ Object suggestionValues) throws IOException, IllegalArgumentException {
+ ArrayList<Object> values = new ArrayList<Object>();
+ if (suggestionValues != null) {
+ if (suggestionValues instanceof Collection) {
+ Collection<Object> collection = (Collection) suggestionValues;
+ for (Object suggestionValue : collection) {
+ String value = getConvertedStringValue(context, component, suggestionValue);
+ values.add(value);
+ encodeSuggestion(writer, component, value, RICH_COMBOBOX_ITEM_CLASSES);
}
-
- List<SelectItem> selectItems = SelectUtils.getSelectItems(context, component);
- if (!selectItems.isEmpty()) {
- for (Iterator<SelectItem> iterator = selectItems.iterator(); iterator.hasNext();) {
- SelectItem selectItem = iterator.next();
- String value = getConvertedStringValue(context, comboBox, selectItem.getValue());
- values.add(value);
- encodeSuggestion(writer, comboBox, value, RICH_COMBOBOX_ITEM_CLASSES);
- }
+ } else if (suggestionValues.getClass().isArray()) {
+ Object[] suggestions = (Object[]) suggestionValues;
+ for (int i = 0; i < suggestions.length; i++) {
+ String value = getConvertedStringValue(context, component, suggestions[i]);
+ values.add(value);
+ encodeSuggestion(writer, component, value, RICH_COMBOBOX_ITEM_CLASSES);
}
- return values;
+ } else {
+ throw new IllegalArgumentException("suggestionValues should be Collection or array");
+ }
+ }
+ return values;
}
@Override
@@ -124,10 +122,10 @@
}
public void encodeSuggestion(ResponseWriter writer, UIComponent component, String value, String classes) throws IOException {
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.writeAttribute(HTML.class_ATTRIBUTE, classes, null);
- writer.writeText(value, null);
- writer.endElement(HTML.SPAN_ELEM);
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, classes, null);
+ writer.writeText(value, null);
+ writer.endElement(HTML.SPAN_ELEM);
}
protected boolean isAcceptableComponent(UIComponent component) {
@@ -139,19 +137,7 @@
}
public String getAsEventHandler(FacesContext context, UIComponent component, String attributeName) {
- String event = (String) component.getAttributes().get(attributeName);
- ScriptString result = JSReference.NULL;
-
- if (event != null) {
- event = event.trim();
- if (event.length() != 0) {
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("event");
- function.addToBody(event);
- result = function;
- }
- }
-
- return ScriptUtils.toScript(result);
+ JSFunctionDefinition script = RendererUtils.getAsEventHandler(context, component, attributeName, null);
+ return ScriptUtils.toScript(script);
}
}
Modified: trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss
===================================================================
--- trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss 2008-04-11 09:45:39 UTC (rev 7753)
+++ trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss 2008-04-11 09:46:06 UTC (rev 7754)
@@ -221,52 +221,19 @@
</f:verbatim>
- <u:selector name=".rich-combobox-shadow-tl">
+ <u:selector name=".rich-combobox-shadow-tl, .rich-combobox-shadow-tr, .rich-combobox-shadow-bl, .rich-combobox-shadow-br">
<u:style name="background-image">
<f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
</u:style>
</u:selector>
- <u:selector name=".rich-combobox-shadow-tr">
+ <u:selector name="input.rich-combobox-button-background, input.rich-combobox-button-background-disabled, input.rich-combobox-button-background-inactive">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
- <u:selector name=".rich-combobox-shadow-bl">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
- <u:selector name=".rich-combobox-shadow-br">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
-
- <u:selector name="input.rich-combobox-button-background">
- <u:style name="background-image">
<f:resource f:key="org.richfaces.renderkit.html.images.SpinnerButtonGradient" />
</u:style>
<u:style name="background-color" skin="tabBackgroundColor"/>
</u:selector>
- <u:selector name="input.rich-combobox-button-background-disabled">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.SpinnerButtonGradient" />
- </u:style>
- <u:style name="background-color" skin="tabBackgroundColor"/>
- </u:selector>
-
- <u:selector name="input.rich-combobox-button-background-inactive">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.SpinnerButtonGradient" />
- </u:style>
- <u:style name="background-color" skin="tabBackgroundColor"/>
- </u:selector>
-
<u:selector name="input.rich-combobox-button-pressed-background">
<u:style name="background-image">
<f:resource f:key="org.richfaces.renderkit.html.images.ComboBoxButtonPressGradient" />
@@ -274,7 +241,7 @@
<u:style name="background-color" skin="tabBackgroundColor"/>
</u:selector>
- <u:selector name="input.rich-combobox-button-icon">
+ <u:selector name="input.rich-combobox-button-icon, input.rich-combobox-button-icon-inactive">
<u:style name="background-image">
<f:resource f:key="org.richfaces.renderkit.html.images.ComboBoxArrowImage" />
</u:style>
@@ -286,85 +253,35 @@
</u:style>
</u:selector>
- <u:selector name="input.rich-combobox-button-icon-inactive">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.ComboBoxArrowImage" />
- </u:style>
- </u:selector>
-
- <u:selector name="input.rich-combobox-button">
+ <u:selector name="input.rich-combobox-button, input.rich-combobox-button-inactive, input.rich-combobox-button-disabled">
<u:style name="border-top-color" skin="panelBorderColor"/>
<u:style name="border-left-color" skin="panelBorderColor"/>
</u:selector>
- <u:selector name="input.rich-combobox-button-inactive">
- <u:style name="border-top-color" skin="panelBorderColor"/>
- <u:style name="border-left-color" skin="panelBorderColor"/>
- </u:selector>
-
- <u:selector name="input.rich-combobox-button-disabled">
- <u:style name="border-top-color" skin="panelBorderColor"/>
- <u:style name="border-left-color" skin="panelBorderColor"/>
- </u:selector>
-
- <u:selector name="input.rich-combobox-font">
+ <u:selector name=".rich-combobox-font, input.rich-combobox-font">
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
<u:style name="color" skin="generalTextColor"/>
</u:selector>
- <u:selector name=".rich-combobox-font">
- <u:style name="font-size" skin="generalSizeFont"/>
- <u:style name="font-family" skin="generalFamilyFont"/>
- <u:style name="color" skin="generalTextColor"/>
- </u:selector>
-
- <u:selector name="input.rich-combobox-font-disabled">
+ <u:selector name="input.rich-combobox-font-disabled, .rich-combobox-font-disabled">
<u:style name="font-family" skin="headerFamilyFont"/>
<u:style name="font-size" skin="headerSizeFont"/>
</u:selector>
- <u:selector name=".rich-combobox-font-disabled">
- <u:style name="font-family" skin="headerFamilyFont"/>
- <u:style name="font-size" skin="headerSizeFont"/>
- </u:selector>
-
- <u:selector name="input.rich-combobox-font-inactive">
+ <u:selector name="input.rich-combobox-font-inactive, .rich-combobox-font-inactive, .rich-combobox-item">
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
<u:style name="color" skin="generalTextColor"/>
</u:selector>
- <u:selector name=".rich-combobox-font-inactive">
- <u:style name="font-size" skin="generalSizeFont"/>
- <u:style name="font-family" skin="generalFamilyFont"/>
- <u:style name="color" skin="generalTextColor"/>
- </u:selector>
-
-
- <u:selector name=".rich-combobox-input">
+
+ <u:selector name=".rich-combobox-input, .rich-combobox-input-disabled, .rich-combobox-input-inactive">
<u:style name="background-color" skin="controlBackgroundColor"/>
<u:style name="border-bottom-color" skin="panelBorderColor"/>
<u:style name="border-right-color" skin="panelBorderColor"/>
</u:selector>
-
- <u:selector name=".rich-combobox-input-disabled">
- <u:style name="background-color" skin="controlBackgroundColor"/>
- <u:style name="border-bottom-color" skin="panelBorderColor"/>
- <u:style name="border-right-color" skin="panelBorderColor"/>
- </u:selector>
-
- <u:selector name=".rich-combobox-input-inactive">
- <u:style name="background-color" skin="controlBackgroundColor"/>
- <u:style name="border-bottom-color" skin="panelBorderColor"/>
- <u:style name="border-right-color" skin="panelBorderColor"/>
- </u:selector>
- <u:selector name=".rich-combobox-item">
- <u:style name="font-size" skin="generalSizeFont"/>
- <u:style name="font-family" skin="generalFamilyFont"/>
- <u:style name="color" skin="generalTextColor"/>
- </u:selector>
<u:selector name=".rich-combobox-item-selected">
<u:style name="background-color" skin="headerBackgroundColor" />
Modified: trunk/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-11 09:45:39 UTC (rev 7753)
+++ trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-11 09:46:06 UTC (rev 7754)
@@ -87,7 +87,7 @@
String valueStyle = "rich-combobox-font-inactive";
value = getConvertedStringValue(context, component,value);
- if (value == null || value.equals("")) {
+ if ("".equals(value)) {
valueStyle = "rich-combobox-font-disabled";
value = defaultLabel;
}
@@ -98,7 +98,7 @@
variables.setVariable("inputStyle", inputStyle);
Object inputClass = component.getAttributes().get("inputClass");
- if(inputClass!=null && inputClass.equals("")) {
+ if("".equals(inputClass)) {
inputClass = null;
}
variables.setVariable("inputClass", inputClass);
@@ -107,7 +107,7 @@
variables.setVariable("inputDisabledStyle", inputDisabledStyle);
Object inputDisabledClass = component.getAttributes().get("inputDisabledClass");
- if(inputDisabledClass!=null && inputDisabledClass.equals("")) {
+ if("".equals(inputDisabledClass)) {
inputDisabledClass = null;
}
variables.setVariable("inputDisabledClass", inputDisabledClass);
@@ -116,14 +116,14 @@
variables.setVariable("inputInactiveStyle", inputInactiveStyle);
Object inputInactiveClass = component.getAttributes().get("inputInactiveClass");
- if(inputInactiveClass!=null && inputInactiveClass.equals("")) {
+ if("".equals(inputInactiveClass)) {
inputInactiveClass = null;
}
variables.setVariable("inputInactiveClass", inputInactiveClass);
Object buttonInactiveClass = component.getAttributes().get("buttonInactiveClass");
- if(buttonInactiveClass!=null && buttonInactiveClass.equals("")) {
+ if("".equals(buttonInactiveClass)) {
buttonInactiveClass = null;
}
variables.setVariable("buttonInactiveClass", buttonInactiveClass);
@@ -132,7 +132,7 @@
variables.setVariable("buttonInactiveStyle", buttonInactiveStyle);
Object buttonDisabledClass = component.getAttributes().get("buttonDisabledClass");
- if(buttonDisabledClass!=null && buttonDisabledClass.equals("")) {
+ if("".equals(buttonDisabledClass)) {
buttonDisabledClass = null;
}
variables.setVariable("buttonDisabledClass", buttonDisabledClass);
@@ -141,7 +141,7 @@
variables.setVariable("buttonDisabledStyle", buttonDisabledStyle);
Object buttonClass = component.getAttributes().get("buttonClass");
- if(buttonClass!=null && buttonClass.equals("")) {
+ if("".equals(buttonClass)) {
buttonClass = null;
}
variables.setVariable("buttonClass", buttonClass);
@@ -153,7 +153,7 @@
variables.setVariable("listStyle", listStyle);
Object listClass = component.getAttributes().get("listClass");
- if(listClass!=null && listClass.equals("")) {
+ if("".equals(listClass)) {
listClass = null;
}
variables.setVariable("listClass", listClass);
@@ -165,31 +165,31 @@
variables.setVariable("style", style);
Object itemClass = component.getAttributes().get("itemClass");
- if(itemClass!=null && itemClass.equals("")) {
+ if("".equals(itemClass)) {
itemClass = null;
}
variables.setVariable("itemClass", itemClass);
Object itemSelectedClass = component.getAttributes().get("itemSelectedClass");
- if(itemSelectedClass!=null && itemSelectedClass.equals("")) {
+ if("".equals(itemSelectedClass)) {
itemSelectedClass = null;
}
variables.setVariable("itemSelectedClass", itemSelectedClass);
String buttonIcon = (String)component.getAttributes().get("buttonIcon");
- if (buttonIcon != null && !buttonIcon.equals("")) {
+ if (!"".equals(buttonIcon)) {
buttonIcon = "url('" + buttonIcon + "')";
}
variables.setVariable("buttonIcon", buttonIcon);
String buttonIconDisabled = (String)component.getAttributes().get("buttonIconDisabled");
- if (buttonIconDisabled != null && !buttonIconDisabled.equals("")) {
+ if (!"".equals(buttonIconDisabled)) {
buttonIconDisabled = "url('" + buttonIconDisabled + "')";
}
variables.setVariable("buttonIconDisabled", buttonIconDisabled);
String buttonIconInactive = (String)component.getAttributes().get("buttonIconInactive");
- if (buttonIconInactive != null && !buttonIconInactive.equals("")) {
+ if (!"".equals(buttonIconInactive)) {
buttonIconInactive = "url('" + buttonIconInactive + "')";
}
variables.setVariable("buttonIconInactive", buttonIconInactive);
@@ -202,7 +202,7 @@
<div id="#{clientId}">
<div id="#{clientId}combobox" class="rich-combobox-font rich-combobox #{styleClass}" style="width:#{listWidth};#{style}"
x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled,onchange">
- <input id="#{clientId}comboboxValue" name="#{clientId}comboboxValue" type="hidden"/>
+ <input id="#{clientId}comboboxValue" name="#{clientId}" type="hidden"/>
<div class="rich-combobox-list-cord"></div>
<div class="rich-combobox-font rich-combobox-shell" style="width:#{width};z-index:1;">
<input id="#{clientId}comboboxField"
16 years, 9 months
JBoss Rich Faces SVN: r7753 - trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 05:45:39 -0400 (Fri, 11 Apr 2008)
New Revision: 7753
Modified:
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
Log:
fix invokeEvent method behavior.
Modified: trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
===================================================================
--- trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-04-11 09:45:08 UTC (rev 7752)
+++ trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-04-11 09:45:39 UTC (rev 7753)
@@ -349,7 +349,7 @@
//TODO: remove Bucks
//TODO: to shared library
invokeEvent : function(eventFunc, element, eventName, memo) {
- var result = false;
+ var result;
if (eventFunc) {
element = $(element);
if (element == document && document.createEvent && !element.dispatchEvent)
@@ -365,10 +365,14 @@
}
event.eventName = eventName;
+ event.rich = {component:this};
event.memo = memo || { };
-
- var result = eventFunc.call(event);
+ try {
+ result = eventFunc.call(element,event);
+ }
+ catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName + "]"); }
}
+ if (result!=false) result = true;
return result;
},
16 years, 9 months
JBoss Rich Faces SVN: r7752 - in trunk/ui/inplaceInput/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 05:45:08 -0400 (Fri, 11 Apr 2008)
New Revision: 7752
Modified:
trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
Log:
applying review
Modified: trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
===================================================================
--- trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-04-11 09:44:49 UTC (rev 7751)
+++ trunk/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-04-11 09:45:08 UTC (rev 7752)
@@ -18,12 +18,9 @@
* <p>The standard component type for this component.</p>
*/
public static final String COMPONENT_TYPE = "org.richfaces.InplaceInput";
+ final static public String COMPONENT_FAMILY = "org.richfaces.InplaceInput";
public static final String VALUE_SUFFIX = "value";
-
- public abstract String getDefaultLabel();
- public abstract void setDefaultLabel(String label);
-
-
-
+ public abstract String getDefaultLabel();
+ public abstract void setDefaultLabel(String label);
}
\ No newline at end of file
Modified: trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-04-11 09:44:49 UTC (rev 7751)
+++ trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-04-11 09:45:08 UTC (rev 7752)
@@ -8,7 +8,9 @@
import javax.faces.convert.ConverterException;
import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.util.InputUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -25,13 +27,7 @@
private static Log logger = LogFactory.getLog(InplaceInputBaseRenderer.class);
private static final String CONTROLS_FACET = "controls";
-
- private static final int NORMAL_KEY = 0;
-
- private static final int HOVERED_KEY = 1;
-
- private static final int EDITABLE_KEY = 2;
-
+
private static final String INPLACE_COMPONENT = "COMPONENT";
private static final String INPLACE_CHANGED = "CHANGED";
@@ -55,10 +51,49 @@
private static final String INPLACE_CSS_HOVER = "hover";
private static final String EMPTY_DEFAULT_LABEL = "   ";
+
+ private static enum States {
+ NORMAL {String createCss(UIComponent component, String suffix){
+ StringBuilder builder = new StringBuilder();
+ builder.append(INPLACE_CSS_PUBLIC);
+ builder.append(" ");
+ builder.append(INPLACE_CSS_PUBLIC + "-" + suffix);
+ Object value = component.getAttributes().get(suffix + "Class");
+ if (value != null) {
+ builder.append(" ");
+ builder.append(value);
+ }
+ return builder.toString();
+ };},
+ HOVERED {String createCss(UIComponent component , String suffix){
+ StringBuilder builder = new StringBuilder();
+ builder.append(INPLACE_CSS_PUBLIC + "-" + "input-" + suffix + "-" + INPLACE_CSS_HOVER);
+ Object value = component.getAttributes().get(suffix + "HoverClass");
+ if (value != null) {
+ builder.append(" ");
+ builder.append(value);
+ }
+ return builder.toString();
+ }},
+ EDIT {String createCss(UIComponent component, String suffix){
+ StringBuilder builder = new StringBuilder();
+ builder.append(INPLACE_CSS_PUBLIC);
+ builder.append(" ");
+ builder.append(INPLACE_CSS_PUBLIC + "-" + suffix);
+ Object value = component.getAttributes().get(suffix + "Class");
+ if (value != null) {
+ builder.append(" ");
+ builder.append(value);
+ }
+ return builder.toString();
+ }};
+ abstract String createCss(UIComponent component, String suffix);
+ };
+
protected Class<UIInplaceInput> getComponentClass() {
- return UIInplaceInput.class;
+ return UIInplaceInput.class;
}
protected void doDecode(FacesContext context, UIComponent component) {
@@ -68,7 +103,6 @@
inplaceInput = (UIInplaceInput) component;
} else {
if (logger.isDebugEnabled()) {
-
logger.debug("No decoding necessary since the component "
+ component.getId() +
" is not an instance or a sub class of UIInplaceInput");
@@ -76,34 +110,28 @@
return;
}
- //TODO:
- //First check NULL clientId
-
+ String clientId = component.getClientId(context);
+ if (clientId == null) {
+ throw new NullPointerException("component client id is NULL" );
+ }
+
if (InputUtils.isDisabled(inplaceInput) || InputUtils.isReadOnly(inplaceInput)) {
if (logger.isDebugEnabled()) {
logger.debug(("No decoding necessary since the component "
+ component.getId() + " is disabled"));
}
- //TODO: return?
+ return;
}
- String clientId = component.getClientId(context);
- //TODO: NULL is NULL?
- if (clientId == null) {
- throw new NullPointerException("component " + inplaceInput.getClientId(context) + " client id is NULL" );
- }
//TODO:
//Should use clientId instead?
clientId = clientId + UIInplaceInput.VALUE_SUFFIX;
- Map request = context.getExternalContext().getRequestParameterMap();
- //TODO:
- //Request.get is enough
- if (request.containsKey(clientId)) {
- String newValue = (String)request.get(clientId);
- if (newValue != null) {
+ Map <String, String> request = context.getExternalContext().getRequestParameterMap();
+
+ String newValue = (String)request.get(clientId);
+ if (newValue != null) {
inplaceInput.setSubmittedValue(newValue);
- }
- }
+ }
}
//TODO:
@@ -124,16 +152,14 @@
}
public String encodeScriptAttributes(FacesContext context, UIComponent component) {
- //TODO:
- //Use string builder instead
- StringBuffer attributes = new StringBuffer();
+ StringBuilder attributes = new StringBuilder();
attributes.append("var attributes = ");
ScriptOptions options = new ScriptOptions(component);
String defaultLabel = (String)component.getAttributes().get("defaultLabel");
- //TODO: length()==0
- if (defaultLabel == null || defaultLabel.equals("")) {
+
+ if (defaultLabel == null || defaultLabel.length() == 0) {
defaultLabel = EMPTY_DEFAULT_LABEL;
}
@@ -152,7 +178,7 @@
}
public String encodeScriptEvents(FacesContext context, UIComponent component) {
- StringBuffer events = new StringBuffer();
+ StringBuilder events = new StringBuilder();
events.append("var events = ");
ScriptOptions options = new ScriptOptions(component);
@@ -166,7 +192,7 @@
}
public String encodeInplaceInputCss(FacesContext context, UIComponent component) {
- StringBuffer cssMap = new StringBuffer();
+ StringBuilder cssMap = new StringBuilder();
cssMap.append("var classes = ");
ScriptOptions mainMap = new ScriptOptions(component);
@@ -174,79 +200,30 @@
ScriptOptions changedClasses = new ScriptOptions(component);
ScriptOptions viewClasses = new ScriptOptions(component);
- changedClasses.addOption(INPLACE_NORMAL, buildCss(component, NORMAL_KEY, INPLACE_CSS_CHANGE) );
- changedClasses.addOption(INPLACE_HOVERED, buildCss(component, HOVERED_KEY, INPLACE_CSS_CHANGE));
+ changedClasses.addOption(INPLACE_NORMAL, createCss(component, States.NORMAL, INPLACE_CSS_CHANGE) );
+ changedClasses.addOption(INPLACE_HOVERED, createCss(component,States.HOVERED, INPLACE_CSS_CHANGE));
- viewClasses.addOption(INPLACE_NORMAL, buildCss(component, NORMAL_KEY, INPLACE_CSS_VIEW) );;
- viewClasses.addOption(INPLACE_HOVERED, buildCss(component, HOVERED_KEY, INPLACE_CSS_VIEW));
+ viewClasses.addOption(INPLACE_NORMAL, createCss(component, States.NORMAL, INPLACE_CSS_VIEW) );;
+ viewClasses.addOption(INPLACE_HOVERED, createCss(component,States.HOVERED, INPLACE_CSS_VIEW));
componentClasses.addOption(INPLACE_CHANGED,changedClasses);
componentClasses.addOption(INPLACE_VIEW, viewClasses);
- componentClasses.addOption(INPLACE_EDITABLE,buildCss(component, EDITABLE_KEY, INPLACE_CSS_EDITABLE));
+ componentClasses.addOption(INPLACE_EDITABLE,createCss(component, States.EDIT, INPLACE_CSS_EDITABLE));
mainMap.addOption(INPLACE_COMPONENT, componentClasses);
cssMap.append(mainMap.toString());
return cssMap.toString();
}
- //TODO: use enum?
- private String buildCss(UIComponent component, int key, String suffix) {
- Object value;
- StringBuffer stringBuffer = new StringBuffer();
-
- switch (key) {
- case NORMAL_KEY:
- stringBuffer.append(INPLACE_CSS_PUBLIC);
- stringBuffer.append(" ");
- stringBuffer.append(INPLACE_CSS_PUBLIC + "-" + suffix);
- value = component.getAttributes().get(suffix + "Class");
- if (value != null) {
- stringBuffer.append(" ");
- stringBuffer.append(value);
- }
- break;
- case HOVERED_KEY:
- stringBuffer.append(INPLACE_CSS_PUBLIC + "-" + "input-" + suffix + "-" + INPLACE_CSS_HOVER);
- value = component.getAttributes().get(suffix + "HoverClass");
- if (value != null) {
- stringBuffer.append(" ");
- stringBuffer.append(value);
- }
- break;
-
- case EDITABLE_KEY:
- stringBuffer.append(INPLACE_CSS_PUBLIC);
- stringBuffer.append(" ");
- stringBuffer.append(INPLACE_CSS_PUBLIC + "-" + suffix);
- value = component.getAttributes().get(suffix + "Class");
- if (value != null) {
- stringBuffer.append(" ");
- stringBuffer.append(value);
- }
- break;
- }
- return stringBuffer.toString();
+ private String createCss(UIComponent component, States state, String suffix) {
+ return state.createCss(component, suffix);
}
- //TODO: remove?
public String getAsEventHandler(FacesContext context, UIComponent component, String attributeName) {
- String event = (String) component.getAttributes().get(attributeName);
- String result = null;
-
- if (event != null) {
- event = event.trim();
-
- if (event.length() != 0) {
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("event");
- function.addToBody(event);
-
- result = function.toScript();
- }
- }
- return result;
+ JSFunctionDefinition script = RendererUtils.getAsEventHandler(context, component, attributeName, null);
+ return ScriptUtils.toScript(script);
}
-
+
@Override
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
return InputUtils.getConvertedValue(context, component, submittedValue);
@@ -257,8 +234,7 @@
}
protected boolean isEmptyDefaultLabel(String defaultLabel) {
- //TODO: remove != null?
- if (defaultLabel != null && EMPTY_DEFAULT_LABEL.equals(defaultLabel)) {
+ if (EMPTY_DEFAULT_LABEL.equals(defaultLabel)) {
return true;
}
return false;
16 years, 9 months
JBoss Rich Faces SVN: r7751 - in trunk/ui/inplaceSelect/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-04-11 05:44:49 -0400 (Fri, 11 Apr 2008)
New Revision: 7751
Modified:
trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/css/inplaceselect.xcss
trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
applying review
Modified: trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2008-04-11 09:21:26 UTC (rev 7750)
+++ trunk/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2008-04-11 09:44:49 UTC (rev 7751)
@@ -1,27 +1,15 @@
package org.richfaces.component;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
import javax.faces.component.UISelectOne;
-import javax.faces.context.FacesContext;
-import javax.faces.model.SelectItem;
-import org.ajax4jsf.util.SelectUtils;
-
/**
- * UI implementation of ComboBox component
+ * UI implementation of InplaceSelect component
* TODO: description here
* @author Anton Belevich
* @since 3.2.0
*
*/
-public class UIInplaceSelect extends UISelectOne{
-
- //TODO: Abstract class?
-
- //TODO: remove
- public List<SelectItem> getSelectItems(FacesContext context, UIComponent component) {
- return SelectUtils.getSelectItems(context, component);
- }
+public abstract class UIInplaceSelect extends UISelectOne{
+ public static final String COMPONENT_TYPE = "org.richfaces.InplaceSelect";
+ final static public String COMPONENT_FAMILY = "org.richfaces.InplaceSelect";
}
Modified: trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-04-11 09:21:26 UTC (rev 7750)
+++ trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-04-11 09:44:49 UTC (rev 7751)
@@ -5,7 +5,6 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -33,149 +32,123 @@
private static final String CONTROLS_FACET = "controls";
private static final String EMPTY_DEFAULT_LABEL = "   ";
- //Check copyPaste
@Override
protected void doDecode(FacesContext context, UIComponent component) {
- UIInplaceSelect inplaceInput = null;
+ UIInplaceSelect inplaceSelect = null;
+
+ if (component instanceof UIInplaceSelect) {
+ inplaceSelect = (UIInplaceSelect) component;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No decoding necessary since the component " + component.getId()
+ + " is not an instance or a sub class of UIInplaceSelect");
+ }
+ return;
+ }
- if (component instanceof UIInplaceSelect) {
- inplaceInput = (UIInplaceSelect) component;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("No decoding necessary since the component " + component.getId() + " is not an instance or a sub class of UIInplaceSelect");
- }
- return;
- }
+ String clientId = inplaceSelect.getClientId(context);
+ if (clientId == null) {
+ throw new NullPointerException("component client id is NULL");
+ }
+
+ if (InputUtils.isDisabled(inplaceSelect) || InputUtils.isReadOnly(inplaceSelect)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(("No decoding necessary since the component " + component.getId() + " is disabled"));
+ }
+ return;
+ }
- if (InputUtils.isDisabled(inplaceInput) || InputUtils.isReadOnly(inplaceInput)) {
- if (logger.isDebugEnabled()) {
- logger.debug(("No decoding necessary since the component " + component.getId() + " is disabled"));
- }
- }
-
- String clientId = component.getClientId(context);
- if (clientId == null) {
- throw new NullPointerException("component " + inplaceInput.getClientId(context) + " client id is NULL");
- }
-
- clientId = clientId + "inplaceValue";
- Map request = context.getExternalContext().getRequestParameterMap();
- if (request.containsKey(clientId)) {
- String newValue = (String) request.get(clientId);
- if(newValue != null) {
- inplaceInput.setSubmittedValue(newValue);
- }
- }
+ Map <String,String> request = context.getExternalContext().getRequestParameterMap();
+ String newValue = (String) request.get(clientId);
+ if (newValue != null) {
+ inplaceSelect.setSubmittedValue(newValue);
+ }
}
- //TODO: base on super method:
- //return component != null ? this.getComponentClass().isAssignableFrom(component.getClass()) : false;
- protected boolean isAcceptableComponent(UIComponent component) {
- if (component instanceof UIInplaceSelect) {
- return true;
- }
- return false;
+ public List<Object> encodeItems(FacesContext context, UIComponent component) throws IOException, IllegalArgumentException {
+
+ if (!isAcceptableComponent(component)) {
+ return null;
+ }
+
+ List<Object> parentList = new ArrayList<Object>();
+ List<String> labels = new ArrayList<String>();
+
+ UIInplaceSelect inplaceSelect = (UIInplaceSelect) component;
+ ResponseWriter writer = context.getResponseWriter();
+ List<SelectItem> selectItems = SelectUtils.getSelectItems(context, inplaceSelect);
+ for (SelectItem selectItem : selectItems) {
+ String value = getConvertedStringValue(context, inplaceSelect, selectItem.getValue());
+ String label = selectItem.getLabel();
+ labels.add(label);
+ encodeSuggestion(writer, inplaceSelect, label, RICH_INPLACE_SELECT_CLASSES);
+ Object[] child = new Object[2];
+ child[0] = label;
+ child[1] = value;
+ parentList.add(child);
+ }
+ return parentList;
}
-
- public List encodeItems(FacesContext context, UIComponent component) throws IOException {
-
- if (!isAcceptableComponent(component)) {
- return null;
- }
-
- //TODO generify
- List parentList = new ArrayList();
- UIInplaceSelect inplaceSelect = (UIInplaceSelect)component;
- List <String> labels = new ArrayList<String>();
- ResponseWriter writer = context.getResponseWriter();
- List<SelectItem> selectItems = SelectUtils.getSelectItems(context, inplaceSelect);
- //TODO use foreach
- if (!selectItems.isEmpty()) {
- for (Iterator<SelectItem> iterator = selectItems.iterator(); iterator.hasNext();) {
- SelectItem selectItem = iterator.next();
- String value = getConvertedStringValue(context, inplaceSelect, selectItem.getValue());
- String label = selectItem.getLabel();
- labels.add(label);
-
- encodeSuggestion(writer, inplaceSelect, label, RICH_INPLACE_SELECT_CLASSES);
-
- //TODO: review
- List childList = new ArrayList(2); //new Object[2]
- childList.add(label);
- childList.add(value);
- parentList.add(childList);
- }
- }
- return parentList;
- }
public void encodeControlsFacet(FacesContext context, UIComponent component) throws IOException {
- UIComponent facet = component.getFacet(CONTROLS_FACET);
- if ((facet != null) && (facet.isRendered())) {
- renderChild(context, facet);
- }
+ UIComponent facet = component.getFacet(CONTROLS_FACET);
+ if ((facet != null) && (facet.isRendered())) {
+ renderChild(context, facet);
+ }
}
public boolean isControlsFacetExists(FacesContext context, UIComponent component) {
- UIComponent facet = component.getFacet(CONTROLS_FACET);
- if (facet != null && facet.isRendered()) {
- return true;
- }
- return false;
+ UIComponent facet = component.getFacet(CONTROLS_FACET);
+ if (facet != null && facet.isRendered()) {
+ return true;
+ }
+ return false;
}
protected Class<? extends UIComponent> getComponentClass() {
return UIInplaceSelect.class;
}
- //TODO: review
public String getSelectedItemLabel(FacesContext context, UIInplaceSelect component) {
- //TODO: submitted value should be converted before searching for label
- Object value = component.getSubmittedValue();
- if (value == null) {
- value = component.getAttributes().get("value");
- }
- if (value == null) {
- return createDefaultLabel(component);
- }
-
- String defaultLabel = getItemLabel(context, component, value);
- if (defaultLabel == null) {
- return createDefaultLabel(component);
- }
- return defaultLabel;
+ Object submittedValue = component.getSubmittedValue();
+ Object value = submittedValue != null ? getConvertedValue(context, component, submittedValue) : component.getAttributes().get("value");
+ if (value == null || "".equals(value)) {
+ return createDefaultLabel(component);
+ }
+ return getItemLabel(context, component, value);
}
protected String getItemLabel(FacesContext context, UIComponent 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 = item.getLabel();
- //TODO break
- }
- }
+ 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 = item.getLabel();
+ break;
}
-
- //TODO exception if item hasn't been found
-
- return itemLabel;
+ }
+ }
+
+ if (itemLabel == null) {
+ throw new IllegalArgumentException("passed value is incorrect");
+ }
+
+ return itemLabel;
}
protected String createDefaultLabel(UIComponent component) {
- String defaultLabel = (String) component.getAttributes().get("defaultLabel");
- //TODO use length()
- if (defaultLabel == null || defaultLabel.equals("")) {
- defaultLabel = EMPTY_DEFAULT_LABEL;
- }
- return defaultLabel;
+ String defaultLabel = (String) component.getAttributes().get("defaultLabel");
+ if (defaultLabel == null || defaultLabel.length() == 0) {
+ defaultLabel = EMPTY_DEFAULT_LABEL;
+ }
+ return defaultLabel;
}
protected boolean isEmptyDefaultLabel(String defaultLabel) {
- //TODO review
- if (defaultLabel != null && EMPTY_DEFAULT_LABEL.equals(defaultLabel)) {
+ if (EMPTY_DEFAULT_LABEL.equals(defaultLabel)) {
return true;
}
return false;
Modified: trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/css/inplaceselect.xcss
===================================================================
--- trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/css/inplaceselect.xcss 2008-04-11 09:21:26 UTC (rev 7750)
+++ trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/css/inplaceselect.xcss 2008-04-11 09:44:49 UTC (rev 7751)
@@ -232,30 +232,11 @@
<u:style name="border-color" skin="headerBackgroundColor" />
</u:selector>
- <u:selector name=".rich-inplace-select-shadow-tl">
+ <u:selector name=".rich-inplace-select-shadow-tl, .rich-inplace-select-shadow-tr, .rich-inplace-select-shadow-bl , .rich-inplace-select-shadow-br">
<u:style name="background-image">
<f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
</u:style>
</u:selector>
-
- <u:selector name=".rich-inplace-select-shadow-tr">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
- <u:selector name=".rich-inplace-select-shadow-bl">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
- <u:selector name=".rich-inplace-select-shadow-br">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/bg_shadow.png"/>
- </u:style>
- </u:selector>
-
<u:selector name="input.rich-inplace-select-arrow">
<u:style name="background-image">
<f:resource f:key="org.richfaces.renderkit.html.images.SpinnerButtonDown"/>
Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-04-11 09:21:26 UTC (rev 7750)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-04-11 09:44:49 UTC (rev 7751)
@@ -78,8 +78,7 @@
<jsp:scriptlet>
if (layout.equals("inline")) {
</jsp:scriptlet>
- <!-- TODO #{component.attributes['viewClass']} -->
- <span id="#{clientId}" class="rich-inplace-select rich-inplace-select-view" x:passThruWithExclusions="id,styleClass,class,style">
+ <span id="#{clientId}" class="rich-inplace-select rich-inplace-select-view #{component.attributes['viewClass']}" x:passThruWithExclusions="id,styleClass,class,style">
<jsp:scriptlet>
} else {
</jsp:scriptlet>
@@ -97,7 +96,7 @@
readonly="readonly"
class="rich-inplace-select-field"/>
<input id="#{clientId}inselArrow" readonly="readonly" type="Text" value="" class="rich-inplace-select-arrow" style='display:none;'/>
- <input id='#{clientId}inplaceValue' name='#{clientId}inplaceValue' type='hidden' value='#{fieldValue}'/>
+ <input id='#{clientId}inplaceValue' name='#{clientId}' type='hidden' value='#{fieldValue}'/>
<div id="#{clientId}bar" class="rich-inplace-select-control-set" style="display:none;">
<jsp:scriptlet>
<![CDATA[
@@ -213,8 +212,8 @@
} else {
writer.writeText(convertToString(variables.getVariable("fieldLabel")),null);
}
- //TODO !layout.equals("inline")
- if (layout.equals("block")) {
+
+ if (!layout.equals("inline")) {
</jsp:scriptlet>
</div>
<jsp:scriptlet>
16 years, 9 months