dev@javaserverfaces.java.net

Re: Review: Fix for JSF RI 87 and state saving changes

From: Jayashri Visvanathan <Jayashri.Visvanathan_at_Sun.COM>
Date: Thu, 17 Mar 2005 09:40:17 -0800

Sorry about the diffs. Here it is.

Ed Burns wrote:

>>>>>>On Wed, 16 Mar 2005 17:16:34 -0800, Jayashri Visvanathan <Jayashri.Visvanathan_at_Sun.COM> said:
>>>>>>
>>>>>>
>
>JV> M conf/test/web.xml
>JV> Make the number of views to persist in session to be 20.
>
>JV> M src/com/sun/faces/application/StateManagerImpl.java
>JV> Complete changes for JSF Spec issue 11
>JV> - remove code related to high availability state saving since
>JV> state saving in server is now HA enabled by default.
>JV> - Allow LRUMap size to be configurable via ServletContextInitParameter.
>
>JV> M src/com/sun/faces/renderkit/html_basic/MenuRenderer.java
>JV> Fix for Issue 87: If UISelectone/UISelectMany component is disabled,
>JV> render
>JV> "disabled" on select tag and ignore any "disabled" attribute specified
>JV> on option tags.
>
>JV> M web/test/RenderResponse_correct
>JV> M web/test/TestRenderResponsePhase.jsp
>JV> updated test and golden files.
>
>Can you please re-send and include the diffs?
>
>Thanks,
>
>Ed
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
>For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>
>


Index: conf/test/web.xml
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/conf/test/web.xml,v
retrieving revision 1.21
diff -u -r1.21 web.xml
--- conf/test/web.xml 27 Apr 2004 17:25:02 -0000 1.21
+++ conf/test/web.xml 17 Mar 2005 01:01:18 -0000
@@ -22,7 +22,7 @@
     </context-param>
     <context-param>
         <param-name>com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
- <param-value>15</param-value>
+ <param-value>20</param-value>
     </context-param>
     <context-param>
         <param-name>minimumCustomerAge</param-name>
Index: src/com/sun/faces/application/StateManagerImpl.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/StateManagerImpl.java,v
retrieving revision 1.26
diff -u -r1.26 StateManagerImpl.java
--- src/com/sun/faces/application/StateManagerImpl.java 15 Mar 2005 20:37:37 -0000 1.26
+++ src/com/sun/faces/application/StateManagerImpl.java 17 Mar 2005 01:01:18 -0000
@@ -48,28 +48,11 @@
 
     private static final String FACES_VIEW_LIST =
         RIConstants.FACES_PREFIX + "VIEW_LIST";
-
- private static final String ENABLE_HA_PARAM = "enableHighAvailability";
-
- private static final String JSF_ENABLE_HA_PARAM =
- RIConstants.FACES_PREFIX + ENABLE_HA_PARAM;
-
- private static final String APPSERVER_ENABLE_HA_PARAM =
- "com.sun.appserver." + ENABLE_HA_PARAM;
-
-
     /**
      * Number of views to be saved in session.
      */
     int noOfViews = 0;
     
- /**
- * value of <code>com.sun.faces.enableHighAvailability</code>
- * <code>com.sun.appserver.enableHighAvailability</code>
- * parameter
- */
- private Boolean haStateSavingSet = null;
-
     public SerializedView saveSerializedView(FacesContext context)
         throws IllegalStateException{
         SerializedView result = null;
@@ -84,8 +67,7 @@
         
         // honor the transient property and remove children from the tree
         // that are marked transient.
- removeTransientChildrenAndFacets(context, viewRoot, new HashSet());
-
+ removeTransientChildrenAndFacets(context, viewRoot, new HashSet());
         
          if (log.isDebugEnabled()) {
              log.debug("Begin creating serialized view for " +
@@ -107,12 +89,10 @@
                  LRUMap lruMap = null;
                  Map sessionMap = Util.getSessionMap(context);
                 Object stateArray[] = { treeStructure, componentState };
-
+
                  if (null == (lruMap = (LRUMap)
- sessionMap.get(RIConstants.STATE_MAP))) {
- lruMap = new LRUMap(15); // PENDING(edburns):
- // configurable
-
+ sessionMap.get(RIConstants.STATE_MAP))) {
+ lruMap = new LRUMap(getNumberOfViewsParameter(context));
                      sessionMap.put(RIConstants.STATE_MAP, lruMap);
                  }
                 result = new SerializedView(id, null);
@@ -130,7 +110,6 @@
         if (requestIdSerial++ == Character.MAX_VALUE) {
             requestIdSerial = 0;
         }
-
         return UIViewRoot.UNIQUE_ID_PREFIX + ((int) requestIdSerial);
     }
 
@@ -225,8 +204,6 @@
             }
         } else {
             // restore tree from session.
- // if high available state saving option is chosen, restore
- // the SerializedView from session instead of UIViewRoot.
             Object id = ((Util.getResponseStateManager(context, renderKitId)).
                          getTreeStructureToRestore(context, viewId));
 
@@ -401,31 +378,6 @@
     }
     
     /**
- * Returns true one of <code>com.sun.faces.enableHighAvailability</code>
- * or <code>com.sun.appserver.enableHighAvailability</code>
- * servlet context parameter is set.
- */
- protected boolean isHAStateSavingSet(FacesContext context) {
- if (null != haStateSavingSet) {
- return haStateSavingSet.booleanValue();
- }
- haStateSavingSet = Boolean.FALSE;
-
- String haStateSavingParam = context.getExternalContext().
- getInitParameter(JSF_ENABLE_HA_PARAM);
- if (haStateSavingParam != null){
- haStateSavingSet = Boolean.valueOf(haStateSavingParam);
- } else {
- haStateSavingParam = context.getExternalContext().
- getInitParameter(APPSERVER_ENABLE_HA_PARAM);
- if (haStateSavingParam != null){
- haStateSavingSet = Boolean.valueOf(haStateSavingParam);
- }
- }
- return haStateSavingSet.booleanValue();
- }
-
- /**
      * Returns the <code> UIViewRoot</code> corresponding the
      * <code> viewId </code> by restoring the view structure and state.
      */
