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