001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.jsp.tag.presentation;
016:
017: import java.io.Writer;
018: import java.util.List;
019: import javax.servlet.jsp.JspException;
020: import org.araneaframework.jsp.UiUpdateEvent;
021: import org.araneaframework.jsp.exception.AraneaJspException;
022: import org.araneaframework.jsp.tag.basic.AttributedTagInterface;
023: import org.araneaframework.jsp.util.JspUpdateRegionUtil;
024:
025: /**
026: * Button base tag.
027: *
028: * @author Oleg Mürk
029: */
030: public class BaseEventButtonTag extends BaseSimpleButtonTag {
031: protected String disabled;
032: protected String updateRegions;
033: protected String globalUpdateRegions;
034:
035: protected List updateRegionNames;
036: protected String eventTarget;
037:
038: protected UiUpdateEvent event;
039:
040: {
041: event = new UiUpdateEvent();
042: }
043:
044: protected int doStartTag(Writer out) throws Exception {
045: int result = super .doStartTag(out);
046:
047: addContextEntry(AttributedTagInterface.HTML_ELEMENT_KEY, id);
048:
049: if (contextWidgetId == null)
050: throw new AraneaJspException(
051: "'eventButton' tag can only be used in a context widget!");
052:
053: updateRegionNames = JspUpdateRegionUtil.getUpdateRegionNames(
054: pageContext, updateRegions, globalUpdateRegions);
055: event.setUpdateRegionNames(updateRegionNames);
056: event.setTarget(eventTarget == null ? contextWidgetId
057: : eventTarget);
058: event.setEventPrecondition(onClickPrecondition);
059:
060: return result;
061: }
062:
063: /** @since 1.1 */
064: protected boolean isDisabled() {
065: return Boolean.valueOf(disabled).booleanValue();
066: }
067:
068: /* ***********************************************************************************
069: * Tag attributes
070: * ***********************************************************************************/
071:
072: /**
073: * @jsp.attribute
074: * type = "java.lang.String"
075: * required = "false"
076: * description = "Event id."
077: */
078: public void setEventId(String eventId) throws JspException {
079: event
080: .setId((String) evaluate("eventId", eventId,
081: String.class));
082: }
083:
084: /**
085: * @jsp.attribute
086: * type = "java.lang.String"
087: * required = "false"
088: * description = "Event parameter."
089: */
090: public void setEventParam(String eventParam) throws JspException {
091: event.setParam((String) evaluate("eventParam", eventParam,
092: String.class));
093: }
094:
095: /**
096: * @jsp.attribute
097: * type = "java.lang.String"
098: * required = "false"
099: * description = "Enumerates the regions of markup to be updated in this widget scope. Please see <code><ui:updateRegion></code> for details."
100: */
101: public void setUpdateRegions(String updateRegions)
102: throws JspException {
103: this .updateRegions = (String) evaluate("updateRegions",
104: updateRegions, String.class);
105: }
106:
107: /**
108: * @jsp.attribute
109: * type = "java.lang.String"
110: * required = "false"
111: * description = "numerates the regions of markup to be updated globally. Please see <code><ui:updateRegion></code> for details."
112: */
113: public void setGlobalUpdateRegions(String globalUpdateRegions)
114: throws JspException {
115: this .globalUpdateRegions = (String) evaluate(
116: "globalUpdateRegions", globalUpdateRegions,
117: String.class);
118: }
119:
120: /**
121: * @jsp.attribute
122: * type = "java.lang.String"
123: * required = "false"
124: * description = "Widget where event should be routed, default is contextwidget."
125: */
126: public void setEventTarget(String eventTarget) throws JspException {
127: this .eventTarget = (String) evaluate("eventTarget",
128: eventTarget, String.class);
129: }
130:
131: /**
132: * @jsp.attribute
133: * type = "java.lang.String"
134: * required = "false"
135: * description = "Disables button."
136: */
137: public void setDisabled(String disabled) throws JspException {
138: this .disabled = (String) evaluate("disabled", disabled,
139: String.class);
140: }
141:
142: public void doFinally() {
143: super.doFinally();
144: event.clear();
145: }
146: }
|