JBoss.orgCommunity Documentation
To use the AnswerEventLifeCycle class, do the following steps:
1. Create a new class that extends AnswerEventListener.
For example: ABCActivityPublisher
public class ABCActivityPublisher extends AnswerEventListener {
....
}
2. Override fuctions in this created class. In each function, you can write anything to meet your needs.
public class ABCActivityPublisher extends AnswerEventListener {
public void saveQuestion(Question question, boolean isNew){
....
}
public void saveAnswer(String questionId, Answer answer, boolean isNew){
....
}
public void saveAnswer(String questionId, Answer[] answers, boolean isNew){
....
}
public void saveComment(String questionId, Comment comment, boolean isNew){
....
}
}
The function saveQuestion is called when a question is added and/or edited.
The function saveAnswer is called when an answer is added and/or edited.
The function saveAnswer is called when answers are added and/or edited.
The function saveComment is called when a comment is added and/or edited.
3. Add a new configuration to the configuration.xml file with the type that is the class created in the Step 1.
<external-component-plugins>
<target-component>org.exoplatform.faq.service.FAQService</target-component>
<component-plugin>
<name>AnswerEventListener</name>
<set-method>addListenerPlugin</set-method>
<type>{package}.{class name}</type>
<!-- example
<type>org.exoplatform.ks.ext.impl.ABCActivityPublisher</type>
-->
</component-plugin>
</external-component-plugins>