001 // Copyright 2004, 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.AbstractComponent;
019 import org.apache.tapestry.IMarkupWriter;
020 import org.apache.tapestry.IRequestCycle;
021
022 /**
023 * The do element provides a general mechanism for the user to act upon the
024 * current card, in other words a card-level user interface element. The
025 * representation of the do element is user agent dependent and the author must
026 * only assume that the element is mapped to a unique user interface widget that
027 * the user can activate. For example, the widget mapping may be to a
028 * graphically rendered button, a soft or function key, a voice-activated
029 * command sequence, or any other interface that has a simple "activate"
030 * operation with no inter-operation persistent state. The do element may appear
031 * at both the card and deck-level.
032 *
033 * @author David Solis
034 * @since 3.0
035 */
036
037 public abstract class Do extends AbstractComponent
038 {
039
040 /**
041 * @see AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle)
042 */
043
044 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
045 {
046 boolean render = !cycle.isRewinding();
047
048 if (render)
049 {
050 writer.begin("do");
051
052 writer.attribute("type", getType());
053
054 String label = getLabel();
055 if (HiveMind.isNonBlank(label)) writer.attribute("label", label);
056
057 renderInformalParameters(writer, cycle);
058 }
059
060 renderBody(writer, cycle);
061
062 if (render) writer.end();
063 }
064
065 public abstract String getType();
066
067 public abstract String getLabel();
068 }