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 2005/06/16 01:15:41 UTC
svn commit: r190829 - in /myfaces/trunk/src:
components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java
components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
share/org/apache/myfaces/renderkit/html/HTML.java
Author: mmarinschek
Date: Wed Jun 15 16:15:41 2005
New Revision: 190829
URL: http://svn.apache.org/viewcvs?rev=190829&view=rev
Log:
Changes in InputTextHelp for proper decoding
Modified:
myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java
myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HTML.java
Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java?rev=190829&r1=190828&r2=190829&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlInputTextHelp.java Wed Jun 15 16:15:41 2005
@@ -61,7 +61,7 @@
public Object saveState(FacesContext context)
{
- Object[] state = new Object[4];
+ Object[] state = new Object[3];
state[0] = super.saveState(context);
state[1] = _helpText;
state[2] = _selectText;
Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java?rev=190829&r1=190828&r2=190829&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java Wed Jun 15 16:15:41 2005
@@ -1,19 +1,19 @@
package org.apache.myfaces.custom.inputTextHelp;
-import org.apache.myfaces.renderkit.html.HtmlTextRendererBase;
-import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.component.html.util.AddResource;
+import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.renderkit.html.HTML;
+import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
import org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer;
import org.apache.myfaces.renderkit.html.util.HTMLEncoder;
-import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.component.html.util.AddResource;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
-
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.ConverterException;
import java.io.IOException;
+import java.util.Map;
/**
* @author Thomas Obereder
@@ -56,27 +56,29 @@
return null;
}
- public static void renderInputTextHelp(FacesContext facesContext, UIInput input)
+ public void renderInputTextHelp(FacesContext facesContext, UIInput input)
throws IOException
{
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.INPUT_ELEM, input);
- //write id in any case, it is needed for the java-script function
- writer.writeAttribute(HTML.ID_ATTR, input.getClientId(facesContext),null);
+ writer.writeAttribute(HTML.ID_ATTR, input.getClientId(facesContext), null);
+ writer.writeAttribute(HTML.NAME_ATTR, input.getClientId(facesContext), null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT, null);
+
renderHelpTextAttributes(input, writer, facesContext);
String value = RendererUtils.getStringValue(facesContext, input);
- value = (value.equals("") || value == null) ? getHelpText(input) : "";
+ value = (value.equals("") || value == null) ? getHelpText(input) : value;
writer.writeAttribute(HTML.VALUE_ATTR, HTMLEncoder.encode(value,true,true), null);
writer.endElement(HTML.INPUT_ELEM);
}
- public static void renderHelpTextAttributes(UIComponent component,
+ private void renderHelpTextAttributes(UIComponent component,
ResponseWriter writer,
FacesContext facesContext)
throws IOException
@@ -92,7 +94,7 @@
if(isSelectText(component))
{
HtmlRendererUtils.renderHTMLAttributes(writer, component,
- HTML.COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK);
+ HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK);
writer.writeAttribute(HTML.ONFOCUS_ATTR,
HtmlInputTextHelp.JS_FUNCTION_SELECT_TEXT + "('" +
getHelpText(component) + "', '" + id +"')", null);
@@ -106,7 +108,7 @@
if(getHelpText(component) != null)
{
HtmlRendererUtils.renderHTMLAttributes(writer, component,
- HTML.COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK);
+ HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK);
writer.writeAttribute(HTML.ONFOCUS_ATTR,
HtmlInputTextHelp.JS_FUNCTION_RESET_HELP + "('" +
getHelpText(component) + "', '" + id +"')", null);
@@ -117,13 +119,35 @@
else
{
HtmlRendererUtils.renderHTMLAttributes(writer,
- component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ component, HTML.COMMON_FIELD_ATTRIBUTES_WITHOUT_DISABLED);
}
}
}
+
+ if (isDisabled(facesContext, component))
+ {
+ writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
+ }
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ super.decode(facesContext, component);
+ }
+
+ public Object getConvertedValue(FacesContext facesContext, UIComponent component, Object submittedValue) throws ConverterException
+ {
+ if(submittedValue!=null && component instanceof HtmlInputTextHelp &&
+ ((HtmlInputTextHelp) component).getHelpText()!=null &&
+ submittedValue.equals(((HtmlInputTextHelp) component).getHelpText()))
+ {
+ submittedValue = "";
+ }
+
+ return super.getConvertedValue(facesContext, component, submittedValue);
}
- private static void addJavaScriptResources(FacesContext facesContext) throws IOException
+ private static void addJavaScriptResources(FacesContext facesContext)
{
AddResource.addJavaScriptToHeader(HtmlTextHelpRenderer.class,
"inputTextHelp.js",
Modified: myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HTML.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HTML.java?rev=190829&r1=190828&r2=190829&view=diff
==============================================================================
--- myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HTML.java (original)
+++ myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HTML.java Wed Jun 15 16:15:41 2005
@@ -269,6 +269,11 @@
INPUT_ATTRIBUTES,
COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+ public static final String[] INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK =
+ (String[]) ArrayUtils.concat(
+ INPUT_ATTRIBUTES,
+ COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONFOCUS_AND_ONCLICK);
+
//values for input-type attribute
public static final String INPUT_TYPE_SUBMIT = "submit";
public static final String INPUT_TYPE_IMAGE = "image";