Ajax requests and Beans in EVENT Scope
uesker Oct 7, 2010 1:03 PMHi!!
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
<rich:panel>
<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>
<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>
<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>
<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>
<s:decorate id="campoData" template="/layout/fields.xhtml">
<ui:define name="label">#{messages['srprocess.fillIdentification.page.date']}</ui:define>
<rich:calendar value="#{srProtocol.date}" />
</s:decorate>
<div style="clear:both"/>
</rich:panel>
And the Bean whitout Scope annotation on SecondaryQuestion variable
@Name("secondaryQuestionAction")
@Scope(ScopeType.PAGE)
public class SecondaryQuestionAction implements Serializable {
private static final long serialVersionUID = 8394705048656015853L;
@In
private StatusMessages statusMessages;
@In(required=false)
@Out(scope=ScopeType.BUSINESS_PROCESS, required=false)
protected SRProtocol srProtocol;
@In(required=false)
private SecondaryQuestion secondaryQuestion;
private List<SecondaryQuestion> secondaryQuestionList;
@Logger
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;
}
@BeginTask
public void startFillSecondaryQuestion() {
if (secondaryQuestionList == null) {
secondaryQuestionList = new ArrayList<SecondaryQuestion>();
statusMessages.addFromResourceBundle("task.initiated.message");
}
}
@EndTask
public String endFillSecondaryQuestion() {
if (srProtocol != null) {
srProtocol.setSecundaryQuestionList(secondaryQuestionList);
}
statusMessages.addFromResourceBundle("srprocess.fillsecondaryquestion.page.success");
return "/listarTarefas.xhtml";
}
public void addSecondaryQuestion(ActionEvent event) {
if (secondaryQuestion != null && secondaryQuestion.getQuestion() != null) {
secondaryQuestionList.add(secondaryQuestion);
secondaryQuestion = null;
} else {
statusMessages.addFromResourceBundle("srprocess.fillsecondaryquestion.page.question.empty");
}
}
public void removeQuestion(SecondaryQuestion secondaryQuestion) {
secondaryQuestionList.remove(secondaryQuestion);
}
}
Thanks for the help!