dev@woodstock.java.net

[Fwd: CVS update: /woodstock/webui/src/runtime/com/sun/webui/jsf/component/, /woodstock/webui/src/runtime/com/sun/webui/jsf/renderkit/widget/, /woodstock...]

From: Dick Spellman <Richard.Spellman_at_Sun.COM>
Date: Thu, 22 Mar 2007 09:46:04 -0400

These will not be in the 4.1 Build 1 candidate we will be testing today
and tomorrow. Which is fine, since it was not scheduled to be
integrated until Build 2.

I just wanted people to be aware since the timing was close to the
nightly build kickoff time.

Thanks,
D

attached mail follows:



User: animeshkumarsahay
Date: 2007/03/22 01:27:11

Added:
   woodstock/webui/src/runtime/com/sun/webui/jsf/renderkit/widget/HiddenFieldRenderer.java

Modified:
   woodstock/webui/src/runtime/com/sun/webui/jsf/component/HiddenField.java
   woodstock/webui/src/runtime/com/sun/webui/jsf/theme/ThemeTemplates.java
   woodstock/webui/src/designtime/conf/faces-config.xml

Log:
 Reviewed by:Dan
 Client side hidden field component

File Changes:

Directory: /woodstock/webui/src/runtime/com/sun/webui/jsf/component/
====================================================================

File [changed]: HiddenField.java
Url: https://woodstock.dev.java.net/source/browse/woodstock/webui/src/runtime/com/sun/webui/jsf/component/HiddenField.java?r1=1.3&r2=1.4
Delta lines: +44 -7
--------------------
--- HiddenField.java 26 Feb 2007 22:46:29 -0000 1.3
+++ HiddenField.java 22 Mar 2007 08:27:07 -0000 1.4
@@ -23,29 +23,27 @@
 
 import com.sun.faces.annotation.Component;
 import com.sun.faces.annotation.Property;
-import com.sun.webui.jsf.event.MethodExprValueChangeListener;
 import com.sun.webui.jsf.util.ConversionUtilities;
-import com.sun.webui.jsf.validator.MethodExprValidator;
+import com.sun.webui.jsf.util.JavaScriptUtilities;
 
 import javax.el.ValueExpression;
 import javax.faces.context.FacesContext;
-import javax.faces.event.ValueChangeListener;
-import javax.faces.validator.Validator;
 
 /**
  * The HiddenField component is used to create a hidden input field.
  */
 @Component(type="com.sun.webui.jsf.HiddenField", family="com.sun.webui.jsf.HiddenField", displayName="Hidden Field", tagName="hiddenField",
     helpKey="projrave_ui_elements_palette_wdstk-jsf1.2_hidden_field",
+ tagRendererType="com.sun.webui.jsf.widget.HiddenField",
     propertiesHelpKey="projrave_ui_elements_palette_wdstk-jsf1.2_propsheets_hidden_field_props")
