myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r474185 - in /myfaces/tobago/trunk: theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/ tobago-tool/gendoc/src/main...
Date Mon, 13 Nov 2006 08:13:10 GMT
Author: lofwyr
Date: Mon Nov 13 00:13:10 2006
New Revision: 474185

URL: http://svn.apache.org/viewvc?view=rev&rev=474185
Log:
Resolving TOBAGO-187

Added:
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/OnOffConverter.java
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/SelectBooleanCheckboxController.java
Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/selectBooleanCheckbox.jsp

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java?view=diff&rev=474185&r1=474184&r2=474185
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
Mon Nov 13 00:13:10 2006
@@ -31,34 +31,46 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.UISelectBoolean;
 import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
 import java.io.IOException;
 
 public class SelectBooleanCheckboxRenderer extends RendererBase {
 
+  private static final Log LOG = LogFactory.getLog(SelectBooleanCheckboxRenderer.class);
+
   public void decode(FacesContext facesContext, UIComponent component) {
-    if (ComponentUtil.isOutputOnly(component)) {
+
+    UIInput input = (UIInput) component;
+
+    if (ComponentUtil.isOutputOnly(input)) {
       return;
     }
 
-    UIInput uiInput = (UIInput) component;
+    String newValue = (String) facesContext.getExternalContext()
+        .getRequestParameterMap().get(input.getClientId(facesContext));
 
-    String newValue = (String)
-        facesContext.getExternalContext().getRequestParameterMap()
-        .get(uiInput.getClientId(facesContext));
-    if (newValue != null
-        && (newValue.equalsIgnoreCase("on") || newValue.equalsIgnoreCase("yes")
-          || newValue.equalsIgnoreCase("true"))) {
-      uiInput.setSubmittedValue(Boolean.TRUE);
-    } else {
-      uiInput.setSubmittedValue(Boolean.FALSE);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("new value = '" + newValue + "'");
     }
+
+//    input.setSubmittedValue("true".equals(newValue) ? Boolean.TRUE : Boolean.FALSE);
+    input.setSubmittedValue("true".equals(newValue) ? "true": "false");
   }
 
+//  public Object getConvertedValue(
+//      FacesContext context, UIComponent component, Object submittedValue)
+//      throws ConverterException {
+//
+//      return Boolean.valueOf((String)submittedValue);
+//  }
+//
   public void encodeEnd(FacesContext facesContext,
       UIComponent uiComponent) throws IOException {
 
@@ -84,8 +96,8 @@
       writer.startElement(HtmlConstants.TD, null);
     }
 
-    Boolean currentValue = (Boolean) component.getValue();
-    boolean checked = currentValue != null && currentValue.booleanValue();
+    String currentValue = getCurrentValue(facesContext, component);
+    boolean checked = "true".equals(currentValue);
 
     writer.startElement(HtmlConstants.INPUT, component);
     writer.writeAttribute(HtmlAttributes.TYPE, "checkbox", null);

Added: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/OnOffConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/OnOffConverter.java?view=auto&rev=474185
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/OnOffConverter.java
(added)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/OnOffConverter.java
Mon Nov 13 00:13:10 2006
@@ -0,0 +1,28 @@
+package org.apache.myfaces.tobago.example.reference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+/**
+ * User: lofwyr
+ * Date: 07.11.2006 13:36:09
+ */
+public class OnOffConverter implements Converter {
+
+  private static final Log LOG = LogFactory.getLog(OnOffConverter.class);
+
+  public Object getAsObject(FacesContext context, UIComponent component, String value) throws
ConverterException {
+    LOG.info("getAsObject" + value);
+    return Boolean.parseBoolean(value) ? "on" : "off";
+  }
+
+  public String getAsString(FacesContext context, UIComponent component, Object value) throws
ConverterException {
+    LOG.info("getAsString" + value);
+    return "on".equals(value) ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
+  }
+}

Added: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/SelectBooleanCheckboxController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/SelectBooleanCheckboxController.java?view=auto&rev=474185
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/SelectBooleanCheckboxController.java
(added)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/java/org/apache/myfaces/tobago/example/reference/SelectBooleanCheckboxController.java
Mon Nov 13 00:13:10 2006
@@ -0,0 +1,24 @@
+package org.apache.myfaces.tobago.example.reference;
+
+public class SelectBooleanCheckboxController {
+
+  private String onOffString = "on";
+  private boolean normalBoolean = true;
+
+  public String getOnOffString() {
+    return onOffString;
+  }
+
+  public void setOnOffString(String onOffString) {
+    this.onOffString = onOffString;
+  }
+
+  public boolean isNormalBoolean() {
+    return normalBoolean;
+  }
+
+  public void setNormalBoolean(boolean normalBoolean) {
+    this.normalBoolean = normalBoolean;
+  }
+
+}

Modified: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=474185&r1=474184&r2=474185
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/WEB-INF/faces-config.xml Mon Nov
13 00:13:10 2006
@@ -25,6 +25,11 @@
 
 <faces-config>
 
+  <converter>
+    <converter-id>org.apache.myfaces.tobago.example.reference.OnOffConverter</converter-id>
+    <converter-class>org.apache.myfaces.tobago.example.reference.OnOffConverter</converter-class>
+  </converter>
+
   <application>
     <locale-config>
       <default-locale>en</default-locale>
@@ -48,6 +53,12 @@
   <managed-bean>
     <managed-bean-name>reference</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.tobago.example.reference.Controller</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
+  <managed-bean>
+    <managed-bean-name>selectBooleanCheckboxController</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.reference.SelectBooleanCheckboxController</managed-bean-class>
     <managed-bean-scope>session</managed-bean-scope>
   </managed-bean>
 

Modified: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/selectBooleanCheckbox.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/selectBooleanCheckbox.jsp?view=diff&rev=474185&r1=474184&r2=474185
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/selectBooleanCheckbox.jsp
(original)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/selectBooleanCheckbox.jsp
Mon Nov 13 00:13:10 2006
@@ -26,12 +26,15 @@
     <jsp:body>
       <tc:box>
         <f:facet name="layout">
-          <tc:gridLayout rows="fixed;fixed;fixed;fixed;1*"/>
+          <tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;1*"/>
         </f:facet>
 
+        <tc:messages/>
+
         <%-- code-sniplet-start id="selectBooleanCheckbox" --%>
-        <tc:selectBooleanCheckbox label="_Letter"/>
+        <%--<tc:selectBooleanCheckbox label="_Letter"/>--%>
         <%-- code-sniplet-end id="selectBooleanCheckbox" --%>
+<%--
         <tc:selectBooleanCheckbox label="_Phone"/>
         <tc:selectBooleanCheckbox label="_eMail"/>
         <tc:selectBooleanCheckbox label="_Fax" >
@@ -39,6 +42,19 @@
             <tc:command />
           </f:facet>
         </tc:selectBooleanCheckbox>
+--%>
+        <tc:cell/>
+        <tc:cell/>
+        <tc:cell/>
+        <tc:cell/>
+
+        <tc:selectBooleanCheckbox label="Value is Boolean" value="#{selectBooleanCheckboxController.normalBoolean}"/>
+
+        <tc:selectBooleanCheckbox label="Converter for Boolean" value="#{selectBooleanCheckboxController.onOffString}">
+          <f:converter converterId="org.apache.myfaces.tobago.example.reference.OnOffConverter"/>
+        </tc:selectBooleanCheckbox>
+
+        <tc:button label="submit" action="submit" />
 
         <tc:cell/>
 



Mime
View raw message