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 public GoFormSupportImpl(IMarkupWriter writer, IRequestCycle cycle, IForm form) 034 { 035 super(writer, cycle, form); 036 } 037 038 protected void writeTag(IMarkupWriter writer, String method, String url) 039 { 040 writer.begin("go"); 041 writer.attribute("method", method); 042 writer.attribute("href", url); 043 } 044 045 protected void writeHiddenFields() 046 { 047 // The super-implementation writes a <div> tag that's not 048 // valid as WML. 049 050 writeHiddenFieldList(getHiddenFieldWriter()); 051 } 052 053 protected void writeHiddenField(IMarkupWriter writer, String name, 054 String id, String value) 055 { 056 writer.beginEmpty("postfield"); 057 writer.attribute("name", name); 058 059 if (HiveMind.isNonBlank(id)) writer.attribute("id", id); 060 061 writer.attribute("value", value); 062 writer.println(); 063 } 064 065 public void addEventHandler(FormEventType type, String functionName) 066 { 067 throw new UnsupportedOperationException("addEventHandler() not supported for WML Go component."); 068 } 069 070 protected void emitEventManagerInitialization() 071 { 072 } 073 }