001: /**
002: * %W% %G% Sun Microsystems
003: * Copyright 2002 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wireless.taglibs.ab;
014:
015: import java.beans.*;
016: import java.util.logging.Logger;
017: import java.util.logging.Level;
018: import javax.servlet.jsp.*;
019:
020: import com.sun.portal.wireless.taglibs.base.BeanSupport;
021: import com.sun.portal.wireless.taglibs.base.Edit;
022: import com.sun.portal.log.common.PortalLogger;
023:
024: import com.sun.addressbook.Group;
025: import com.sun.addressbook.Element;
026:
027: /**
028: * ABAddGroupMembersTag - add group members to a group
029: *
030: * This class writes the group members to the Group bean found in its parent
031: * entry tag or retrieved from pagecontext using name attribute.
032: *
033: * Attributes:
034: *
035: * members
036: * ',' separated list of element ids to add to the Group
037: * name
038: * name to use to retrieve the bean from the page context
039: *
040: */
041: public class ABAddGroupMembersTag extends BeanSupport {
042:
043: /*
044: * Member ids of the members of a group .. to be used from add and
045: * modify with groups
046: */
047: protected String members = null;
048:
049: // Create a logger for this class
050: private static Logger debugLogger = PortalLogger
051: .getLogger(ABAddGroupMembersTag.class);
052:
053: /**
054: * Get the members attribute
055: *
056: * @return set the members attribute
057: */
058: public String getMembers() {
059: return members;
060: }
061:
062: /**
063: * Set the members attribute
064: *
065: * @param set the members attribute
066: */
067: public void setMembers(String members) {
068: if (this .members != null) {
069: // If members already exist, append to that list
070: this .members += ", " + evalAttribute(members);
071: } else {
072: this .members = evalAttribute(members);
073: }
074: }
075:
076: /**
077: * Edit bean...
078: */
079: private Edit edit = null;
080:
081: /**
082: * Set the edit bean
083: */
084: public void setEdit(String edit) {
085: this .edit = (Edit) pageContext.getAttribute(edit);
086: }
087:
088: /**
089: * Set the group members to be added list in the properties object
090: *
091: * @return SKIP_BODY
092: * @exception JspException
093: */
094: public int doStartTag() throws JspException {
095: Object value;
096:
097: if (edit != null) {
098: members = edit.editString(members.toString());
099: }
100:
101: try {
102: Group group = (Group) findBean();
103: group.setProperty("addmembers", members);
104: } catch (Exception e) {
105: String msg = this .getClass().getName()
106: + ".doStartTag(): No Group bean found.";
107: debugLogger.log(Level.FINE, "PSMA_CSPWTA0003", e);
108: throw new JspException(msg + e.getMessage());
109: }
110:
111: return SKIP_BODY;
112: }
113:
114: /**
115: * Cleanup
116: */
117: public void release() {
118: super.release();
119: members = null;
120: edit = null;
121: }
122:
123: }
|