FileDocCategorySizeDatePackage
ListMessagesTag.javaAPI DocGlassfish v2 API4557Mon Oct 17 14:54:30 BST 2005demo

ListMessagesTag

public class ListMessagesTag extends BodyTagSupport
Custom tag for listing messages. The scripting variable is only within the body of the tag.

Fields Summary
private String
folder
private String
session
private int
msgNum
private int
messageCount
private Message
message
private Message[]
messages
private MessageInfo
messageinfo
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();
       
        if (msgNum < messageCount) {
            getMessage();
            return BodyTag.EVAL_BODY_TAG;
        } else {
            return BodyTag.SKIP_BODY;
        }
    
public intdoStartTag()
Method for processing the start of the tag.

        messageinfo = new MessageInfo();
       
        try {
            Folder folder = (Folder)pageContext.getAttribute(
		getFolder(), PageContext.SESSION_SCOPE);
            FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.DELETED), false);
            messages = folder.search(ft);
            messageCount = messages.length;
	    msgNum = 0;
        } catch (Exception ex) {
            throw new JspException(ex.getMessage());
        }

        if (messageCount > 0) {
            getMessage();
            return BodyTag.EVAL_BODY_TAG;
        } else
            return BodyTag.SKIP_BODY;
    
public java.lang.StringgetFolder()
folder attribute getter method.

    
             
       
        return folder;
    
private voidgetMessage()
Helper method for retrieving messages.

        message = messages[msgNum++];
        messageinfo.setMessage(message);
        pageContext.setAttribute(getId(), messageinfo);
    
public java.lang.StringgetSession()
session attribute getter method.

        return session;
    
public voidsetFolder(java.lang.String folder)
folder setter method.

        this.folder = folder;
    
public voidsetSession(java.lang.String session)
session attribute setter method.

        this.session = session;