@@ -449,5 +401,31 @@
              viewRoot.processRestoreState(context, state);
         }
         return ((UIViewRoot)viewRoot);
+ }
+
+ /**
+ * Returns the value of ServletContextInitParameter that specifies the
+ * maximum number of views to be saved in session. If none is specified
+ * returns <code>DEFAULT_NUMBER_OF_VIEWS_IN_SESSION</code>.
+ */
+ protected int getNumberOfViewsParameter(FacesContext context) {
+ if (noOfViews != 0) {
+ return noOfViews;
+ }
+ noOfViews = DEFAULT_NUMBER_OF_VIEWS_IN_SESSION;
+ String noOfViewsStr = context.getExternalContext().
+ getInitParameter(NUMBER_OF_VIEWS_IN_SESSION);
+ if (noOfViewsStr != null) {
+ try {
+ noOfViews = Integer.valueOf(noOfViewsStr).intValue();
+ } catch (NumberFormatException nfe) {
+ if (log.isDebugEnabled()) {
+ log.debug("Error parsing the servetInitParameter " +
+ NUMBER_OF_VIEWS_IN_SESSION + ". Using default " +
+ noOfViews);
+ }
+ }
+ }
+ return noOfViews;
     }
 }
Index: src/com/sun/faces/renderkit/html_basic/MenuRenderer.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/MenuRenderer.java,v
retrieving revision 1.54
diff -u -r1.54 MenuRenderer.java
--- src/com/sun/faces/renderkit/html_basic/MenuRenderer.java 16 Dec 2004 17:56:37 -0000 1.54
+++ src/com/sun/faces/renderkit/html_basic/MenuRenderer.java 17 Mar 2005 01:01:19 -0000
@@ -475,10 +475,7 @@
         }
 
         Util.renderPassThruAttributes(context, writer, component);
- // don't render disabled here, because it is dealt with in a
- // special fashin further down the callstack.
- Util.renderBooleanPassThruAttributes(writer, component,
- new String [] {"disabled"});
+ Util.renderBooleanPassThruAttributes(writer, component);
 
         // Now, render the "options" portion...
         renderOptions(context, component);
