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