// note exam id and exam text are initialized from exam backing bean which is (request scoped) and in the same time they are traveling in each request
@ManagedBean(name = "question")//Constants.QUESTION)
@RequestScoped
public class QuestionBean {
private int examId;
private String examText;
@ManagedProperty(name="exam", value="#{exam}")
private ExamBean exam;
// getters and setters
@PostConstruct
public void init() {
examId = exam.getExamId();
examText=exam.getExamText();
}
}
------------------------XHTML page ---------------------------------------
<?xml version="1.0"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head />
<h:body>
<h:form>
<h:panelGrid columns="2" >
Exam name <h:outputText value="#{question.examText}" />
Exam id <h:outputText value="#{question.examId}" />
</h:panelGrid>
<h:inputHidden value="#{question.examText}" />
<h:inputHidden value="#{question.examId}" />
</h:form>
</h:body>
</f:view>
@ManagedBean(name = "question")//Constants.QUESTION)
@RequestScoped
public class QuestionBean {
private int examId;
private String examText;
@ManagedProperty(name="exam", value="#{exam}")
private ExamBean exam;
// getters and setters
@PostConstruct
public void init() {
examId = exam.getExamId();
examText=exam.getExamText();
}
}
------------------------XHTML page ---------------------------------------
<?xml version="1.0"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head />
<h:body>
<h:form>
<h:panelGrid columns="2" >
Exam name <h:outputText value="#{question.examText}" />
Exam id <h:outputText value="#{question.examId}" />
</h:panelGrid>
<h:inputHidden value="#{question.examText}" />
<h:inputHidden value="#{question.examId}" />
</h:form>
</h:body>
</f:view>
Comments
Post a Comment