001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.wicket.extensions.wizard;
018:
019: import org.apache.wicket.markup.html.basic.Label;
020: import org.apache.wicket.model.IModel;
021: import org.apache.wicket.model.Model;
022:
023: /**
024: * A wizard step that displays the provided static content without expecting any
025: * input.
026: *
027: * @author eelcohillenius
028: */
029: public class StaticContentStep extends WizardStep {
030: private static final long serialVersionUID = 1L;
031:
032: /**
033: * Whether HTML codes should be rendered as is (true), or should be escaped
034: * (false).
035: */
036: private final boolean allowHtml;
037:
038: /** The model that provided the actual content. */
039: private IModel content;
040:
041: /**
042: * Constructor for if you want to set all the properties yourself.
043: *
044: * @param allowHtml
045: * If true, any html of the content will be rendered as is.
046: * Otherwise, it will be escaped.
047: */
048: public StaticContentStep(boolean allowHtml) {
049: this .allowHtml = allowHtml;
050: add(new Label("content", ""));
051: }
052:
053: /**
054: * Construct.
055: *
056: * @param title
057: * The title of this step
058: * @param summary
059: * The summary of this step
060: * @param content
061: * The content of the step panel
062: * @param allowHtml
063: * If true, any html of the content will be rendered as is.
064: * Otherwise, it will be escaped.
065: */
066: public StaticContentStep(IModel title, IModel summary,
067: IModel content, boolean allowHtml) {
068: super (title, summary);
069: this .content = content;
070: this .allowHtml = allowHtml;
071: add(new Label("content", content)
072: .setEscapeModelStrings(!allowHtml));
073: }
074:
075: /**
076: * Construct.
077: *
078: * @param title
079: * The title of this step
080: * @param summary
081: * The summary of this step
082: * @param content
083: * The content of the step panel
084: * @param allowHtml
085: * If true, any html of the content will be rendered as is.
086: * Otherwise, it will be escaped.
087: */
088: public StaticContentStep(IModel title, IModel summary,
089: String content, boolean allowHtml) {
090: this (title, summary, new Model(content), allowHtml);
091: }
092:
093: /**
094: * Construct.
095: *
096: * @param title
097: * The title of this step
098: * @param summary
099: * The summary of this step
100: * @param content
101: * The content of the step panel
102: * @param allowHtml
103: * If true, any html of the content will be rendered as is.
104: * Otherwise, it will be escaped.
105: */
106: public StaticContentStep(String title, String summary,
107: IModel content, boolean allowHtml) {
108: this (new Model(title), new Model(summary), content, allowHtml);
109: }
110:
111: /**
112: * Construct.
113: *
114: * @param title
115: * The title of this step
116: * @param summary
117: * The summary of this step
118: * @param content
119: * The content of the step panel
120: * @param allowHtml
121: * If true, any html of the content will be rendered as is.
122: * Otherwise, it will be escaped.
123: */
124: public StaticContentStep(String title, String summary,
125: String content, boolean allowHtml) {
126: this (title, summary, new Model(content), allowHtml);
127: }
128:
129: /**
130: * Gets whether html is allowed as output.
131: *
132: * @return Whether html is allowed as output
133: */
134: public final boolean getAllowHtml() {
135: return allowHtml;
136: }
137:
138: /**
139: * Gets the content from the content model.
140: *
141: * @return The content
142: */
143: public final String getContent() {
144: return (content != null) ? (String) content.getObject() : null;
145: }
146:
147: /**
148: * Gets the content model.
149: *
150: * @return The content model
151: */
152: public final IModel getContentModel() {
153: return content;
154: }
155:
156: /**
157: * Sets the content model.
158: *
159: * @param content
160: * The content model
161: */
162: public final void setContentModel(IModel content) {
163: this .content = content;
164: replace(new Label("content", content)
165: .setEscapeModelStrings(!allowHtml));
166: }
167: }
|