-public class HiddenField extends WebuiInput {
+public class HiddenField extends WebuiInput implements Widget {
     
     private final static boolean DEBUG = false;
     
     /** Creates a new instance of HiddenField */
     public HiddenField() {
         super();
- setRendererType("com.sun.webui.jsf.HiddenField");
+ setRendererType("com.sun.webui.jsf.widget.HiddenField");
     }
 
     /**
@@ -56,6 +54,43 @@
     }
             
     /**
+ * Get the type of widget represented by this component.
+ * @return The type of widget represented by this component.
+ */
+ public String getWidgetType() {
+ return JavaScriptUtilities.getNamespace("hiddenField");
+ }
+
+ /**
+ * Alternative HTML template to be used by this component.
+ */
+ @Property(name="htmlTemplate", displayName="HTML Template", category="Appearance")
+ private String htmlTemplate = null;
+
+ /**
+ * Get alternative HTML template to be used by this component.
+ */
+
+ public String getHtmlTemplate() {
+ if (this.htmlTemplate != null) {
+ return this.htmlTemplate;
+ }
+ ValueExpression _vb = getValueExpression("htmlTemplate");
+ if (_vb != null) {
+ return (String) _vb.getValue(getFacesContext().getELContext());
+ }
+ return null;
+ }
+
+ /**
+ * Set alternative HTML template to be used by this component.
+ */
+
+ public void setHtmlTemplate(String htmlTemplate) {
+ this.htmlTemplate = htmlTemplate;
+ }
+
+ /**
      * <p>Return the value to be rendered as a string when the
      * component is readOnly. The default behaviour is to
      * invoke getValueAsString(). Override this method in case
@@ -237,16 +272,18 @@
         super.restoreState(_context, _values[0]);
         this.disabled = ((Boolean) _values[1]).booleanValue();
         this.disabled_set = ((Boolean) _values[2]).booleanValue();
+ this.htmlTemplate = (String) _values[3];
     }
 
     /**
      * <p>Save the state of this component.</p>
      */
     public Object saveState(FacesContext _context) {
- Object _values[] = new Object[3];
+ Object _values[] = new Object[4];
         _values[0] = super.saveState(_context);
         _values[1] = this.disabled ? Boolean.TRUE : Boolean.FALSE;
         _values[2] = this.disabled_set ? Boolean.TRUE : Boolean.FALSE;
+ _values[3] = this.htmlTemplate;
         return _values;
     }
 }

Directory: /woodstock/webui/src/runtime/com/sun/webui/jsf/renderkit/widget/
===========================================================================

File [added]: HiddenFieldRenderer.java
Url: https://woodstock.dev.java.net/source/browse/woodstock/webui/src/runtime/com/sun/webui/jsf/renderkit/widget/HiddenFieldRenderer.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 168
----------------
/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://woodstock.dev.java.net/public/CDDLv1.0.html.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at https://woodstock.dev.java.net/public/CDDLv1.0.html.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.webui.jsf.renderkit.widget;

import com.sun.faces.annotation.Renderer;
import com.sun.webui.jsf.component.ComplexComponent;
import com.sun.webui.jsf.component.Field;
import com.sun.webui.jsf.component.HiddenField;
import com.sun.webui.jsf.component.Widget;
import com.sun.webui.jsf.theme.ThemeTemplates;
import com.sun.webui.jsf.util.ConversionUtilities;
import com.sun.webui.jsf.util.JavaScriptUtilities;
import com.sun.webui.jsf.util.MessageUtil;
import com.sun.webui.jsf.util.ThemeUtilities;
import com.sun.webui.theme.Theme;
import java.io.IOException;
import java.util.Map;
import javax.faces.FacesException;
import javax.faces.component.EditableValueHolder;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


/**
 * This class renders HiddenField component.
 */
@Renderer(@Renderer.Renders(
rendererType="com.sun.webui.jsf.widget.HiddenField",
        componentFamily="com.sun.webui.jsf.HiddenField"))
public class HiddenFieldRenderer extends RendererBase {
        
    private static final boolean DEBUG = false;
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // RendererBase methods
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    /**
     * Get the Dojo modules required to instantiate the widget.
     *
     * @param context FacesContext for the current request.
     * @param component UIComponent to be rendered.
     */
    protected JSONArray getModules(FacesContext context, UIComponent component)
        throws JSONException {
        JSONArray json = new JSONArray();
        json.put(JavaScriptUtilities.getModuleName("widget.hiddenField"));
        return json;
    }
    
    /**
     * Helper method to obtain component properties.
     *
     * @param context FacesContext for the current request.
     * @param component UIComponent to be rendered.
     */
    protected JSONObject getProperties(FacesContext context,
            UIComponent component) throws IOException, JSONException {
        HiddenField hiddenField = (HiddenField) component;
        
        if(!(component instanceof HiddenField)) {
            Object[] params = { component.toString(),
                    this.getClass().getName(),
                    HiddenField.class.getName() };
                    String message = MessageUtil.getMessage
                            ("com.sun.webui.jsf.resources.LogMessages", //NOI18N
                            "Renderer.component", params); //NOI18N
                    throw new FacesException(message);
        }
        
        // Record the value that is rendered.
        // Note that getValueAsString conforms to JSF conventions
        // for NULL values, in that it returns "" if the component
        // value is NULL. This value cannot be trusted since
        // the fidelity of the data must be preserved, i.e. if the
        // value is null, it must remain null if the component is unchanged
        // by the user..
        //
        // What should be done in the case of submittedValue != null ?
        // This call to getValue may not be value is used by
        // getValueAsString, it may use the submittedValue.
        // Then should the previously set rendered value be
        // preserved ?
        //
        // If submittedValue is not null then the component's
        // model value or local value has not been updated
        // therefore assume that this is an immediate or premature
        // render response. Therefore just assume that if the rendered
        // value was null, the saved information is still valid.
        //
        if (((HiddenField)component).getSubmittedValue() == null) {
            ConversionUtilities.setRenderedValue(component,
                ((HiddenField)component).getText());
        }
        
        String templatePath = ((Widget) hiddenField).getHtmlTemplate(); // Get HTML template.
        JSONObject json = new JSONObject();
        json.put("value", hiddenField.getValueAsString(context))
            .put("name", hiddenField.getClientId(context))
            .put("disabled", hiddenField.isDisabled())
            .put("templatePath", (templatePath != null)
                ? templatePath
                : getTheme().getPathToTemplate(ThemeTemplates.HIDDENFIELD));
                    
        // Add core and attribute properties.
        setCoreProperties(context, component, json);
        
        return json;
    }
    
    /**
     * Decode the component
     * @param context The FacesContext associated with this request
     */
    public void decode(FacesContext context, UIComponent component) {
        
        String id = component.getClientId(context);
        Map params = context.getExternalContext().getRequestParameterMap();
        Object valueObject = params.get(id);
        String value = null;
               
        if(valueObject != null) {
            value = (String) valueObject;
            if(DEBUG) log("Submitted value is " + value);
        
        } else if(DEBUG) log("\tNo relevant input parameter");
      
        ((EditableValueHolder)component).setSubmittedValue(value);
    }
        
    protected void log(String s) {
        System.out.println(s);
    }
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Private renderer methods
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Helper method to get Theme objects.
    private Theme getTheme() {
        return ThemeUtilities.getTheme(FacesContext.getCurrentInstance());
    }
}

Directory: /woodstock/webui/src/runtime/com/sun/webui/jsf/theme/
================================================================

File [changed]: ThemeTemplates.java
Url: https://woodstock.dev.java.net/source/browse/woodstock/webui/src/runtime/com/sun/webui/jsf/theme/ThemeTemplates.java?r1=1.4&r2=1.5
Delta lines: +5 -0
-------------------
--- ThemeTemplates.java 12 Mar 2007 08:53:53 -0000 1.4
+++ ThemeTemplates.java 22 Mar 2007 08:27:08 -0000 1.5
@@ -60,6 +60,11 @@
      * A template file that contains HTML for the staticText component.
      */
     public static final String STATICTEXT = "staticText";
+
+ /**
+ * A template file that contains HTML for the hiddenField component.
+ */
+ public static final String HIDDENFIELD = "hiddenField";
 
     /**
      * This private constructor prevents this class from being instantiated

Directory: /woodstock/webui/src/designtime/conf/
================================================

File [changed]: faces-config.xml
Url: https://woodstock.dev.java.net/source/browse/woodstock/webui/src/designtime/conf/faces-config.xml?r1=1.2&r2=1.3
Delta lines: +6 -0
-------------------
--- faces-config.xml 21 Mar 2007 12:49:55 -0000 1.2
+++ faces-config.xml 22 Mar 2007 08:27:08 -0000 1.3
@@ -116,6 +116,12 @@
     </renderer>
     
     <renderer>
+ <component-family>com.sun.webui.jsf.HiddenField</component-family>
+ <renderer-type>com.sun.webui.jsf.widget.HiddenFieldDesignTime</renderer-type>
+ <renderer-class>com.sun.webui.jsf.renderkit.html.HiddenFieldRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
       <component-family>com.sun.webui.jsf.Hyperlink</component-family>
       <renderer-type>com.sun.webui.jsf.HyperlinkDesignTime</renderer-type>
       <renderer-class>com.sun.webui.jsf.renderkit.html.HyperlinkDesignTimeRenderer</renderer-class>




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe_at_woodstock.dev.java.net
For additional commands, e-mail: cvs-help_at_woodstock.dev.java.net