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.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementHtmlTag;
20: import org.araneaframework.jsp.util.JspUtil;
21: import org.araneaframework.uilib.form.control.ButtonControl;
22:
23: /**
24: * Standard button form element base tag.
25: *
26: * @author Oleg Mürk
27: */
28: public class BaseFormButtonTag extends BaseFormElementHtmlTag {
29: protected boolean showLabel = true;
30:
31: protected String onClickPrecondition;
32: protected ButtonControl.ViewModel viewModel;
33:
34: //
35: // Attributes
36: //
37:
38: /**
39: * @jsp.attribute
40: * type = "java.lang.String"
41: * required = "false"
42: * description = "Whether button shows its label."
43: */
44: public void setShowLabel(String showLabel) {
45: this .showLabel = showLabel.equalsIgnoreCase("true");
46: }
47:
48: /**
49: * @jsp.attribute
50: * type = "java.lang.String"
51: * required = "false"
52: * description = "Precondition for deciding whether go to server side or not."
53: */
54: public void setOnClickPrecondition(String onClickPrecondition)
55: throws JspException {
56: this .onClickPrecondition = (String) evaluate(
57: "onClickPrecondition", onClickPrecondition,
58: String.class);
59: }
60:
61: //
62: // Implementation
63: //
64:
65: protected int doStartTag(Writer out) throws Exception {
66: super .doStartTag(out);
67:
68: // Type check
69: assertControlType("ButtonControl");
70:
71: // Prepare
72: viewModel = ((ButtonControl.ViewModel) controlViewModel);
73:
74: // Check whether access key was specified in the resources
75: if (accessKey == null) {
76: accessKey = JspUtil.getResourceStringOrNull(pageContext,
77: controlViewModel.getLabel() + ".access-key");
78: if (accessKey != null && accessKey.length() != 1)
79: accessKey = null;
80: }
81:
82: // Continue
83: return EVAL_BODY_INCLUDE;
84: }
85: }
|