Coverage Report - javax.faces.component.html.HtmlSelectManyCheckbox
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlSelectManyCheckbox
96%
254/264
90%
77/86
2.133
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package javax.faces.component.html;
 17  
 
 18  
 import javax.faces.component.ComponentUtil_;
 19  
 import javax.faces.component.UISelectMany;
 20  
 import javax.faces.context.FacesContext;
 21  
 import javax.faces.el.ValueBinding;
 22  
 import javax.faces.event.ValueChangeEvent;
 23  
 import javax.faces.internal.FacesMessageUtil;
 24  
 import javax.faces.internal.UIComponentUtil;
 25  
 
 26  
 import org.seasar.teeda.core.JsfConstants;
 27  
 import org.seasar.teeda.core.util.PostbackUtil;
 28  
 import org.seasar.teeda.core.util.RendererUtil;
 29  
 import org.seasar.teeda.core.util.UIValueUtil;
 30  
 
 31  
 /**
 32  
  * @author shot
 33  
  */
 34  
 public class HtmlSelectManyCheckbox extends UISelectMany {
 35  
 
 36  
     public static final String COMPONENT_TYPE = "javax.faces.HtmlSelectManyCheckbox";
 37  
 
 38  
     private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Checkbox";
 39  
 
 40  
     private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
 41  
 
 42  
     private static final boolean DEFAULT_DISABLED = false;
 43  
 
 44  
     private static final boolean DEFAULT_READONLY = false;
 45  
 
 46  207
     private String accesskey = null;
 47  
 
 48  207
     private Integer border = null;
 49  
 
 50  207
     private String dir = null;
 51  
 
 52  207
     private Boolean disabled = null;
 53  
 
 54  207
     private String disabledClass = null;
 55  
 
 56  207
     private String enabledClass = null;
 57  
 
 58  207
     private String lang = null;
 59  
 
 60  207
     private String layout = null;
 61  
 
 62  207
     private String onblur = null;
 63  
 
 64  207
     private String onchange = null;
 65  
 
 66  207
     private String onclick = null;
 67  
 
 68  207
     private String ondblclick = null;
 69  
 
 70  207
     private String onfocus = null;
 71  
 
 72  207
     private String onkeydown = null;
 73  
 
 74  207
     private String onkeypress = null;
 75  
 
 76  207
     private String onkeyup = null;
 77  
 
 78  207
     private String onmousedown = null;
 79  
 
 80  207
     private String onmousemove = null;
 81  
 
 82  207
     private String onmouseout = null;
 83  
 
 84  207
     private String onmouseover = null;
 85  
 
 86  207
     private String onmouseup = null;
 87  
 
 88  207
     private String onselect = null;
 89  
 
 90  207
     private Boolean readonly = null;
 91  
 
 92  207
     private String style = null;
 93  
 
 94  207
     private String styleClass = null;
 95  
 
 96  207
     private String tabindex = null;
 97  
 
 98  207
     private String title = null;
 99  
 
 100  207
     private String label = null;
 101  
 
 102  
     public HtmlSelectManyCheckbox() {
 103  207
         super();
 104  207
         setRendererType(DEFAULT_RENDERER_TYPE);
 105  207
     }
 106  
 
 107  
     public void setAccesskey(String accesskey) {
 108  3
         this.accesskey = accesskey;
 109  3
     }
 110  
 
 111  
     public String getAccesskey() {
 112  27
         if (accesskey != null) {
 113  3
             return accesskey;
 114  
         }
 115  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 116  
                 JsfConstants.ACCESSKEY_ATTR);
 117  
     }
 118  
 
 119  
     public void setBorder(int border) {
 120  4
         this.border = new Integer(border);
 121  4
     }
 122  
 
 123  
     public int getBorder() {
 124  16
         if (border != null) {
 125  3
             return border.intValue();
 126  
         }
 127  13
         ValueBinding vb = getValueBinding("border");
 128  13
         Integer v = vb != null ? (Integer) vb.getValue(getFacesContext())
 129  
                 : null;
 130  13
         return v != null ? v.intValue() : DEFAULT_BORDER;
 131  
     }
 132  
 
 133  
     public void setDir(String dir) {
 134  3
         this.dir = dir;
 135  3
     }
 136  
 
 137  
     public String getDir() {
 138  27
         if (dir != null) {
 139  3
             return dir;
 140  
         }
 141  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 142  
                 JsfConstants.DIR_ATTR);
 143  
     }
 144  
 
 145  
     public void setDisabled(boolean disabled) {
 146  4
         this.disabled = Boolean.valueOf(disabled);
 147  4
     }
 148  
 
 149  
     public boolean isDisabled() {
 150  27
         if (disabled != null) {
 151  5
             return disabled.booleanValue();
 152  
         }
 153  22
         ValueBinding vb = getValueBinding("disabled");
 154  22
         Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
 155  
                 : null;
 156  22
         return v != null ? v.booleanValue() : DEFAULT_DISABLED;
 157  
     }
 158  
 
 159  
     public void setDisabledClass(String disabledClass) {
 160  5
         this.disabledClass = disabledClass;
 161  5
     }
 162  
 
 163  
     public String getDisabledClass() {
 164  10
         if (disabledClass != null) {
 165  4
             return disabledClass;
 166  
         }
 167  6
         return ComponentUtil_.getValueBindingValueAsString(this,
 168  
                 JsfConstants.DISABLED_CLASS_ATTR);
 169  
     }
 170  
 
 171  
     public void setEnabledClass(String enabledClass) {
 172  5
         this.enabledClass = enabledClass;
 173  5
     }
 174  
 
 175  
     public String getEnabledClass() {
 176  20
         if (enabledClass != null) {
 177  3
             return enabledClass;
 178  
         }
 179  17
         return ComponentUtil_.getValueBindingValueAsString(this,
 180  
                 JsfConstants.ENABLED_CLASS_ATTR);
 181  
     }
 182  
 
 183  
     public void setLang(String lang) {
 184  3
         this.lang = lang;
 185  3
     }
 186  
 
 187  
     public String getLang() {
 188  27
         if (lang != null) {
 189  3
             return lang;
 190  
         }
 191  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 192  
                 JsfConstants.LANG_ATTR);
 193  
     }
 194  
 
 195  
     public void setLayout(String layout) {
 196  5
         this.layout = layout;
 197  5
     }
 198  
 
 199  
     public String getLayout() {
 200  33
         if (layout != null) {
 201  8
             return layout;
 202  
         }
 203  25
         return ComponentUtil_.getValueBindingValueAsString(this,
 204  
                 JsfConstants.LAYOUT_ATTR);
 205  
     }
 206  
 
 207  
     public void setOnblur(String onblur) {
 208  3
         this.onblur = onblur;
 209  3
     }
 210  
 
 211  
     public String getOnblur() {
 212  27
         if (onblur != null) {
 213  3
             return onblur;
 214  
         }
 215  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 216  
                 JsfConstants.ONBLUR_ATTR);
 217  
     }
 218  
 
 219  
     public void setOnchange(String onchange) {
 220  4
         this.onchange = onchange;
 221  4
     }
 222  
 
 223  
     public String getOnchange() {
 224  27
         if (onchange != null) {
 225  3
             return onchange;
 226  
         }
 227  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 228  
                 JsfConstants.ONCHANGE_ATTR);
 229  
     }
 230  
 
 231  
     public void setOnclick(String onclick) {
 232  3
         this.onclick = onclick;
 233  3
     }
 234  
 
 235  
     public String getOnclick() {
 236  27
         if (onclick != null) {
 237  3
             return onclick;
 238  
         }
 239  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 240  
                 JsfConstants.ONCLICK_ATTR);
 241  
     }
 242  
 
 243  
     public void setOndblclick(String ondblclick) {
 244  3
         this.ondblclick = ondblclick;
 245  3
     }
 246  
 
 247  
     public String getOndblclick() {
 248  27
         if (ondblclick != null) {
 249  3
             return ondblclick;
 250  
         }
 251  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 252  
                 JsfConstants.ONDBLCLICK_ATTR);
 253  
     }
 254  
 
 255  
     public void setOnfocus(String onfocus) {
 256  3
         this.onfocus = onfocus;
 257  3
     }
 258  
 
 259  
     public String getOnfocus() {
 260  27
         if (onfocus != null) {
 261  3
             return onfocus;
 262  
         }
 263  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 264  
                 JsfConstants.ONFOCUS_ATTR);
 265  
     }
 266  
 
 267  
     public void setOnkeydown(String onkeydown) {
 268  3
         this.onkeydown = onkeydown;
 269  3
     }
 270  
 
 271  
     public String getOnkeydown() {
 272  27
         if (onkeydown != null) {
 273  3
             return onkeydown;
 274  
         }
 275  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 276  
                 JsfConstants.ONKEYDOWN_ATTR);
 277  
     }
 278  
 
 279  
     public void setOnkeypress(String onkeypress) {
 280  3
         this.onkeypress = onkeypress;
 281  3
     }
 282  
 
 283  
     public String getOnkeypress() {
 284  27
         if (onkeypress != null) {
 285  3
             return onkeypress;
 286  
         }
 287  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 288  
                 JsfConstants.ONKEYPRESS_ATTR);
 289  
     }
 290  
 
 291  
     public void setOnkeyup(String onkeyup) {
 292  3
         this.onkeyup = onkeyup;
 293  3
     }
 294  
 
 295  
     public String getOnkeyup() {
 296  27
         if (onkeyup != null) {
 297  3
             return onkeyup;
 298  
         }
 299  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 300  
                 JsfConstants.ONKEYUP_ATTR);
 301  
     }
 302  
 
 303  
     public void setOnmousedown(String onmousedown) {
 304  3
         this.onmousedown = onmousedown;
 305  3
     }
 306  
 
 307  
     public String getOnmousedown() {
 308  27
         if (onmousedown != null) {
 309  3
             return onmousedown;
 310  
         }
 311  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 312  
                 JsfConstants.ONMOUSEDOWN_ATTR);
 313  
     }
 314  
 
 315  
     public void setOnmousemove(String onmousemove) {
 316  3
         this.onmousemove = onmousemove;
 317  3
     }
 318  
 
 319  
     public String getOnmousemove() {
 320  27
         if (onmousemove != null) {
 321  3
             return onmousemove;
 322  
         }
 323  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 324  
                 JsfConstants.ONMOUSEMOVE_ATTR);
 325  
     }
 326  
 
 327  
     public void setOnmouseout(String onmouseout) {
 328  3
         this.onmouseout = onmouseout;
 329  3
     }
 330  
 
 331  
     public String getOnmouseout() {
 332  27
         if (onmouseout != null) {
 333  3
             return onmouseout;
 334  
         }
 335  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 336  
                 JsfConstants.ONMOUSEOUT_ATTR);
 337  
     }
 338  
 
 339  
     public void setOnmouseover(String onmouseover) {
 340  3
         this.onmouseover = onmouseover;
 341  3
     }
 342  
 
 343  
     public String getOnmouseover() {
 344  27
         if (onmouseover != null) {
 345  3
             return onmouseover;
 346  
         }
 347  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 348  
                 JsfConstants.ONMOUSEOVER_ATTR);
 349  
     }
 350  
 
 351  
     public void setOnmouseup(String onmouseup) {
 352  3
         this.onmouseup = onmouseup;
 353  3
     }
 354  
 
 355  
     public String getOnmouseup() {
 356  27
         if (onmouseup != null) {
 357  3
             return onmouseup;
 358  
         }
 359  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 360  
                 JsfConstants.ONMOUSEUP_ATTR);
 361  
     }
 362  
 
 363  
     public void setOnselect(String onselect) {
 364  4
         this.onselect = onselect;
 365  4
     }
 366  
 
 367  
     public String getOnselect() {
 368  27
         if (onselect != null) {
 369  3
             return onselect;
 370  
         }
 371  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 372  
                 JsfConstants.ONSELECT_ATTR);
 373  
     }
 374  
 
 375  
     public void setReadonly(boolean readonly) {
 376  4
         this.readonly = Boolean.valueOf(readonly);
 377  4
     }
 378  
 
 379  
     public boolean isReadonly() {
 380  27
         if (readonly != null) {
 381  3
             return readonly.booleanValue();
 382  
         }
 383  24
         ValueBinding vb = getValueBinding("readonly");
 384  24
         Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
 385  
                 : null;
 386  24
         return v != null ? v.booleanValue() : DEFAULT_READONLY;
 387  
     }
 388  
 
 389  
     public void setStyle(String style) {
 390  3
         this.style = style;
 391  3
     }
 392  
 
 393  
     public String getStyle() {
 394  16
         if (style != null) {
 395  3
             return style;
 396  
         }
 397  13
         return ComponentUtil_.getValueBindingValueAsString(this,
 398  
                 JsfConstants.STYLE_ATTR);
 399  
     }
 400  
 
 401  
     public void setStyleClass(String styleClass) {
 402  3
         this.styleClass = styleClass;
 403  3
     }
 404  
 
 405  
     public String getStyleClass() {
 406  16
         if (styleClass != null) {
 407  3
             return styleClass;
 408  
         }
 409  13
         return ComponentUtil_.getValueBindingValueAsString(this,
 410  
                 JsfConstants.STYLE_CLASS_ATTR);
 411  
     }
 412  
 
 413  
     public void setTabindex(String tabindex) {
 414  3
         this.tabindex = tabindex;
 415  3
     }
 416  
 
 417  
     public String getTabindex() {
 418  27
         if (tabindex != null) {
 419  3
             return tabindex;
 420  
         }
 421  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 422  
                 JsfConstants.TABINDEX_ATTR);
 423  
     }
 424  
 
 425  
     public void setTitle(String title) {
 426  3
         this.title = title;
 427  3
     }
 428  
 
 429  
     public String getTitle() {
 430  27
         if (title != null) {
 431  3
             return title;
 432  
         }
 433  24
         return ComponentUtil_.getValueBindingValueAsString(this,
 434  
                 JsfConstants.TITLE_ATTR);
 435  
     }
 436  
 
 437  
     public void setLabel(String label) {
 438  2
         this.label = label;
 439  2
     }
 440  
 
 441  
     public String getLabel() {
 442  28
         if (label != null) {
 443  2
             return label;
 444  
         }
 445  26
         return ComponentUtil_.getValueBindingValueAsString(this,
 446  
                 JsfConstants.LABEL_ATTR);
 447  
     }
 448  
 
 449  
     public void validate(FacesContext context) {
 450  2
         Object submittedValue = getSubmittedValue();
 451  2
         if ("".equals(submittedValue)) {
 452  1
             submittedValue = new String[0];
 453  
         }
 454  2
         Object convertedValue = RendererUtil.getConvertedValue(context, this,
 455  
                 submittedValue);
 456  2
         if (!isValid()) {
 457  0
             return;
 458  
         }
 459  2
         boolean empty = UIValueUtil.isManyEmpty(convertedValue);
 460  2
         if (isRequired() && empty) {
 461  1
             context.addMessage(getClientId(context), FacesMessageUtil
 462  
                     .getMessage(context, REQUIRED_MESSAGE_ID,
 463  
                             new Object[] { getLabel() }));
 464  1
             setValid(false);
 465  1
             return;
 466  
         }
 467  1
         if (!empty) {
 468  0
             UIComponentUtil.callValidators(context, this, convertedValue);
 469  
         }
 470  1
         if (PostbackUtil.isPostback(context.getExternalContext()
 471  
                 .getRequestMap())) {
 472  1
             validateForExtension(context, convertedValue);
 473  
         }
 474  1
         if (!isValid()) {
 475  1
             return;
 476  
         }
 477  0
         if (isDisabled()) {
 478  0
             return;
 479  
         }
 480  0
         Object previousValue = getValue();
 481  0
         setValue(convertedValue);
 482  0
         setSubmittedValue(null);
 483  0
         if (compareValues(previousValue, convertedValue)) {
 484  0
             queueEvent(new ValueChangeEvent(this, previousValue, convertedValue));
 485  
         }
 486  0
     }
 487  
 
 488  
     public Object saveState(FacesContext context) {
 489  5
         Object values[] = new Object[29];
 490  5
         values[0] = super.saveState(context);
 491  5
         values[1] = accesskey;
 492  5
         values[2] = border;
 493  5
         values[3] = dir;
 494  5
         values[4] = disabled;
 495  5
         values[5] = disabledClass;
 496  5
         values[6] = enabledClass;
 497  5
         values[7] = lang;
 498  5
         values[8] = layout;
 499  5
         values[9] = onblur;
 500  5
         values[10] = onchange;
 501  5
         values[11] = onclick;
 502  5
         values[12] = ondblclick;
 503  5
         values[13] = onfocus;
 504  5
         values[14] = onkeydown;
 505  5
         values[15] = onkeypress;
 506  5
         values[16] = onkeyup;
 507  5
         values[17] = onmousedown;
 508  5
         values[18] = onmousemove;
 509  5
         values[19] = onmouseout;
 510  5
         values[20] = onmouseover;
 511  5
         values[21] = onmouseup;
 512  5
         values[22] = onselect;
 513  5
         values[23] = readonly;
 514  5
         values[24] = style;
 515  5
         values[25] = styleClass;
 516  5
         values[26] = tabindex;
 517  5
         values[27] = title;
 518  5
         values[28] = label;
 519  5
         return ((Object) (values));
 520  
     }
 521  
 
 522  
     public void restoreState(FacesContext context, Object state) {
 523  4
         Object values[] = (Object[]) state;
 524  4
         super.restoreState(context, values[0]);
 525  4
         accesskey = (String) values[1];
 526  4
         border = (Integer) values[2];
 527  4
         dir = (String) values[3];
 528  4
         disabled = (Boolean) values[4];
 529  4
         disabledClass = (String) values[5];
 530  4
         enabledClass = (String) values[6];
 531  4
         lang = (String) values[7];
 532  4
         layout = (String) values[8];
 533  4
         onblur = (String) values[9];
 534  4
         onchange = (String) values[10];
 535  4
         onclick = (String) values[11];
 536  4
         ondblclick = (String) values[12];
 537  4
         onfocus = (String) values[13];
 538  4
         onkeydown = (String) values[14];
 539  4
         onkeypress = (String) values[15];
 540  4
         onkeyup = (String) values[16];
 541  4
         onmousedown = (String) values[17];
 542  4
         onmousemove = (String) values[18];
 543  4
         onmouseout = (String) values[19];
 544  4
         onmouseover = (String) values[20];
 545  4
         onmouseup = (String) values[21];
 546  4
         onselect = (String) values[22];
 547  4
         readonly = (Boolean) values[23];
 548  4
         style = (String) values[24];
 549  4
         styleClass = (String) values[25];
 550  4
         tabindex = (String) values[26];
 551  4
         title = (String) values[27];
 552  4
         label = (String) values[28];
 553  4
     }
 554  
 }