01: /*
02: * AttachmentTag
03: *
04: * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
05: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
06: */
07:
08: package com.sun.portal.wireless.taglibs.mail;
09:
10: import java.util.Vector;
11:
12: import com.sun.portal.wireless.taglibs.base.*;
13:
14: /**
15: *
16: * @version 1.0
17: * @see com.sun.portal.wireless.taglibs.base.BeanTag
18: */
19:
20: public class AttachmentTag extends BeanTag {
21:
22: String msgId = null;
23: String attachmentId = null;
24:
25: public void setMsgId(String mid) {
26: this .msgId = evalAttribute(mid);
27: }
28:
29: public void setAttachId(String aid) {
30: this .attachmentId = evalAttribute(aid);
31: }
32:
33: public Object newBean() throws Exception {
34: return new AttachmentBean();
35: }
36:
37: public Object findBean() throws Exception {
38:
39: MailContext mc = MailContext.getContext(pageContext);
40:
41: if (msgId != null && attachmentId != null) {
42:
43: int mid = Integer.parseInt(msgId);
44: int aid = Integer.parseInt(attachmentId);
45:
46: MsgBean[] msgs = mc.getMsgsCollection();
47: MsgBean mbean = msgs[mid];
48: Vector attachments = mbean.getAttachments();
49: bean = attachments.elementAt(aid);
50:
51: if (id != null) {
52: pageContext.setAttribute(id, bean);
53: }
54:
55: return bean;
56: }
57:
58: return super .findBean();
59: }
60:
61: /**
62: * Cleanup
63: */
64: public void release() {
65: super.release();
66: msgId = null;
67: attachmentId = null;
68: }
69:
70: }
|