| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| WOSubmitButton |
|
| 2.1666666666666665;2.167 |
| 1 | /* |
|
| 2 | Wotonomy: OpenStep design patterns for pure Java applications. |
|
| 3 | Copyright (C) 2000 Blacksmith, Inc. |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, see http://www.gnu.org |
|
| 17 | */ |
|
| 18 | ||
| 19 | package net.wotonomy.web; |
|
| 20 | ||
| 21 | import net.wotonomy.foundation.NSDictionary; |
|
| 22 | import net.wotonomy.foundation.NSMutableArray; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Implements a submit button with dynamic bindings. |
|
| 26 | * @author michael@mpowers.net |
|
| 27 | * @author $Author: cgruber $ |
|
| 28 | * @version $Revision: 905 $ |
|
| 29 | */ |
|
| 30 | public class WOSubmitButton extends WOInput { |
|
| 31 | ||
| 32 | public WOSubmitButton() { |
|
| 33 | 0 | super(); |
| 34 | 0 | } |
| 35 | ||
| 36 | public WOSubmitButton(String n, NSDictionary m, WOElement t) { |
|
| 37 | 0 | super(n, m, t); |
| 38 | 0 | } |
| 39 | ||
| 40 | protected String inputType() { |
|
| 41 | 0 | return "SUBMIT"; |
| 42 | } |
|
| 43 | ||
| 44 | protected Object value(WOContext c) { |
|
| 45 | 0 | Object v = valueForProperty("value", c.component()); |
| 46 | 0 | if (v == null) { |
| 47 | 0 | return "Submit"; |
| 48 | } |
|
| 49 | 0 | return v; |
| 50 | } |
|
| 51 | ||
| 52 | protected NSMutableArray additionalAttributes() { |
|
| 53 | 0 | NSMutableArray a = super.additionalAttributes(); |
| 54 | 0 | a.add("action"); |
| 55 | 0 | return a; |
| 56 | } |
|
| 57 | ||
| 58 | public WOActionResults invokeAction(WORequest r, WOContext c) { |
|
| 59 | 0 | if (disabled(c)) |
| 60 | 0 | return null; |
| 61 | //It's useless to check the senderID here because it's going to be for the form always. |
|
| 62 | //So we check if the formValues contain the button's name (which means it was pressed) |
|
| 63 | 0 | if (r.formValueForKey(inputName(c)) != null) { |
| 64 | 0 | if (associations.objectForKey("action") != null) |
| 65 | 0 | return (WOActionResults)valueForProperty("action", c.component()); |
| 66 | } |
|
| 67 | 0 | return null; |
| 68 | } |
|
| 69 | ||
| 70 | } |