001 // Copyright 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.wml;
016
017 import org.apache.hivemind.HiveMind;
018 import org.apache.tapestry.IForm;
019 import org.apache.tapestry.IMarkupWriter;
020 import org.apache.tapestry.IRequestCycle;
021 import org.apache.tapestry.form.FormEventType;
022 import org.apache.tapestry.form.FormSupportImpl;
023
024 /**
025 * Subclass of {@link org.apache.tapestry.form.FormSupportImpl} that
026 * adjusts the output markup to conform to WML.
027 *
028 * @author Howard M. Lewis Ship
029 * @since 4.0
030 */
031 public class GoFormSupportImpl extends FormSupportImpl
032 {
033
034 public GoFormSupportImpl(IMarkupWriter writer, IRequestCycle cycle,
035 IForm form)
036 {
037 super(writer, cycle, form);
038 }
039
040 protected void writeTag(IMarkupWriter writer, String method, String url)
041 {
042 writer.begin("go");
043 writer.attribute("method", method);
044 writer.attribute("href", url);
045 }
046
047 protected void writeHiddenFields()
048 {
049 // The super-implementation writes a <div> tag that's not
050 // valid as WML.
051
052 writeHiddenFieldList(getHiddenFieldWriter());
053 }
054
055 protected void writeHiddenField(IMarkupWriter writer, String name,
056 String id, String value)
057 {
058 writer.beginEmpty("postfield");
059 writer.attribute("name", name);
060
061 if (HiveMind.isNonBlank(id)) writer.attribute("id", id);
062
063 writer.attribute("value", value);
064 writer.println();
065 }
066
067 public void addEventHandler(FormEventType type, String functionName)
068 {
069 throw new UnsupportedOperationException(
070 "addEventHandler() not supported for WML Go component.");
071 }
072
073 protected void emitEventManagerInitialization()
074 {
075 }
076 }