@@ -514,10 +511,11 @@
         while (items.hasNext()) {
             curItem = (SelectItem) items.next();
             if (curItem instanceof SelectItemGroup) {
-// render OPTGROUP
+ // render OPTGROUP
                 writer.startElement("optgroup", component);
                 writer.writeAttribute("label", curItem.getLabel(), "label");
-// render options of this group.
+
+ // render options of this group.
                 SelectItem[] itemsArray =
                     ((SelectItemGroup) curItem).getSelectItems();
                 for (int i = 0; i < itemsArray.length; ++i) {
@@ -557,9 +555,6 @@
         if (isSelected) {
             writer.writeAttribute("selected", "selected", "selected");
         }
- if (curItem.isDisabled()) {
- writer.writeAttribute("disabled", "disabled", "disabled");
- }
 
         String labelClass = null;
         Boolean disabledAttr = (Boolean)component.getAttributes().get("disabled") ;
@@ -569,6 +564,13 @@
                 componentDisabled = true;
             }
         }
+
+ // if the component is disabled, "disabled" attribute would be rendered
+ // on "select" tag, so don't render "disabled" on every option.
+ if ((!componentDisabled) && curItem.isDisabled()) {
+ writer.writeAttribute("disabled", "disabled", "disabled");
+ }
+
         if (componentDisabled || curItem.isDisabled()) {
             labelClass = (String) component.
                 getAttributes().get("disabledClass");
Index: web/test/RenderResponse_correct
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/RenderResponse_correct,v
retrieving revision 1.119
diff -u -r1.119 RenderResponse_correct
--- web/test/RenderResponse_correct 15 Mar 2005 20:37:41 -0000 1.119
+++ web/test/RenderResponse_correct 17 Mar 2005 01:01:19 -0000
@@ -15,7 +15,7 @@
 
 
   
-<form id="basicForm" method="post" action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" class="formClass" accept-charset="some-charset" accept="html,wml" enctype="application/x-www-form-urlencoded" target="_self" title="basicForm">
+<form id="basicForm" method="post" action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=95F83ADE9D04C306D880389D1992A343" class="formClass" accept-charset="some-charset" accept="html,wml" enctype="application/x-www-form-urlencoded" target="_self" title="basicForm">
 
 
   <TABLE BORDER="1">
@@ -130,12 +130,12 @@
 
               
                 
- <a id="basicForm:imageLink" href="#" style="someStyle" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:imageLink'; document.forms['basicForm'].submit(); return false;"><img src="duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" /></a>
+ <a id="basicForm:imageLink" href="#" style="someStyle" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:imageLink'; document.forms['basicForm'].submit(); return false;"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
 
         </TD>
 
         <TD>
- <img id="basicForm:graphicImage" src="/test/duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" style="someStyle" usemap="#map1" ismap="ismap" />
+ <img id="basicForm:graphicImage" src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" style="someStyle" usemap="#map1" ismap="ismap" />
         </TD>
 
       </TR>
@@ -169,7 +169,7 @@
               
               
               
- <a id="basicForm:hrefParamLink" href="#" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:hrefParamLink';document.forms['basicForm']['name'].value='horwat';document.forms['basicForm']['value'].value='password'; document.forms['basicForm'].target='_top'; document.forms['basicForm'].submit(); return false;"><img src="duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" /></a>
+ <a id="basicForm:hrefParamLink" href="#" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:hrefParamLink';document.forms['basicForm']['name'].value='horwat';document.forms['basicForm']['value'].value='password'; document.forms['basicForm'].target='_top'; document.forms['basicForm'].submit(); return false;"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
         </TD>
       </TR>
 
@@ -177,7 +177,7 @@
 
         <TD>
 
- <a id="basicForm:outputLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" class="hyperlinkClass">output link text</a>
+ <a id="basicForm:outputLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" class="hyperlinkClass">output link text</a>
 
         </TD>
 
@@ -189,12 +189,12 @@
 
               
                 
- <a id="basicForm:output_imageLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" style="position: absolute; left: 96px; top: 168px"><img src="duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" /></a>
+ <a id="basicForm:output_imageLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position: absolute; left: 96px; top: 168px"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
 
         </TD>
 
         <TD>
- <img id="basicForm:output_graphicImage" src="/test/duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" usemap="#map1" ismap="ismap" />
+ <img id="basicForm:output_graphicImage" src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" usemap="#map1" ismap="ismap" />
         </TD>
 
       </TR>
@@ -202,7 +202,7 @@
       <TR>
         <TD>
             
- <a id="basicForm:output_commandLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" style="position: absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a>
+ <a id="basicForm:output_commandLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position: absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a>
        </TD>
       </TR>
 
@@ -212,13 +212,13 @@
               
               
               
- <a id="basicForm:output_commandParamLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658?name=horwat&value=password" class="hyperlinkClass">link text</a>
+ <a id="basicForm:output_commandParamLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password" class="hyperlinkClass">link text</a>
         </TD>
       </TR>
 
       <TR>
         <TD>
- <a id="basicForm:output_hrefLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658"><img src="duke.gif"></a>
+ <a id="basicForm:output_hrefLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343"><img src="duke.gif"></a>
         </TD>
       </TR>
 
@@ -228,7 +228,7 @@
               
               
               
- <a id="basicForm:output_hrefParamLink" href="test.html;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658?name=horwat&value=password"><img src="duke.gif;jsessionid=4877F2CAACEB09E82BF724E3EDC8C658" /></a>
+ <a id="basicForm:output_hrefParamLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
         </TD>
       </TR>
 
@@ -374,16 +374,16 @@
                 
                 
 
- <select name="basicForm:_id25" class="selectoneClass" size="1" style="someStyle" tabindex="20" title="Select Quantity"> <option value="0" disabled="disabled" class="dclass">0</option>
- <option value="1" class="eclass">1</option>
- <option value="2" class="eclass">2</option>
- <option value="3" disabled="disabled" class="dclass">3</option>
- <option value="4" class="eclass">4</option>
- <option value="5" class="eclass">5</option>
- <option value="6" class="eclass">6</option>
- <option value="7" class="eclass">7</option>
- <option value="8" class="eclass">8</option>
- <option value="9" class="eclass">9</option>
+ <select name="basicForm:_id25" class="selectoneClass" size="1" style="someStyle" tabindex="20" title="Select Quantity" disabled="disabled"> <option value="0" class="dclass">0</option>
+ <option value="1" class="dclass">1</option>
+ <option value="2" class="dclass">2</option>
+ <option value="3" class="dclass">3</option>
+ <option value="4" class="dclass">4</option>
+ <option value="5" class="dclass">5</option>
+ <option value="6" class="dclass">6</option>
+ <option value="7" class="dclass">7</option>
+ <option value="8" class="dclass">8</option>
+ <option value="9" class="dclass">9</option>
 </select>
 
         </TD>
@@ -427,15 +427,15 @@
            <table border="1" id="basicForm:verticalRadio">
         <tr>
 <td>
-<label><input type="radio" name="basicForm:verticalRadio" value="nextDay" disabled="disabled"> Next Day</input></label></td>
+<label><input type="radio" name="basicForm:verticalRadio" value="nextDay" disabled="disabled" disabled="disabled"> Next Day</input></label></td>
         </tr>
         <tr>
 <td>
-<label><input type="radio" name="basicForm:verticalRadio" value="nextWeek"> Next Week</input></label></td>
+<label><input type="radio" name="basicForm:verticalRadio" value="nextWeek" disabled="disabled"> Next Week</input></label></td>
         </tr>
         <tr>
 <td>
-<label><input type="radio" name="basicForm:verticalRadio" value="nextMonth"> Next Month</input></label></td>
+<label><input type="radio" name="basicForm:verticalRadio" value="nextMonth" disabled="disabled"> Next Month</input></label></td>
         </tr>
 </table>
 
@@ -652,16 +652,16 @@
                                                 
                                                 
                                                 
- <select name="basicForm:_id54" multiple="multiple" size="10" style="someStyle"> <option value="0" class="eclass">zero</option>
- <option value="1" class="eclass">one</option>
- <option value="2" class="eclass">two</option>
- <option value="3" disabled="disabled" class="dclass">three</option>
- <option value="4" class="eclass">four</option>
- <option value="5" class="eclass">five</option>
- <option value="6" class="eclass">six</option>
- <option value="7" class="eclass">seven</option>
- <option value="8" class="eclass">eight</option>
- <option value="9" class="eclass">nine</option>
+ <select name="basicForm:_id54" multiple="multiple" size="10" style="someStyle" disabled="disabled"> <option value="0" class="dclass">zero</option>
+ <option value="1" class="dclass">one</option>
+ <option value="2" class="dclass">two</option>
+ <option value="3" class="dclass">three</option>
+ <option value="4" class="dclass">four</option>
+ <option value="5" class="dclass">five</option>
+ <option value="6" class="dclass">six</option>
+ <option value="7" class="dclass">seven</option>
+ <option value="8" class="dclass">eight</option>
+ <option value="9" class="dclass">nine</option>
 </select></TD>
 </tr>
 
Index: web/test/TestRenderResponsePhase.jsp
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/TestRenderResponsePhase.jsp,v
retrieving revision 1.87
diff -u -r1.87 TestRenderResponsePhase.jsp
--- web/test/TestRenderResponsePhase.jsp 22 Feb 2005 15:56:18 -0000 1.87
+++ web/test/TestRenderResponsePhase.jsp 17 Mar 2005 01:01:19 -0000
@@ -345,7 +345,7 @@
 
         <TD>
 
- <h:selectOneMenu styleClass="selectoneClass"
+ <h:selectOneMenu styleClass="selectoneClass" disabled="true"
                      title="Select Quantity" style="someStyle"
                      tabindex="20" enabledClass="eclass" disabledClass="dclass">
 
@@ -388,7 +388,7 @@
       <TR>
 
         <TD>
- <h:selectOneRadio id="verticalRadio"
+ <h:selectOneRadio id="verticalRadio" disabled="true"
                                             layout="pageDirection" border="1" >
 
                 <f:selectItem itemValue="nextDay" itemLabel="Next Day"
@@ -620,7 +620,7 @@
 <tr>
                                         <TD>Multi-select listbox:</TD>
                                         <TD><h:selectManyListbox style="someStyle" enabledClass="eclass"
- disabledClass="dclass">
+ disabledClass="dclass" disabled="true">
                                                 <f:selectItem itemValue="0" itemLabel="zero" />
                                                 <f:selectItem itemValue="1" itemLabel="one" />
                                                 <f:selectItem itemValue="2" itemLabel="two" />