01: /*
02: * Created on Mar 1, 2005
03: */
04: package com.sun.portal.wireless.htmlconversion.processors;
05:
06: import java.util.HashMap;
07:
08: import org.w3c.dom.Element;
09:
10: import com.sun.portal.wireless.htmlconversion.ParserState;
11:
12: /**
13: * Tag processor to set the submit label on the AmlForm
14: *
15: * @author ashwin.mathew@sun.com
16: */
17: public class AmlFormSubmitTagProcessor extends BaseTagProcessor {
18:
19: // Fake tag name - must not map this to AmlForm, since it
20: // would then incorrectly override AmlFormTagProcessor
21: public static final String AML_FORM_SUBMIT = "AmlFormSubmitAttribute";
22:
23: // No mapping to HTML tags, since this operates by delegation
24: // from HtmlInputTagProcessor
25: private String[] supportedTags = {};
26:
27: /* (non-Javadoc)
28: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getAmlTag()
29: */
30: public String getAmlTag() {
31: return AML_FORM_SUBMIT;
32: }
33:
34: /* (non-Javadoc)
35: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getSupportedTags()
36: */
37: public String[] getSupportedTags() {
38: return supportedTags;
39: }
40:
41: /* (non-Javadoc)
42: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#canHaveChildren(com.sun.portal.wireless.htmlconversion.ParserState)
43: */
44: public boolean canHaveChildren(ParserState state) {
45: return false;
46: }
47:
48: /* (non-Javadoc)
49: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#startTag(java.lang.String, java.util.HashMap, com.sun.portal.wireless.htmlconversion.ParserState)
50: */
51: public Element startTag(String tagName, HashMap attributes,
52: ParserState state) {
53: String value = (String) attributes
54: .get(HtmlInputTagProcessor.ATTR_VALUE);
55: setFormSubmitAttribute(value, state);
56:
57: return null;
58: }
59:
60: /* (non-Javadoc)
61: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#isMaintainOnState(com.sun.portal.wireless.htmlconversion.ParserState)
62: */
63: public boolean isMaintainOnState(ParserState state) {
64: return false;
65: }
66:
67: /**
68: * Sets the form submit label on the current AmlForm.
69: *
70: * @param submitLabel
71: * @param state
72: */
73: public static void setFormSubmitAttribute(String submitLabel,
74: ParserState state) {
75: Element formElement = state.getLayoutManager()
76: .getLastAmlFormTag();
77:
78: if (formElement != null
79: && submitLabel != null
80: && formElement
81: .getAttribute(AmlFormTagProcessor.ATTR_SUBMIT_LABEL) == null) {
82: formElement.setAttribute(
83: AmlFormTagProcessor.ATTR_SUBMIT_LABEL, submitLabel);
84: }
85: }
86: }
|