01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.tag.uilib.form.element.display;
16:
17: import java.io.Writer;
18: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementDisplayTag;
19: import org.araneaframework.uilib.form.control.DisplayControl;
20:
21: /**
22: * Depending whether form element boolean value is true or false display one or other content,
23: * represents {@link org.araneaframework.uilib.form.control.DisplayControl}.
24: * {@link org.araneaframework.jsp.tag.uilib.form.element.display.FormConditionFalseTag}
25: * and {@link org.araneaframework.jsp.tag.uilib.form.element.display.FormConditionTrueTag} tags
26: * are meant to be used
27: * inside this tag to define alternative contents. This tag itself does not render anything, it just
28: * makes <code>Boolean</code> available to inner tags.
29: *
30: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
31: *
32: * @jsp.tag
33: * name = "conditionalDisplay"
34: * body-content = "JSP"
35: * description = "Depending whether element Boolean value is TRUE or FALSE display one or other content, represents UiLib "DisplayControl"."
36: */
37: public class FormConditionalDisplayTag extends
38: BaseFormElementDisplayTag {
39: public final static String CONDITION_KEY = "org.araneaframework.jsp.tag.uilib.form.element.display.FormConditionalDisplayTag.CONDITION";
40: protected Boolean condition = Boolean.FALSE;
41:
42: protected int doStartTag(Writer out) throws Exception {
43: super .doStartTag(out);
44:
45: assertControlType("DisplayControl");
46:
47: DisplayControl.ViewModel viewModel = (DisplayControl.ViewModel) controlViewModel;
48:
49: if (viewModel.getValue() != null)
50: condition = ((Boolean) viewModel.getValue());
51:
52: addContextEntry(CONDITION_KEY, condition);
53:
54: return EVAL_BODY_INCLUDE;
55: }
56: }
|