Confluence Docs 3.0 : UPT 2.1 - The UserInfo Bean This page last changed on Jun 30, 2006 by cmiller. The first thing I need is an object to store the user information in. I already know what information I need to store: I'm replicating the contents of our existing staff directory. In Ruby, I'd write something like this:
    class UserInfo
       attr_accessor :position, :office, :extension, :mobile_phone, :other_phone,
           :aim_id, :msn_id, :yahoo_id, :jabber_id, :icq_id, :skype_id;
    end
However, Confluence plugins are written in Java. I've got to write this instead:
    package com.atlassian.confluence.extra.userinfo;

    import java.io.Serializable;

    /**
     * Dumb serializable bean so we can fit all the user info in a single property
     */
    public class UserInformation implements Serializable
    {
        private String position;
        private String office;
        private String extension;

        private String mobilePhone;
        private String otherPhone;
        private String aimId;
        private String msnId;
        private String yahooId;
        private String jabberId;
        private String icqId;
        private String skypeId;

        public String getPosition()
        {
            return position;
        }

        public void setPosition(String position)
        {
            this.position = position;
        }

        public String getOffice()
        {
            return office;
        }

        public void setOffice(String office)
        {
            this.office = office;
        }

        public String getExtension()
        {
            return extension;
        }

        public void setExtension(String extension)
        {
            this.extension = extension;
        }

        public String getMobilePhone()
        {
            return mobilePhone;
        }

        public void setMobilePhone(String mobilePhone)
        {
            this.mobilePhone = mobilePhone;
        }

        public String getOtherPhone()
        {
            return otherPhone;
        }

        public void setOtherPhone(String otherPhone)
        {
            this.otherPhone = otherPhone;
        }

        public String getAimId()
        {
            return aimId;
        }

        public void setAimId(String aimId)
        {
            this.aimId = aimId;
        }

        public String getMsnId()
        {
            return msnId;
        }

        public void setMsnId(String msnId)
        {
            this.msnId = msnId;
        }

        public String getYahooId()
        {
            return yahooId;
        }

        public void setYahooId(String yahooId)
        {
            this.yahooId = yahooId;
        }

        public String getJabberId()
        {
            return jabberId;
        }

        public void setJabberId(String jabberId)
        {
            this.jabberId = jabberId;
        }

        public String getIcqId()
        {
            return icqId;
        }

        public void setIcqId(String icqId)
        {
            this.icqId = icqId;
        }

        public String getSkypeId()
        {
            return skypeId;
        }

        public void setSkypeId(String skypeId)
        {
            this.skypeId = skypeId;
        }
    }
Luckily, 90% of the typing above can be done for me by any decent Java IDE. The most important part of the code above is that the object is Serializable. This is what makes it possible to store and retrieve the object later.

Document generated by Confluence on Nov 05, 2009 23:34