myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svieu...@apache.org
Subject svn commit: r169687 - in /myfaces/trunk: src/components/org/apache/myfaces/component/html/ext/ src/components/org/apache/myfaces/custom/inputHtml/ tlds/ tlds/entities/
Date Wed, 11 May 2005 19:46:21 GMT
Author: svieujot
Date: Wed May 11 12:46:20 2005
New Revision: 169687

URL: http://svn.apache.org/viewcvs?rev=169687&view=rev
Log:
First use of displayValueOnly attribute for inputHtml.

Added:
    myfaces/trunk/tlds/entities/display_value_only_attributes.xml   (with props)
Modified:
    myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java
    myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.xml
    myfaces/trunk/src/components/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
    myfaces/trunk/tlds/myfaces_ext.tld

Modified: myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java?rev=169687&r1=169686&r2=169687&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java
(original)
+++ myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java
Wed May 11 12:46:20 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.myfaces.component.html.ext;
 
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
 import org.apache.myfaces.component.UserRoleAware;
 import org.apache.myfaces.component.UserRoleUtils;
 import org.apache.myfaces.component.html.util.HtmlComponentUtils;
@@ -28,7 +29,7 @@
  */
 public class HtmlInputText
         extends javax.faces.component.html.HtmlInputText
-        implements UserRoleAware
+        implements UserRoleAware, DisplayValueOnlyCapable
 {
 
     public String getClientId(FacesContext context)
@@ -45,9 +46,11 @@
     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
 
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlInputText";
+    private static final boolean DEFAULT_DISPLAYVALUEONLY = false;
 
     private String _enabledOnUserRole = null;
     private String _visibleOnUserRole = null;
+	private Boolean _displayValueOnly = null;
 
     public HtmlInputText()
     {
@@ -78,20 +81,33 @@
         return vb != null ? (String)vb.getValue(getFacesContext()) : null;
     }
 
-
     public boolean isRendered()
     {
         if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
         return super.isRendered();
     }
+	
+    public void setDisplayValueOnly(boolean displayValueOnly)
+    {
+        _displayValueOnly = Boolean.valueOf(displayValueOnly);
+    }
+
+    public boolean isDisplayValueOnly()
+    {
+        if (_displayValueOnly != null) return _displayValueOnly.booleanValue();
+        ValueBinding vb = getValueBinding("displayValueOnly");
+        Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
+        return v != null ? v.booleanValue() : DEFAULT_DISPLAYVALUEONLY;
+    }
 
     public Object saveState(FacesContext context)
     {
-        Object values[] = new Object[3];
+        Object values[] = new Object[4];
         values[0] = super.saveState(context);
         values[1] = _enabledOnUserRole;
         values[2] = _visibleOnUserRole;
-        return ((Object) (values));
+		values[3] = _displayValueOnly;
+        return values;
     }
 
     public void restoreState(FacesContext context, Object state)
@@ -100,6 +116,7 @@
         super.restoreState(context, values[0]);
         _enabledOnUserRole = (String)values[1];
         _visibleOnUserRole = (String)values[2];
+		_displayValueOnly = (Boolean)values[3];
     }
     //------------------ GENERATED CODE END ---------------------------------------
 }

Modified: myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.xml
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.xml?rev=169687&r1=169686&r2=169687&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.xml (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.xml Wed
May 11 12:46:20 2005
@@ -14,4 +14,9 @@
         <name>visibleOnUserRole</name>
         <type>java.lang.String</type>
     </field>
+    <field>
+        <name>displayValueOnly</name>
+        <type>boolean</type>
+        <default-value>false</default-value>
+    </field>
 </component>

Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java?rev=169687&r1=169686&r2=169687&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
(original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
Wed May 11 12:46:20 2005
@@ -58,11 +58,34 @@
     public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException
{
         RendererUtils.checkParamValidity(context, uiComponent, InputHtml.class);
 		InputHtml editor = (InputHtml) uiComponent;
-		if( useFallback(editor) )
+		if( editor.isDisplayValueOnly() )
+			encodeDisplayValueOnly(context, editor);
+		else if( useFallback(editor) )
 			encodeEndFallBackMode(context, editor);
 		else
 			encodeEndNormalMode(context, editor);
     }
+
+	private void encodeDisplayValueOnly(FacesContext context, InputHtml editor) throws IOException
{
+		String clientId = editor.getClientId(context);
+		// Use only a textarea
+		ResponseWriter writer = context.getResponseWriter();
+        writer.startElement(HTML.SPAN_ELEM, editor);
+
+        writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
+        HtmlRendererUtils.writeIdIfNecessary(writer, editor, context);
+
+		// TODO : Change to use displayValueOnlyStyle/StyleClass ?
+		if( editor.getStyle()!=null )
+            writer.writeAttribute(HTML.STYLE_ATTR, editor.getStyle(), null);
+		if( editor.getStyleClass()!=null )
+            writer.writeAttribute(HTML.STYLE_CLASS_ATTR, editor.getStyleClass(), null);
+
+        String text = RendererUtils.getStringValue(context, editor);
+        writer.write( getHtmlBody( text ) );
+
+        writer.endElement(HTML.SPAN_ELEM);
+	}
 
 	private void encodeEndFallBackMode(FacesContext context, InputHtml editor) throws IOException
{
 		String clientId = editor.getClientId(context);

Added: myfaces/trunk/tlds/entities/display_value_only_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/trunk/tlds/entities/display_value_only_attributes.xml?rev=169687&view=auto
==============================================================================
--- myfaces/trunk/tlds/entities/display_value_only_attributes.xml (added)
+++ myfaces/trunk/tlds/entities/display_value_only_attributes.xml Wed May 11 12:46:20 2005
@@ -0,0 +1,10 @@
+<!-- MyFaces extension: user role attributes -->
+        <attribute>
+            <name>displayValueOnly</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+            <description>
+                If true, renders only the value of the component, but no input widget.
+                Default is false.
+            </description>
+        </attribute>

Propchange: myfaces/trunk/tlds/entities/display_value_only_attributes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trunk/tlds/entities/display_value_only_attributes.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: myfaces/trunk/tlds/entities/display_value_only_attributes.xml
------------------------------------------------------------------------------
    svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"

Propchange: myfaces/trunk/tlds/entities/display_value_only_attributes.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: myfaces/trunk/tlds/myfaces_ext.tld
URL: http://svn.apache.org/viewcvs/myfaces/trunk/tlds/myfaces_ext.tld?rev=169687&r1=169686&r2=169687&view=diff
==============================================================================
--- myfaces/trunk/tlds/myfaces_ext.tld (original)
+++ myfaces/trunk/tlds/myfaces_ext.tld Wed May 11 12:46:20 2005
@@ -19,6 +19,7 @@
 <!DOCTYPE taglib
   PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
   "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd" [
+<!ENTITY display_value_only_attributes  SYSTEM "entities/display_value_only_attributes.xml">
 <!ENTITY ext_forceId_attribute          SYSTEM "entities/ext_forceId_attribute.xml">
 <!ENTITY html_anchor_attributes         SYSTEM "entities/html_anchor_attributes.xml">
 <!ENTITY html_button_attributes         SYSTEM "entities/html_button_attributes.xml">
@@ -994,6 +995,7 @@
         </attribute>
         &ui_input_attributes;
         &user_role_attributes;
+        &display_value_only_attributes;
         <attribute>
 	        <name>style</name>
             <required>false</required>



Mime
View raw message