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