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;
16:
17: import java.io.IOException;
18: import java.io.Writer;
19: import javax.servlet.jsp.JspException;
20: import org.araneaframework.jsp.UiUpdateEvent;
21: import org.araneaframework.jsp.util.JspUtil;
22: import org.araneaframework.jsp.util.JspWidgetCallUtil;
23: import org.araneaframework.uilib.event.OnClickEventListener;
24:
25: /**
26: * Standard button link form element tag.
27: *
28: * @author Oleg Mürk
29: *
30: * @jsp.tag
31: * name = "linkButton"
32: * body-content = "JSP"
33: * description = "HTML link, represents UiLib "ButtonControl"."
34: */
35: public class FormLinkButtonHtmlTag extends BaseFormButtonTag {
36: {
37: baseStyleClass = "aranea-link";
38: }
39:
40: protected int doStartTag(Writer out) throws Exception {
41: super .doStartTag(out);
42:
43: // Write button tag
44: JspUtil.writeOpenStartTag(out, "a");
45: JspUtil.writeAttribute(out, "class", getStyleClass());
46: JspUtil.writeAttribute(out, "style", getStyle());
47: JspUtil.writeAttribute(out, "id", this .getFullFieldId());
48: JspUtil.writeAttribute(out, "href", "#");
49: JspUtil.writeAttribute(out, "tabindex", tabindex);
50:
51: if (events) {
52: writeEventAttribute(out);
53: }
54:
55: JspUtil.writeAttributes(out, attributes);
56: JspUtil.writeCloseStartTag_SS(out);
57:
58: // Continue
59: return EVAL_BODY_INCLUDE;
60: }
61:
62: protected int doEndTag(Writer out) throws Exception {
63: if (showLabel)
64: JspUtil.writeEscaped(out, localizedLabel);
65:
66: JspUtil.writeEndTag(out, "a");
67:
68: // Continue
69: super .doEndTag(out);
70: return EVAL_PAGE;
71: }
72:
73: protected boolean writeEventAttribute(Writer out)
74: throws IOException, JspException {
75: if (viewModel.isOnClickEventRegistered()) {
76: UiUpdateEvent event = new UiUpdateEvent(
77: OnClickEventListener.ON_CLICK_EVENT, formFullId
78: + "." + derivedId, null, updateRegionNames);
79: event.setEventPrecondition(onClickPrecondition);
80: JspUtil.writeEventAttributes(out, event);
81: JspWidgetCallUtil.writeSubmitScriptForEvent(out, "onclick");
82: }
83:
84: return viewModel.isOnClickEventRegistered();
85: }
86: }
|