FileDocCategorySizeDatePackage
ListAttachmentsTag.javaAPI DocGlassfish v2 API4271Mon Oct 17 14:54:28 BST 2005demo

ListAttachmentsTag

public class ListAttachmentsTag extends BodyTagSupport
Custom tag for listing message attachments. The scripting variable is only within the body of the tag.

Fields Summary
private String
messageinfo
private int
partNum
private int
numParts
private AttachmentInfo
attachmentinfo
private MessageInfo
messageInfo
private Multipart
multipart
Constructors Summary
Methods Summary
public intdoAfterBody()
Method for processing the body content of the tag.

        
        BodyContent body = getBodyContent();
        try {
            body.writeOut(getPreviousOut());
        } catch (IOException e) {
            throw new JspTagException("IterationTag: " + e.getMessage());
        }
        
        // clear up so the next time the body content is empty
        body.clearBody();
       
        partNum++;
        if (partNum < numParts) {
            getPart();
            return BodyTag.EVAL_BODY_TAG;
        } else {
            return BodyTag.SKIP_BODY;
        }
    
public intdoStartTag()
Method for processing the start of the tag.

        messageInfo = (MessageInfo)pageContext.getAttribute(getMessageinfo());
        attachmentinfo = new AttachmentInfo();
        
        try {
            multipart = (Multipart)messageInfo.getMessage().getContent();
            numParts = multipart.getCount();
        } catch (Exception ex) {
            throw new JspException(ex.getMessage());
        }

        getPart();

        return BodyTag.EVAL_BODY_TAG;
    
public java.lang.StringgetMessageinfo()
messageinfo attribute getter method.


             
       
        return messageinfo;
    
private voidgetPart()
Helper method for retrieving message parts.

        try {
            attachmentinfo.setPart(partNum, multipart.getBodyPart(partNum));
            pageContext.setAttribute(getId(), attachmentinfo);
        } catch (Exception ex) {
            throw new JspException(ex.getMessage());
        }
    
public voidsetMessageinfo(java.lang.String messageinfo)
messageinfo attribute setter method.

        this.messageinfo = messageinfo;