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.uilib.list;
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.tag.presentation.BaseSimpleButtonTag;
024: import org.araneaframework.jsp.util.JspUpdateRegionUtil;
025:
026: /**
027: * List row button base tag.
028: *
029: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
030: */
031: public class BaseListRowButtonTag extends BaseSimpleButtonTag {
032: protected String updateRegions;
033: protected String globalUpdateRegions;
034:
035: protected List updateRegionNames;
036:
037: protected UiUpdateEvent event;
038:
039: {
040: event = new UiUpdateEvent();
041: }
042:
043: protected int doStartTag(Writer out) throws Exception {
044: int result = super .doStartTag(out);
045: addContextEntry(AttributedTagInterface.HTML_ELEMENT_KEY, id);
046:
047: if (contextWidgetId == null)
048: throw new AraneaJspException(
049: "'listRow(Link)Button' tags can only be used in a context widget!");
050:
051: event
052: .setParam((String) requireContextEntry(ListRowsTag.ROW_REQUEST_ID_KEY));
053: event.setTarget(contextWidgetId);
054: event.setUpdateRegionNames(JspUpdateRegionUtil
055: .getUpdateRegionNames(pageContext, updateRegions,
056: globalUpdateRegions));
057: event.setEventPrecondition(onClickPrecondition);
058:
059: return result;
060: }
061:
062: /* ***********************************************************************************
063: * Tag attributes
064: * ***********************************************************************************/
065:
066: /**
067: * @jsp.attribute
068: * type = "java.lang.String"
069: * required = "false"
070: * description = "Event id."
071: */
072: public void setEventId(String eventId) throws JspException {
073: event
074: .setId((String) evaluate("eventId", eventId,
075: String.class));
076: }
077:
078: /**
079: * @jsp.attribute
080: * type = "java.lang.String"
081: * required = "false"
082: * description = "Enumerates the regions of markup to be updated in this widget scope. Please see <code><ui:updateRegion></code> for details."
083: */
084: public void setUpdateRegions(String updateRegions)
085: throws JspException {
086: this .updateRegions = (String) evaluate("updateRegions",
087: updateRegions, String.class);
088: }
089:
090: /**
091: * @jsp.attribute
092: * type = "java.lang.String"
093: * required = "false"
094: * description = "Enumerates the regions of markup to be updated globally. Please see <code><ui:updateRegion></code> for details."
095: */
096: public void setGlobalUpdateRegions(String globalUpdateRegions)
097: throws JspException {
098: this .globalUpdateRegions = (String) evaluate(
099: "globalUpdateRegions", globalUpdateRegions,
100: String.class);
101: }
102:
103: public void doFinally() {
104: super.doFinally();
105: event.clear();
106: }
107: }
|