dev@javaserverfaces.java.net

[REVIEW] Ensure correct rendering for 'multiple' and 'selected' attributes

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Thu, 27 Oct 2005 09:34:42 +0800

Tweak MenuRenderer so that the HtmlResponseWriter takes
appropriate action when writing the multiple and selected attributes
based on the content-type.


SECTION: Modified Files
----------------------------
M src/com/sun/faces/renderkit/html_basic/MenuRenderer.java
  - pass a boolean for the attribute value. This will cause
    the writer to write the attribute using minimization
    or xhtml-style

M web/test/CorrectRenderersResponse_2
M web/test/CorrectRenderersResponse_3
M web/test/RenderResponse_correct
M web/test/TestRenderersFromJsp_correct
  - Correct the tests


SECTION: Diffs
----------------------------
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.63
diff -u -r1.63 MenuRenderer.java
--- src/com/sun/faces/renderkit/html_basic/MenuRenderer.java 18 Oct
2005 00:27:05 -0000 1.63
+++ src/com/sun/faces/renderkit/html_basic/MenuRenderer.java 27 Oct
2005 16:28:58 -0000
@@ -470,7 +470,7 @@
             writer.writeAttribute("class", styleClass, "styleClass");
         }
         if (!getMultipleText(component).equals("")) {
- writer.writeAttribute("multiple", "multiple", "multiple");
+ writer.writeAttribute("multiple", true, "multiple");
         }
 
         // Determine how many option(s) we need to render, and update
@@ -584,7 +584,7 @@
         isSelected = isSelected(newValue, valuesArray);
 
         if (isSelected) {
- writer.writeAttribute("selected", "selected", "selected");
+ writer.writeAttribute("selected", true, "selected");
         }
 
     String labelClass = null;
Index: web/test/CorrectRenderersResponse_2
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/web/test/CorrectRenderersResponse_2,v
retrieving revision 1.38
diff -u -r1.38 CorrectRenderersResponse_2
--- web/test/CorrectRenderersResponse_2 18 Oct 2005 00:27:08 -0000
 1.38
+++ web/test/CorrectRenderersResponse_2 27 Oct 2005 16:28:59 -0000
@@ -1,7 +1,7 @@
 <input id="myCheckbox" type="checkbox" name="myCheckbox" checked />
 <input id="myCheckbox" type="checkbox" name="myCheckbox" />
 <input id="myCheckbox" type="checkbox" name="myCheckbox" />
-<select id="myListbox" name="myListbox" size="4"> <option
value="100" selected="selected">Long1</option>
+<select id="myListbox" name="myListbox" size="4"> <option
value="100" selected>Long1</option>
     <option value="101">Long2</option>
     <option value="102">Long3</option>
     <option value="103">Long4</option>
Index: web/test/CorrectRenderersResponse_3
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/web/test/CorrectRenderersResponse_3,v
retrieving revision 1.30
diff -u -r1.30 CorrectRenderersResponse_3
--- web/test/CorrectRenderersResponse_3 18 Oct 2005 00:27:08 -0000
 1.30
+++ web/test/CorrectRenderersResponse_3 27 Oct 2005 16:28:59 -0000
@@ -1,10 +1,10 @@
-<select id="myMenu" name="myMenu" multiple="multiple" size="1">
 <option value="Red">Red</option>
- <option value="Blue" selected="selected">Blue</option>
+<select id="myMenu" name="myMenu" multiple size="1"> <option
value="Red">Red</option>
+ <option value="Blue" selected>Blue</option>
     <option value="Green">Green</option>
     <option value="Yellow">Yellow</option>
 </select>
-<select id="myListbox" name="myListbox" multiple="multiple" size="5">
 <option value="Red">Red</option>
- <option value="Blue" selected="selected">Blue</option>
+<select id="myListbox" name="myListbox" multiple size="5"> <option
value="Red">Red</option>
+ <option value="Blue" selected>Blue</option>
 <optgroup label="group"> <option value="Green">Green</option>
     <option value="Yellow">Yellow</option>
 </optgroup></select>
@@ -25,7 +25,7 @@
 </table></td> </tr>
 </table>
 <select id="myOnemenu" name="myOnemenu" size="1"> <option
value="Red">Red</option>
- <option value="Blue" selected="selected">Blue</option>
+ <option value="Blue" selected>Blue</option>
     <option value="Green">Green</option>
     <option value="Yellow">Yellow</option>
 </select>
Index: web/test/RenderResponse_correct
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/web/test/RenderResponse_correct,v
retrieving revision 1.135
diff -u -r1.135 RenderResponse_correct
--- web/test/RenderResponse_correct 19 Oct 2005 19:51:41 -0000 1.135
+++ web/test/RenderResponse_correct 27 Oct 2005 16:28:59 -0000
@@ -485,7 +485,7 @@
 
 <tr>
                     <TD>Multi-select menu:</TD>
- <TD><select id="basicForm:ManyApples"
name="basicForm:ManyApples" class="selectmanyClass" multiple="multiple"
size="1" style="someStyle"> <option value="0"
class="eclass">zero</option>
+ <TD><select id="basicForm:ManyApples"
name="basicForm:ManyApples" class="selectmanyClass" multiple size="1"
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" class="eclass">three</option>
@@ -501,7 +501,7 @@
 
 <tr>
                     <TD>Multi-select listbox:</TD>
- <TD><select name="basicForm:_id_id555"
multiple="multiple" size="10" style="someStyle"> <option value="0"
class="dclass">zero</option>
+ <TD><select name="basicForm:_id_id555" multiple
size="10" style="someStyle"> <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>
Index: web/test/TestRenderersFromJsp_correct
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/web/test/TestRenderersFromJsp_correct,v
retrieving revision 1.3
diff -u -r1.3 TestRenderersFromJsp_correct
--- web/test/TestRenderersFromJsp_correct 5 Feb 2004 05:05:34 -0000
 1.3
+++ web/test/TestRenderersFromJsp_correct 27 Oct 2005 16:28:59 -0000
@@ -21,7 +21,7 @@
 
             <INPUT TYPE="CHECKBOX" NAME="/basicForm/validUser"> Checker
 
- <SELECT NAME="/basicForm/appleQuantity"><OPTION
VALUE="0">0.00</OPTION><OPTION VALUE="1">1.00</OPTION><OPTION
VALUE="2">2.00</OPTION><OPTION VALUE="3">3.00</OPTION><OPTION VALUE="4"
selected="selected">4.00</OPTION><OPTION VALUE="5">5.00</OPTION><OPTION
VALUE="6">6.00</OPTION><OPTION VALUE="7">7.00</OPTION><OPTION
VALUE="8">8.00</OPTION><OPTION VALUE="9">9.00</OPTION></SELECT>
+ <SELECT NAME="/basicForm/appleQuantity"><OPTION
VALUE="0">0.00</OPTION><OPTION VALUE="1">1.00</OPTION><OPTION
VALUE="2">2.00</OPTION><OPTION VALUE="3">3.00</OPTION><OPTION VALUE="4"
selected>4.00</OPTION><OPTION VALUE="5">5.00</OPTION><OPTION
VALUE="6">6.00</OPTION><OPTION VALUE="7">7.00</OPTION><OPTION
VALUE="8">8.00</OPTION><OPTION VALUE="9">9.00</OPTION></SELECT>
 
             <INPUT TYPE="RADIO" NAME="/basicForm/shipType"
VALUE="nextDay"> Next Day
 <INPUT TYPE="RADIO" CHECKED NAME="/basicForm/shipType"
VALUE="nextWeek"> Next Week