001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.html;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlRadioButtonGroup.java $
024: //$Author: Dan $
025: //$Revision: 28 $
026: //$Modtime: 10/20/03 4:07p $
027: /////////////////////////
028:
029: import com.salmonllc.properties.Props;
030: import com.salmonllc.sql.DBConnection;
031: import com.salmonllc.util.MessageLog;
032: import com.salmonllc.util.ThreeObjectContainer;
033:
034: import com.salmonllc.html.events.*;
035:
036: import java.util.Hashtable;
037: import java.util.Vector;
038:
039: /**
040: * This class is used to create a group of radio buttons that act like a single entity.
041: */
042: public class HtmlRadioButtonGroup extends HtmlFormComponent {
043: public static final int ORIENTATION_HORIZONTAL = 0;
044: public static final int ORIENTATION_VERTICAL = 1;
045:
046: public static final int CAPTIONS_ON_LEFT = 0;
047: public static final int CAPTIONS_ON_RIGHT = 1;
048: public static final int CAPTIONS_ON_TOP = 2;
049:
050: private String _fontTagStart;
051: private String _fontTagEnd;
052:
053: private Vector _options = new Vector();
054: private int _orientation = ORIENTATION_HORIZONTAL;
055: private int _captionLayout = CAPTIONS_ON_LEFT;
056: private String _onClick = null;
057: private boolean _useProportions = false;
058:
059: private String _imageOn;
060: private String _imageOff;
061: private Integer _tabIndex;
062:
063: /**
064: * Constructs a new HtmlRadioButtonGroup component.
065: * @param name The name of the component
066: * @param p The page the component will be placed in.
067: */
068: public HtmlRadioButtonGroup(String name, HtmlPage p) {
069: this (name, null, p);
070: }
071:
072: /**
073: * Constructs a new HtmlRadioButtonGroup component.
074: * @param name The name of the component
075: * @param theme The theme to use for loading properties.
076: * @param p The page the component will be placed in.
077: */
078: public HtmlRadioButtonGroup(String name, String theme, HtmlPage p) {
079: super (name, p);
080: setTheme(theme);
081:
082: }
083:
084: /**
085: * Creates a radio button group plus an associated datastore column based on a simple table with an <BR>
086: * integer primary key column and a string column. Typically the integer is a type value <BR>
087: * and the string is a description. A simplifying assumption is that each of the following <BR>
088: * is the same: <BR>
089: * - name of column in the main table which refers to the simple table <BR>
090: * - name of integer column in simple table <BR>
091: * @param page com.salmonllc.html.HtmlPage The page hold the new component
092: * @param table - name of table to look up keys and displays from
093: * @param keyColumn - column to get key values from
094: * @param dispColumn - column to get display values from
095: */
096: public HtmlRadioButtonGroup(String name, String theme,
097: HtmlPage page, String table, String keyColumn,
098: String dispColumn) {
099: super (name, theme, page);
100: /**
101: * srufle 04-02-2002
102: * using initialize method now
103: * should be functionally the same
104: */
105: initialize(table, keyColumn, dispColumn, null);
106: }
107:
108: /**
109: * Creates a radio button group based on a table with an <BR>
110: * integer primary key column (typically an id) and a string column.<BR>
111: * A simplifying assumption is that each of the following <BR>
112: * is the same: <BR>
113: * - name of column in the main table which refers to the simple table <BR>
114: * - name of integer column in simple table <BR>
115: * @param table - name of table to look up keys and displays from
116: * @param keyColumn - column to get key values from
117: * @param dispColumn - column to get display values from
118: * @param criteria - optional selection criteria
119: */
120: public void initialize(String table, String keyColumn,
121: String dispColumn, String criteria) {
122: initialize(table, keyColumn, dispColumn, criteria, false);
123: }
124:
125: /**
126: * Creates a radio button group based on a table with an <BR>
127: * integer primary key column (typically an id) and a string column.<BR>
128: * A simplifying assumption is that each of the following <BR>
129: * is the same: <BR>
130: * - name of column in the main table which refers to the simple table <BR>
131: * - name of integer column in simple table <BR>
132: * @param table - name of table to look up keys and displays from
133: * @param keyColumn - column to get key values from
134: * @param dispColumn - column to get display values from
135: * @param criteria - optional selection criteria
136: * @param trimResults - optional value that trims the rtesults before adding the options
137: */
138: public void initialize(String table, String keyColumn,
139: String dispColumn, String criteria, boolean trimResults) {
140: initialize(table, keyColumn, dispColumn, criteria, trimResults,
141: false);
142:
143: }
144:
145: /**
146: * Creates a radio button group based on a table with an <BR>
147: * integer primary key column (typically an id) and a string column.<BR>
148: * A simplifying assumption is that each of the following <BR>
149: * is the same: <BR>
150: * - name of column in the main table which refers to the simple table <BR>
151: * - name of integer column in simple table <BR>
152: * @param table - name of table to look up keys and displays from
153: * @param keyColumn - column to get key values from
154: * @param dispColumn - column to get display values from
155: * @param criteria - optional selection criteria
156: * @param trimResults - optional value that trims the rtesults before adding the options
157: * @param toUpper - optional value that makes the option's kays and display values all upper case
158: */
159: public void initialize(String table, String keyColumn,
160: String dispColumn, String criteria, boolean trimResults,
161: boolean toUpper) {
162: resetOptions();
163:
164: DBConnection connection = null;
165: try {
166: connection = DBConnection.getConnection(getPage()
167: .getApplicationName());
168: java.sql.Statement s = connection.createStatement();
169: String query = null;
170: if (criteria != null) {
171: query = "SELECT " + keyColumn + "," + dispColumn
172: + " FROM " + table + " WHERE " + criteria
173: + " ORDER BY ";
174:
175: if (toUpper)
176: query = query + "UPPER(" + dispColumn + ")";
177: else
178: query += dispColumn;
179: } else {
180: query = "SELECT " + keyColumn + "," + dispColumn
181: + " FROM " + table + " ORDER BY ";
182:
183: if (toUpper)
184: query = query + "UPPER(" + dispColumn + ")";
185: else
186: query += dispColumn;
187: }
188:
189: java.sql.ResultSet r = s.executeQuery(query);
190: if (r.next()) {
191: do {
192: if (trimResults) {
193: addOption(r.getObject(1).toString().trim(), r
194: .getObject(2).toString().trim());
195: } else {
196: addOption(r.getObject(1).toString(), r
197: .getObject(2).toString());
198: }
199: } while (r.next());
200: }
201: r.close();
202: s.close();
203: } catch (java.sql.SQLException se) {
204: MessageLog.writeErrorMessage("initialize", se, null);
205: } catch (Exception e) {
206: MessageLog.writeErrorMessage("initialize", e, this );
207: } finally {
208: if (connection != null)
209: connection.freeConnection();
210: }
211:
212: }
213:
214: /**
215: * Use this method to add new choices to the list.
216: * @param key The internal name of the item (must be unique)
217: * @param disp The value to be displayed on the list.
218: */
219: public void addOption(String key, String disp) {
220: ThreeObjectContainer t = new ThreeObjectContainer(key, disp,
221: null);
222: _options.addElement(t);
223: }
224:
225: /**
226: * Use this method to add new choices to the list.
227: * @param key The internal name of the item (must be unique)
228: * @param disp The value to be displayed on the list.
229: * @param javaScript The javaScript to be executed when the radio button is clicked.
230: */
231: public void addOption(String key, String disp, String javaScript) {
232: ThreeObjectContainer t = new ThreeObjectContainer(key, disp,
233: javaScript);
234: _options.addElement(t);
235: }
236:
237: /**
238: * This method returns the index of the option with the specified key.
239: * @return The index of the key or -1 if not found.
240: */
241: public int findOptionIndexOf(String key) {
242: int optionsSize = _options.size();
243: ThreeObjectContainer t = null;
244: for (int i = 0; i < optionsSize; i++) {
245: t = (ThreeObjectContainer) _options.elementAt(i);
246: if (key == null) {
247: if (t.getObject1() == null)
248: return i;
249: } else if (key.equals(t.getObject1()))
250: return i;
251: }
252: return -1;
253: }
254:
255: public void generateHTML(java.io.PrintWriter p, int rowNo)
256: throws Exception {
257: if (!_visible)
258: return;
259: if (!getEnabled() && !useDisabledAttribute()) {
260: generateHTMLDisabled(p, rowNo);
261: return;
262: }
263: String align = "";
264: if (_captionLayout == CAPTIONS_ON_TOP)
265: align = " ALIGN=\"CENTER\"";
266: String startTag = "";
267: String endTag = "";
268: if (_orientation == ORIENTATION_HORIZONTAL) {
269: if (_useProportions) {
270: int width = 100 / _options.size();
271: startTag = "<TD WIDTH=\"" + width + "%\"" + align;
272: if (_class != null && !_class.trim().equals(""))
273: startTag += " class=\"" + _class + "\"";
274: startTag += ">";
275: } else {
276: startTag = "<TD" + align;
277: if (_class != null && !_class.trim().equals(""))
278: startTag += " class=\"" + _class + "\"";
279: startTag += ">";
280: }
281: endTag = "</TD>";
282: } else {
283: startTag = "<TR" + align + ">";
284: endTag = "</TR>";
285: }
286: String tag = "<TABLE>";
287: if (_orientation == ORIENTATION_HORIZONTAL && _useProportions)
288: tag = "<TABLE WIDTH=\"100%\">";
289: _value = getValue(rowNo, true);
290: if (_captionLayout == CAPTIONS_ON_RIGHT
291: || _captionLayout == CAPTIONS_ON_LEFT) {
292: if (_orientation == ORIENTATION_HORIZONTAL)
293: tag += "<TR>";
294: for (int i = 0; i < _options.size(); i++) {
295: tag += startTag;
296: if (_orientation == ORIENTATION_VERTICAL) {
297: tag += "<TD";
298: if (_class != null && !_class.trim().equals(""))
299: tag += " class=\"" + _class + "\"";
300: tag += ">";
301: }
302: if (_captionLayout == CAPTIONS_ON_LEFT)
303: tag += getCaptionTag(i)
304: + getRadioButtonTag(i, rowNo, _value);
305: else
306: tag += getRadioButtonTag(i, rowNo, _value)
307: + getCaptionTag(i);
308: if (_orientation == ORIENTATION_VERTICAL)
309: tag += "</TD>";
310: tag += endTag;
311: }
312: if (_orientation == ORIENTATION_HORIZONTAL)
313: tag += "</TR>";
314: } else {
315: // CAPTIONS_ON_TOP
316: int optionsSize = _options.size();
317: if (_orientation == ORIENTATION_VERTICAL) {
318: for (int i = 0; i < optionsSize; i++) {
319: tag += startTag + "<TD";
320: if (_class != null && !_class.trim().equals(""))
321: tag += " class=\"" + _class + "\"";
322: tag += ">" + getCaptionTag(i) + "</TD>" + endTag;
323: tag += startTag + "<TD";
324: if (_class != null && !_class.trim().equals(""))
325: tag += " class=\"" + _class + "\"";
326: tag += ">" + getRadioButtonTag(i, rowNo, _value)
327: + "</TD>" + endTag;
328: }
329: } else {
330: tag += "<TR>";
331: for (int i = 0; i < optionsSize; i++)
332: tag += startTag + getCaptionTag(i) + endTag;
333: tag += "</TR><TR>";
334: for (int i = 0; i < optionsSize; i++)
335: tag += startTag
336: + getRadioButtonTag(i, rowNo, _value)
337: + endTag;
338: }
339: }
340: tag += "</TABLE>";
341: p.println(tag);
342: writeFocusScript(p, rowNo);
343: }
344:
345: public void generateHTMLDisabled(java.io.PrintWriter p, int rowNo)
346: throws Exception {
347: String align = "";
348: if (_captionLayout == CAPTIONS_ON_TOP)
349: align = " ALIGN=\"CENTER\"";
350: String startTagImage = "<TD>";
351: String startTagText = "";
352: String endTag = "";
353: if (_orientation == ORIENTATION_HORIZONTAL) {
354: endTag = "</TD>";
355: if (_useProportions) {
356: int width = 100 / _options.size();
357: startTagText = "<TD NOWRAP VALIGN=\"MIDDLE\" WIDTH=\""
358: + width + "%\"" + align;
359: if (_class != null && !_class.trim().equals(""))
360: startTagText += " class=\"" + _class + "\"";
361: startTagText += ">";
362: } else {
363: startTagText = "<TD NOWRAP VALIGN=\"MIDDLE\"" + align;
364: if (_class != null && !_class.trim().equals(""))
365: startTagText += " class=\"" + _class + "\"";
366: startTagText += ">";
367: }
368: switch (_captionLayout) {
369: case CAPTIONS_ON_TOP:
370: startTagImage = "<TD VALIGN=\"MIDDLE\" ALIGN=\"CENTER\" HEIGHT=\"22\"";
371: if (_class != null && !_class.trim().equals(""))
372: startTagImage += " class=\"" + _class + "\"";
373: startTagImage += ">";
374: break;
375: case CAPTIONS_ON_RIGHT:
376: startTagImage = "<TD VALIGN=\"MIDDLE\" HEIGHT=\"22\" WIDTH=\"16\" ALIGN=\"RIGHT\"";
377: if (_class != null && !_class.trim().equals(""))
378: startTagImage += " class=\"" + _class + "\"";
379: startTagImage += ">";
380: break;
381: case CAPTIONS_ON_LEFT:
382: default:
383: startTagImage = "<TD VALIGN=\"MIDDLE\" HEIGHT=\"22\" WIDTH=\"16\" ALIGN=\"CENTER\"";
384: if (_class != null && !_class.trim().equals(""))
385: startTagImage += " class=\"" + _class + "\"";
386: startTagImage += ">";
387: break;
388: }
389: } else {
390: startTagImage = startTagText = "<TR" + align + "><TD";
391: if (_class != null && !_class.trim().equals(""))
392: startTagImage += " class=\"" + _class + "\"";
393: startTagImage += ">";
394: endTag = "</TD></TR>";
395: }
396: String tag = "<TABLE>";
397: if (_orientation == ORIENTATION_HORIZONTAL && _useProportions)
398: tag = "<TABLE WIDTH=\"100%\">";
399: _value = getValue(rowNo, true);
400: // get size of vector now so we don't have to do it lots of times in the loops
401: int optionsSize = _options.size();
402: //
403: if (_captionLayout == CAPTIONS_ON_RIGHT
404: || _captionLayout == CAPTIONS_ON_LEFT) {
405: if (_orientation == ORIENTATION_VERTICAL) {
406: for (int i = 0; i < optionsSize; i++) {
407: if (_captionLayout == CAPTIONS_ON_LEFT)
408: tag += startTagText + getCaptionTag(i)
409: + getRadioButtonTag(i, rowNo, _value);
410: else
411: tag += startTagImage
412: + getRadioButtonTag(i, rowNo, _value)
413: + getCaptionTag(i);
414: tag += endTag;
415: }
416: } else {
417: tag += "<TR>";
418: for (int i = 0; i < optionsSize; i++) {
419: if (_captionLayout == CAPTIONS_ON_LEFT)
420: tag += startTagText + getCaptionTag(i) + endTag
421: + startTagImage
422: + getRadioButtonTag(i, rowNo, _value);
423: else
424: tag += startTagImage
425: + getRadioButtonTag(i, rowNo, _value)
426: + endTag + startTagText
427: + getCaptionTag(i);
428: tag += endTag;
429: }
430: tag += "</TR>";
431: }
432: } else {
433: if (_orientation == ORIENTATION_VERTICAL) {
434: for (int i = 0; i < optionsSize; i++)
435: tag += startTagText + getCaptionTag(i) + endTag
436: + startTagImage
437: + getRadioButtonTag(i, rowNo, _value)
438: + endTag;
439: } else {
440: tag += "<TR>";
441: for (int i = 0; i < optionsSize; i++)
442: tag += startTagText + getCaptionTag(i) + endTag;
443: tag += "</TR><TR>";
444: for (int i = 0; i < optionsSize; i++)
445: tag += startTagImage
446: + getRadioButtonTag(i, rowNo, _value)
447: + endTag;
448: }
449: }
450: tag += "</TABLE>";
451: p.println(tag);
452: writeFocusScript(p, rowNo);
453: }
454:
455: /**
456: * Returns the caption layout of the component. Valid Values are CAPTIONS_ON_LEFT, CAPTIONS_ON_RIGHT and CAPTIONS_ON_TOP.
457: */
458: public int getCaptionLayout() {
459: return _captionLayout;
460: }
461:
462: private String getCaptionTag(int capNo) {
463: String retVal = "";
464:
465: ThreeObjectContainer t = (ThreeObjectContainer) _options
466: .elementAt(capNo);
467: String caption = (String) t.getObject2();
468:
469: if (caption == null)
470: return " ";
471:
472: String fontS = _fontTagStart;
473: if (fontS == null)
474: fontS = "";
475: String fontE = _fontTagEnd;
476: if (fontE == null)
477: fontE = "";
478:
479: if (caption != null)
480: retVal += fontS + caption + fontE;
481:
482: return retVal;
483: }
484:
485: /**
486: * This method gets the end font tag for the component.
487: */
488: public String getFontEndTag() {
489: return _fontTagEnd;
490: }
491:
492: /**
493: * This method gets the start font tag for the component.
494: */
495: public String getFontStartTag() {
496: return _fontTagStart;
497: }
498:
499: /**
500: * This method gets the javascript to be executed when the component gets clicked.
501: */
502: public String getOnClick() {
503: return _onClick;
504: }
505:
506: /**
507: * Use this method get the value of the key at index.
508: */
509: public String getOptionKey(int index) {
510: if (index < 0 || index >= _options.size())
511: return null;
512:
513: ThreeObjectContainer t = (ThreeObjectContainer) _options
514: .elementAt(index);
515: return (String) t.getObject1();
516: }
517:
518: /**
519: * Use this method get the value of the option at index.
520: */
521: public String getOptionValue(int index) {
522: if (index < 0 || index >= _options.size())
523: return null;
524:
525: ThreeObjectContainer t = (ThreeObjectContainer) _options
526: .elementAt(index);
527: return (String) t.getObject2();
528: }
529:
530: /**
531: * Returns the orientation of the component. Valid Values are ORIENTATION_VERTICAL and ORIENTATION_HORIZONTAL.
532: */
533: public int getOrientation() {
534: return _orientation;
535: }
536:
537: private String getRadioButtonTag(int capNo, int rowNo, String val) {
538: ThreeObjectContainer t = (ThreeObjectContainer) _options
539: .elementAt(capNo);
540: String value = (String) t.getObject1();
541:
542: if (value == null)
543: return " ";
544:
545: boolean checked = false;
546: if (val != null) {
547: if (val.equals(value))
548: checked = true;
549: }
550:
551: String name = getFullName();
552: if (rowNo > -1)
553: name += "_" + rowNo;
554:
555: String tag = "<INPUT TYPE=\"RADIO\" NAME=\"" + name
556: + "\" VALUE=\"" + value + "\"";
557:
558: if ((!_enabled) && useDisabledAttribute()) {
559: tag += " disabled=\"true\"";
560: } else if (!_enabled && (_imageOn != null)
561: && (_imageOff != null)) {
562: String out = "<IMG SRC=\"";
563: if (checked)
564: out += _imageOn + "\"";
565: else
566: out += _imageOff + "\"";
567: if (_orientation == ORIENTATION_VERTICAL)
568: out += " ALIGN=\"ABSBOTTOM\" HSPACE= \"4\" VSPACE=\"5\"";
569: out += ">";
570: return out;
571: }
572:
573: if (_onClick != null)
574: tag += " ONCLICK=\"" + _onClick + "\"";
575: if (_class != null)
576: tag += " class=\"" + _class + "\"";
577: else {
578: String jScript = (String) t.getObject3();
579: if (jScript != null)
580: tag += " ONCLICK=\"" + jScript + "\"";
581: }
582:
583: if (checked)
584: tag += " CHECKED";
585:
586: if (_tabIndex != null)
587: tag += " tabindex=\"" + _tabIndex + "\"";
588:
589: tag += ">";
590:
591: if (_fontTagStart != null)
592: tag = _fontTagStart + tag + _fontTagEnd;
593:
594: return tag;
595: }
596:
597: /**
598: * Returns the index of the selected option.
599: */
600: public int getSelectedIndex() {
601: String option = getValue();
602: return findOptionIndexOf(option);
603: }
604:
605: /**
606: * Returns the index of the selected option.
607: */
608: public int getSelectedIndex(int rowNo) {
609: String option = getValue(rowNo);
610: return findOptionIndexOf(option);
611: }
612:
613: /**
614: * Returns whether or not to use a fixed percent of available space for each button in the radio button group (Horizontal Orientation only)
615: */
616: public boolean getUseProportions() {
617: return _useProportions;
618: }
619:
620: public boolean processParms(Hashtable parms, int rowNo)
621: throws Exception {
622: if (!getEnabled())
623: return false;
624: Object oldValue = _value;
625:
626: String name = getFullName();
627: if (rowNo > -1) {
628: name += "_" + rowNo;
629: if (_dsBuff != null)
630: oldValue = _dsBuff.getAny(rowNo, _dsColNo);
631: } else {
632: if (_dsBuff != null)
633: oldValue = _dsBuff.getAny(_dsColNo);
634: }
635:
636: String val[] = (String[]) parms.get(name);
637:
638: if (val == null)
639: _value = null;
640: else
641: _value = val[0];
642:
643: if (!valuesEqual(oldValue, _value) && _value != null) {
644: String s = null;
645: if (oldValue != null)
646: s = oldValue.toString();
647: ValueChangedEvent e = new ValueChangedEvent(getPage(),
648: this , getName(), getFullName(), s, _value, rowNo,
649: _dsColNo, _dsBuff);
650: addEvent(e);
651: }
652:
653: return false;
654: }
655:
656: /**
657: * Use this method to remove an option from the list.
658: * @param index The index of the option to remove.
659: */
660: public void removeOption(int index) {
661: if (index < 0 || index >= _options.size())
662: return;
663:
664: _options.removeElementAt(index);
665: }
666:
667: /**
668: * This method removes all options from the component.
669: */
670: public void resetOptions() {
671: _options.removeAllElements();
672: }
673:
674: /**
675: * Sets the caption layout of the component. Valid Values are CAPTIONS_ON_LEFT, CAPTIONS_ON_RIGHT and CAPTIONS_ON_TOP.
676: */
677: public void setCaptionLayout(int layout) {
678: _captionLayout = layout;
679: }
680:
681: /**
682: * This method sets the end font tag for the component.
683: */
684: public void setFontEndTag(String value) {
685: _fontTagEnd = value;
686: }
687:
688: /**
689: * This method sets the start font tag for the component.
690: */
691: public void setFontStartTag(String value) {
692: _fontTagStart = value;
693: }
694:
695: /**
696: * This method sets the javascript to be executed when the component is checked.
697: */
698: public void setOnClick(String value) {
699: _onClick = value;
700: }
701:
702: /**
703: * Sets the orientation of the component. Valid Values are ORIENTATION_VERTICAL and ORIENTATION_HORIZONTAL.
704: */
705: public void setOrientation(int orientation) {
706: _orientation = orientation;
707: }
708:
709: /**
710: * This method sets the property theme for the component.
711: * @param theme The theme to use.
712: */
713: public void setTheme(String theme) {
714:
715: super .setTheme(theme);
716: Props props = getPage().getPageProperties();
717:
718: _fontTagStart = props.getThemeProperty(theme,
719: Props.FONT_DEFAULT + Props.TAG_START);
720: _fontTagEnd = props.getThemeProperty(theme, Props.FONT_DEFAULT
721: + Props.TAG_END);
722: _imageOn = props.getThemeProperty(theme,
723: Props.RADIOBUTTON_IMAGE_ON);
724: _imageOff = props.getThemeProperty(theme,
725: Props.RADIOBUTTON_IMAGE_OFF);
726:
727: }
728:
729: /**
730: * This method is used to set whether the each button in the group will occupy a fixed percent available space (Horizontal Orientation only)
731: */
732: public void setUseProportions(boolean use) {
733: _useProportions = use;
734: }
735:
736: /**
737: * This method sets the layout property for the component
738: */
739: public void setCaptionLayout(String layout) {
740: int iLayout = CAPTIONS_ON_LEFT;
741: if (layout != null) {
742: layout = layout.toUpperCase();
743: iLayout = layout.equals("TOP") ? CAPTIONS_ON_TOP : (layout
744: .equals("RIGHT") ? CAPTIONS_ON_RIGHT
745: : CAPTIONS_ON_LEFT);
746: }
747: setCaptionLayout(iLayout);
748: }
749:
750: /**
751: * This method sets the orientation property for the component
752: */
753: public void setOrientation(String orientation) {
754: setOrientation(orientation == null
755: || !orientation.toUpperCase().equals("VERTICAL") ? ORIENTATION_HORIZONTAL
756: : ORIENTATION_VERTICAL);
757: }
758:
759: /**
760: * @param sets the tab index html attribute. You can also pass TAB_INDEX_DEFAULT to use the default tab index for the component or TAB_INDEX_NONE to keep this component from being tabbed to
761: */
762: public void setTabIndex(int val) {
763: if (val == -1)
764: _tabIndex = null;
765: else
766: _tabIndex = new Integer(val);
767: }
768: }
|