cancel
Showing results for 
Search instead for 
Did you mean: 

creating custom behavior

speedster
Champ in-the-making
Champ in-the-making
Hi,
I am trying out alfresco web-client.
I would like to know how to add custom behavior to the existing functionalities.
For eg., when a user is created by admin, sending a notification email.
How can I implement it.
5 REPLIES 5

lover91
Champ in-the-making
Champ in-the-making
I have the same issue
any one can help to send email to new user that created
send to him the login user and password

zaizi
Champ in-the-making
Champ in-the-making
Take a look at the PersonServiceImpl.java. This implements onCreate behaviour for person object. Also there is an behaviour example in the Alfresco SDK.

This registers onCreate for Person Type.
this.policyComponent
                .bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), ContentModel.TYPE_PERSON, new JavaBehaviour(this, "onCreateNode"));

lover91
Champ in-the-making
Champ in-the-making
Thanks zaizi
I will look in this class

lover91
Champ in-the-making
Champ in-the-making
In this class I can't get user password so I found this in class CreateUserWizard.java
in method finishImpl(….)

lover91
Champ in-the-making
Champ in-the-making
I solve this
1- go to class CreateUserWizard.java
———
2-import this packages
import javax.mail.internet.MimeMessage;
import javax.mail.MessagingException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
3-
protected void SendEmail() {
        MimeMessagePreparator mailPreparer = new MimeMessagePreparator() {

            public void prepare(MimeMessage mimeMessage) throws MessagingException {
                MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
                message.setTo(getEmail());
                message.setSubject("Mail subject");
                message.setText("Your new User , UserName=" + getUserName() + ", Password=" + getPassword());
                message.setFrom(getFrom());
            }
        };
        this.getMailSender().send(mailPreparer);
    }

    protected JavaMailSender getMailSender() {
        JavaMailSender mailSender = null;
        if (mailSender == null) {
            mailSender = (JavaMailSender) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "mailService");
        }
        return mailSender;
    }

4- call SendEmail() method in finishImpl(….)