I have a question about filling a Primafaces Output Label via Method Call. The method also required a parameter.
The Label looks like followed:
<p:dataTable id="answerToQuestionDialogTable" var="answer" value="#{allQuestionBean.answers}">
<p:column headerText="Counts For this Answer">
<p:outputLabel value="#{allQuestionBean.votingCounter}">
<f:param name="id" value="#{answer.answerId}"/>
</p:outputLabel>
</p:column>
</p:dataTable>
In my Backing Bean i have an Integer Field named “votingCounter” with the followed Getter:
public int getVotingCounter() {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
int answerID = Integer.parseInt(params.get("id"));
return answeredDAO.getCountForAnswer(answerID);
}
If I try to load the Site i get following LogOutput from my AppServer(Tomcat 6):
04.09.2012 04:30:47 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
SCHWERWIEGEND: javax.el.ELException: /pages/allQuestion.xhtml @69,81 value="#{allQuestionBean.votingCounter}": Error reading 'votingCounter' on type bean.view.AllQuestionBean
Can anyone explain me why this won´t work and can give me a solution how I can call the method to fill the Label with Text?
Since you are going to bring all count answers for all answers anyway , why don’t you create a map and populate it in your
@PostConstructand access it the simple way , something like