1 Reply Latest reply on Oct 12, 2010 12:11 AM by Gabor Jakab

    Ajax requests and Beans in EVENT Scope

    Rafael Espirito Santo Newbie


      I´m facing a problem with a Bean with EVENT Scope and Ajax Request.

      What I need it´s to fill a text area and press a button that fill a data table with the value from text area. So, I created a method that its call by a ajax component (command button). I can enter inseide the method but the value of bean binding to text area it´s null. It´s happens only when I´m working with the Bean on EVENT scope. If I remove the Scope annotation, the value of bean it´s present, but I don´t want to do this.

      Here is the xhtml page

                   <f:facet name="header">#{messages['srprocess.fillIdentification.page.title']}</f:facet>
                     <h:outputText value="#{messages['srprocess.fillIdentification.page.description']}"/><br/>
                  <rich:spacer height="20px"/>
                  <s:decorate id="campoTitulo" template="/layout/fields.xhtml">
                       <ui:define name="label">#{messages['srprocess.fillIdentification.page.titleofsr']}"</ui:define>
                       <h:inputTextarea rows="3" cols="100" value="#{srProtocol.title}"/>
                  <s:decorate id="campoInstituicao" template="/layout/fields.xhtml">
                       <ui:define name="label">#{messages['srprocess.fillIdentification.page.institution']}"</ui:define>
                       <h:inputTextarea rows="3" cols="100" value="#{srProtocol.institution}"/><br/>
                  <s:decorate id="campoAutores" template="/layout/fields.xhtml">
                       <ui:define name="label">#{messages['srprocess.fillIdentification.page.authors']}</ui:define>
                       <h:inputTextarea rows="3" cols="100" value="#{srProtocol.authors}"/>     
                  <s:decorate id="campoContato" template="/layout/fields.xhtml">
                       <ui:define name="label">#{messages['srprocess.fillIdentification.page.contact']}</ui:define>
                       <h:inputTextarea rows="3" cols="100" value="#{srProtocol.contact}"/>     
                  <s:decorate id="campoData" template="/layout/fields.xhtml">
                       <ui:define name="label">#{messages['srprocess.fillIdentification.page.date']}</ui:define>
                       <rich:calendar value="#{srProtocol.date}" />     
                  <div style="clear:both"/>

      And the Bean whitout Scope annotation on SecondaryQuestion variable

      public class SecondaryQuestionAction implements Serializable {
           private static final long serialVersionUID = 8394705048656015853L;
           private StatusMessages statusMessages;
           @Out(scope=ScopeType.BUSINESS_PROCESS, required=false)
           protected SRProtocol srProtocol;
           private SecondaryQuestion secondaryQuestion;
           private List<SecondaryQuestion> secondaryQuestionList;
           private Log log;
           public SecondaryQuestion getSecondaryQuestion() {
                return secondaryQuestion;
           public void setSecondaryQuestion(SecondaryQuestion secondaryQuestion) {
                this.secondaryQuestion = secondaryQuestion;
           public boolean isExibeTabelaQuestoes() {
                return (secondaryQuestionList.size() > 0);
           public List<SecondaryQuestion> getSecondaryQuestionList() {
                return secondaryQuestionList;
           public void setSecondaryQuestionList(
                     List<SecondaryQuestion> secondaryQuestionList) {
                this.secondaryQuestionList = secondaryQuestionList;
           public void startFillSecondaryQuestion() {
                if (secondaryQuestionList == null) {
                     secondaryQuestionList = new ArrayList<SecondaryQuestion>();
           public String endFillSecondaryQuestion() {
                if (srProtocol != null) {
                return "/listarTarefas.xhtml";
           public void addSecondaryQuestion(ActionEvent event) {
                if (secondaryQuestion != null && secondaryQuestion.getQuestion() != null) {
                     secondaryQuestion = null;
                } else {
           public void removeQuestion(SecondaryQuestion secondaryQuestion) {

      Thanks for the help!

        • 1. Re: Ajax requests and Beans in EVENT Scope
          Gabor Jakab Newbie

          Actually, this is the normal behavior. This scope is nothing to do with jBPM events or Seam Events...  EVENT scope is:

          Analogous to the servlet request scope. Exists from the beginning of the Restore View phase until the end of the Render Response phase in the JSF life cycle or until a redi- rect occurs.

          You can use e.g. lifecycle methods @Create @Destroy and logs to monitor if your bean is there...

          Why is that you need EVENT scope here?