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.example.common.tags.wizard;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.example.common.framework.context.WizardContext;
20: import org.araneaframework.jsp.tag.BaseTag;
21: import org.araneaframework.jsp.tag.presentation.BaseEventButtonTag;
22: import org.araneaframework.jsp.tag.presentation.EventButtonHtmlTag;
23:
24: /**
25: * This tag displays wizard's navigation buttons.
26: *
27: * @author Rein Raudjärv <reinra@ut.ee>
28: *
29: * @jsp.tag
30: * name = "wizardFooter"
31: * body-content = "empty"
32: * description = "Includes navigation buttons."
33: */
34: public class WizardFooterTag extends BaseTag {
35: public static final String WIZARD_GOTO_EVENT_ID = "goto";
36: public static final String WIZARD_SUBMIT_EVENT_ID = "submit";
37: public static final String WIZARD_CANCEL_EVENT_ID = "cancel";
38:
39: public static final String WIZARD_GOTO_NEXT_LABEL_ID = "#Next";
40: public static final String WIZARD_GOTO_PREV_LABEL_ID = "#Previous";
41: public static final String WIZARD_SUBMIT_LABEL_ID = "#Submit";
42: public static final String WIZARD_CANCEL_LABEL_ID = "#Cancel";
43:
44: protected int doStartTag(Writer out) throws Exception {
45:
46: WizardContext wizard = (WizardContext) getContextWidget();
47:
48: int index = wizard.getCurrentPageIndex();
49: int count = wizard.countPages();
50:
51: writeEventButtonTag(WIZARD_GOTO_EVENT_ID,
52: new Integer(index - 1).toString(), index == 0,
53: WIZARD_GOTO_PREV_LABEL_ID);
54: writeEventButtonTag(WIZARD_GOTO_EVENT_ID,
55: new Integer(index + 1).toString(), index == count - 1,
56: WIZARD_GOTO_NEXT_LABEL_ID);
57:
58: writeEventButtonTag(WIZARD_SUBMIT_EVENT_ID, null, false,
59: WIZARD_SUBMIT_LABEL_ID);
60: writeEventButtonTag(WIZARD_CANCEL_EVENT_ID, null, false,
61: WIZARD_CANCEL_LABEL_ID);
62:
63: return SKIP_BODY;
64: }
65:
66: protected void writeEventButtonTag(String eventId,
67: String eventParam, boolean disabled, String labelId)
68: throws JspException {
69: BaseEventButtonTag buttonTag = new EventButtonHtmlTag();
70: registerSubtag(buttonTag);
71: buttonTag.setEventId(eventId);
72: if (eventParam != null) {
73: buttonTag.setEventParam(eventParam);
74: }
75: if (disabled == true) {
76: buttonTag.setDisabled("true");
77: }
78: if (labelId != null) {
79: buttonTag.setLabelId(labelId);
80: }
81: executeSubtag(buttonTag);
82: unregisterSubtag(buttonTag);
83: }
84: }
|