You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/07/18 15:08:17 UTC
svn commit: r423078 - in /myfaces/tomahawk/trunk/core/src/main:
java/org/apache/myfaces/custom/selectOneCountry/ tld/tomahawk-entities/
Author: mmarinschek
Date: Tue Jul 18 06:08:16 2006
New Revision: 423078
URL: http://svn.apache.org/viewvc?rev=423078&view=rev
Log:
patch for TOMAHAWK-23. Thanks to Cagatay Civici for providing this.
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountry.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryRenderer.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryTag.java
myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_select_one_country_attributes.xml
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountry.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountry.java?rev=423078&r1=423077&r2=423078&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountry.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountry.java Tue Jul 18 06:08:16 2006
@@ -42,6 +42,8 @@
private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SelectOneCountryRenderer";
private Integer _maxLength = null;
+
+ private String _emptySelection = null;
public SelectOneCountry() {
setRendererType(DEFAULT_RENDERER_TYPE);
@@ -55,11 +57,21 @@
public void setMaxLength(Integer maxLength) {
_maxLength = maxLength;
}
+
+ public String getEmptySelection() {
+ if (_emptySelection != null) return _emptySelection;
+ ValueBinding vb = getValueBinding("emptySelection");
+ return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ }
+ public void setEmptySelection(String emptySelection) {
+ _emptySelection = emptySelection;
+ }
public Object saveState(FacesContext context) {
- Object values[] = new Object[2];
+ Object values[] = new Object[3];
values[0] = super.saveState(context);
values[1] = _maxLength;
+ values[2] = _emptySelection;
return values;
}
@@ -67,6 +79,7 @@
Object values[] = (Object[])state;
super.restoreState(context, values[0]);
_maxLength = (Integer)values[1];
+ _emptySelection = (String) values[2];
}
private Set getFilterSet(){
@@ -108,6 +121,8 @@
}
List countriesSelectItems = new ArrayList( map.size() );
+ if(getEmptySelection() != null)
+ countriesSelectItems.add(new SelectItem(getEmptySelection(), getEmptySelection()));
Integer maxLength = getMaxLength();
int maxDescriptionLength = maxLength==null ? Integer.MAX_VALUE : maxLength.intValue();
@@ -143,4 +158,4 @@
setValid(false);
}
-}
\ No newline at end of file
+}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryRenderer.java?rev=423078&r1=423077&r2=423078&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryRenderer.java Tue Jul 18 06:08:16 2006
@@ -36,6 +36,15 @@
*/
public class SelectOneCountryRenderer extends HtmlMenuRenderer {
+ public void decode(FacesContext facesContext, UIComponent component) {
+ super.decode(facesContext, component);
+ SelectOneCountry selectOneCountry = (SelectOneCountry) component;
+ //if the empty selection is submitted, reset the submitted value
+ Object submittedValue = selectOneCountry.getSubmittedValue();
+ if(submittedValue != null && submittedValue.equals(selectOneCountry.getEmptySelection()))
+ selectOneCountry.setSubmittedValue(null);
+ }
+
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException
{
@@ -83,4 +92,4 @@
writer.writeText("", null);
writer.endElement(HTML.SELECT_ELEM);
}
-}
\ No newline at end of file
+}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryTag.java?rev=423078&r1=423077&r2=423078&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryTag.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneCountry/SelectOneCountryTag.java Tue Jul 18 06:08:16 2006
@@ -33,19 +33,32 @@
}
private String maxLength;
+
+ private String emptySelection;
public void release() {
super.release();
maxLength=null;
+ emptySelection=null;
}
protected void setProperties(UIComponent component) {
super.setProperties(component);
setIntegerProperty(component, "maxLength", maxLength);
+ setStringProperty(component, "emptySelection", emptySelection);
}
public void setMaxLength(String maxLength){
this.maxLength = maxLength;
}
-}
\ No newline at end of file
+
+ public String getEmptySelection() {
+ return emptySelection;
+ }
+
+ public void setEmptySelection(String emptySelection) {
+ this.emptySelection = emptySelection;
+ }
+
+}
Modified: myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_select_one_country_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_select_one_country_attributes.xml?rev=423078&r1=423077&r2=423078&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_select_one_country_attributes.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_select_one_country_attributes.xml Tue Jul 18 06:08:16 2006
@@ -6,3 +6,11 @@
Integer equals to the maximum number of characters in the country name.
</description>
</attribute>
+ <attribute>
+ <name>emptySelection</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ Label and value to be used when displaying an empty selection
+ </description>
+ </attribute>