You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/12/07 12:51:05 UTC

svn commit: r1042986 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/convert/ tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/ tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myf...

Author: lofwyr
Date: Tue Dec  7 11:51:05 2010
New Revision: 1042986

URL: http://svn.apache.org/viewvc?rev=1042986&view=rev
Log:
TOBAGO-956: CurrencyConverter should handle null values

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/currency.xhtml
      - copied, changed from r1042955, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/convert/CurrencyConverter.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/convert/CurrencyConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/convert/CurrencyConverter.java?rev=1042986&r1=1042985&r2=1042986&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/convert/CurrencyConverter.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/convert/CurrencyConverter.java Tue Dec  7 11:51:05 2010
@@ -17,6 +17,8 @@ package org.apache.myfaces.tobago.conver
  * limitations under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
+
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
@@ -31,11 +33,18 @@ public class CurrencyConverter implement
 
   public Object getAsObject(FacesContext facesContext, UIComponent component, String string)
       throws ConverterException {
-    return Currency.getInstance(string);
+    if (StringUtils.isBlank(string)) {
+      return null;
+    } else {
+      return Currency.getInstance(string);
+    }
   }
 
   public String getAsString(FacesContext facesContext, UIComponent component, Object object)
       throws ConverterException {
+    if (object == null) {
+      return null;
+    }
     try {
       return ((Currency) object).getCurrencyCode();
     } catch (ClassCastException e) {

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/currency.xhtml (from r1042955, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/currency.xhtml?p2=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/currency.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml&r1=1042955&r2=1042986&rev=1042986&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/currency.xhtml Tue Dec  7 11:51:05 2010
@@ -22,66 +22,27 @@
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">
 
-  <tc:page>
+  <tc:page label="Sample with model">
     <tc:gridLayoutConstraint width="700px" height="600px"/>
     <f:facet name="layout">
       <!-- fixme: rows="20px" -->
-      <tc:gridLayout columns="*;2*" rows="auto;20px" columnSpacing="30px"/>
+      <tc:gridLayout rows="auto;20px;auto;auto;auto;*"/>
     </f:facet>
 
-    <tc:messages>
-      <tc:gridLayoutConstraint columnSpan="2"/>
-    </tc:messages>
-    
-    <tc:label value="tc"/>
-    <tc:label value="tx"/>
-    
-    <tc:selectOneChoice value="a">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tc:selectOneChoice>
-    <tx:selectOneChoice value="b" label="normal">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tx:selectOneChoice>
+    <tc:messages/>
 
-    <tc:selectOneChoice value="a" readonly="true">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tc:selectOneChoice>
-    <tx:selectOneChoice value="b" readonly="true" label="readonly">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tx:selectOneChoice>
+    <tc:label value="required input"/>
 
-    <tc:selectOneChoice value="a" disabled="true">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tc:selectOneChoice>
-    <tx:selectOneChoice value="b" disabled="true" label="disabled">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
+    <tx:selectOneChoice required="true" value="#{selectItemModel.currency}" label="Input:">
+      <tc:selectItem itemValue="#{null}" itemLabel="&lt;please select>"/>
+      <tc:selectItems value="#{selectItemModel.availableCurrencies}"/>
     </tx:selectOneChoice>
 
-    <tc:selectOneChoice value="a" tip="tip">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tc:selectOneChoice>
-    <tx:selectOneChoice value="b" tip="tip" label="tip">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tx:selectOneChoice>
+    <tx:in readonly="true" value="#{selectItemModel.currency}" label="Model:"/>
 
-    <tc:selectOneChoice required="true">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tc:selectOneChoice>
-    <tx:selectOneChoice required="true" label="required">
-      <tc:selectItem itemValue="a" itemLabel="A Value"/>
-      <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
-    </tx:selectOneChoice>
-    
     <tc:button label="submit"/>
+
+    <tc:cell/>
     
   </tc:page>
 </f:view>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml?rev=1042986&r1=1042985&r2=1042986&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/selectOneChoice/selectOneChoice.xhtml Tue Dec  7 11:51:05 2010
@@ -75,10 +75,12 @@
     <tc:selectOneChoice required="true">
       <tc:selectItem itemValue="a" itemLabel="A Value"/>
       <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
+      <tc:selectItem itemLabel="&lt;no value>"/>
     </tc:selectOneChoice>
     <tx:selectOneChoice required="true" label="required">
       <tc:selectItem itemValue="a" itemLabel="A Value"/>
       <tc:selectItem itemValue="b" itemLabel="An Alternative"/>
+      <tc:selectItem itemLabel="&lt;no value>"/>
     </tx:selectOneChoice>
     
     <tc:button label="submit"/>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?rev=1042986&r1=1042985&r2=1042986&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Tue Dec  7 11:51:05 2010
@@ -1007,8 +1007,91 @@ div.tobago-richTextEditor-body {
 
 /* tab ------------------------------------------------------------------ */
 
+.tobago-tab {
+  background-color: #cccccc;
+  border: 1px solid #000000;
+  padding: 2px 6px 1px 6px;
+  margin-top: 2px;
+  margin-right: 2px;
+  vertical-align: top;
+  float: left;
+  cursor: pointer;
+}
+
+.tobago-tab img {
+  height: 12px;
+}
+
+.tobago-tab a:link,
+.tobago-tab a:visited,
+.tobago-tab a:active {
+  color: #000000;
+  text-decoration: none;
+}
+
+.tobago-tab-markup-selected {
+  border-bottom-width: 0;
+  font-weight: bold;
+  background: url("image/box-header-bg.gif") repeat-x scroll center top #E8E8E8;
+  margin-top: 0;
+  padding-bottom: 4px;
+  color: #660000;
+}
+
+.tobago-tab-markup-error span {
+  background-image: url("org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/dialog-error.png");
+  background-repeat: no-repeat;
+  background-position: left center;
+  padding-left: 13px;
+  color: #FF0000;
+}
+
+.tobago-tab-markup-selected a:link,
+.tobago-tab-markup-selected a:visited,
+.tobago-tab-markup-selected a:active {
+  color: #660000;
+}
+
+.tobago-tabGroup {
+  position: absolute;
+  background-color: #fafad2;
+}
+
+.tobago-tabGroup-header {
+  position: relative;
+  background-color: #cccccc;
+  font: 12px arial, helvetica, sans-serif;
+  overflow: hidden;
+}
+
+.tobago-tabGroup-headerInner {
+  border-bottom: 1px solid #000000;
+  height: 20px;
+  width: 10000px;
+  font: 12px arial, helvetica, sans-serif;
+  overflow: visible;
+}
+
+.tobago-tabGroup-toolBar {
+  position: absolute;
+  right: 0;
+  top: 0;
+  height: 19px;
+  width: 50px;
+  background-color: #cccccc;
+  border: 1px solid black;
+}
+
+.tobago-tab-content {
+  position: relative;
+  border-color: #ddeeff #778899 #778899 #ddeeff;
+  border-width: 0 1px 1px 1px;
+  border-style: solid;
+}
+
+/*
 .tobago-tab-link {
-  font-family: arial, helvetica, sans-serif; /*  font-size: 14px; */
+  font-family: arial, helvetica, sans-serif; /*  font-size: 14px; * /
   color: #000000;
   cursor: pointer;
   white-space: nowrap;
@@ -1044,6 +1127,13 @@ div.tobago-richTextEditor-body {
   white-space: nowrap;
 }
 
+.tobago-tab-content {
+  border-color: #ddeeff #778899 #778899 #ddeeff;
+  border-width: 0 1px 1px 1px;
+  border-style: solid;
+  padding: 11px 11px;
+}
+
 .tobago-tabGroup-fulfill {
   border-color: #ddeeff;
   border-width: 0 0 1px 0;
@@ -1052,25 +1142,19 @@ div.tobago-richTextEditor-body {
   vertical-align:bottom;
 }
 
-.tobago-tab-content {
-  border-color: #ddeeff #778899 #778899 #ddeeff;
-  border-width: 0 1px 1px 1px;
-  border-style: solid;
-  padding: 11px 11px;
-}
-
 div.tobago-tabGroup-toolBar {
   border-color: #DDEEFF;
   border-style: solid;
   border-width: 1px;
   height: 16px;
   bottom: 0;
-/* width: 59px; */
+/* width: 59px; * /
   margin-right: 0;
   position: absolute;
   overflow: hidden;
   white-space: nowrap;
 }
+*/
 
 /* tabGroupToolBar ----------------------------------------------------------------- */