yapkm01 0 Newbie Poster

I'm newbie to JSF and i am confused on this portion written by Cay Horstmann in the Core Java server faces:

=======================================================================================

The code:

public class QuizFormBean { 
private UIOutput scoreComponent; 
private UIInput answerComponent; 
// PROPERTY: scoreComponent 
public UIOutput getScoreComponent() { return scoreComponent; } 
public void setScoreComponent(UIOutput newValue) { scoreComponent = newValue; } 

// PROPERTY: answerComponent 
public UIInput getAnswerComponent() { return answerComponent; } 
public void setAnswerComponent(UIInput newValue) { answerComponent = newValue; } 
... 
}

=====================================================================================

This is the 2nd edition of this book.

When you use a backing bean, you need to wire up the components on the form to those on the bean. You use the binding attribute for this purpose:

<h : outputText binding="#{quizForm.scoreComponent}"/>

When the component tree for the form is built, the getScoreComponent method of the backing bean is called, but it returns null. As a result, an output component is constructed and installed into the backing bean with a call to setScoreComponent.

Question:

if this is correct .. why another output component is created? I dont see the need since a backing bean is both ways - input and output.


==================================================================================

This is the 3rd edition of this book.

When you use a backing bean, you need to wire up the components on the form to those on the bean. You use the binding attribute for this purpose:

<h : outputText binding="#{quizForm.answerComponent}"/>

When the component tree for the form is built, the getAnswerComponent method of the backing bean is called, but it returns null. As a result, an output component is constructed and installed into the backing bean with a call to setAnswerComponent .

Question:
If this edition is correct, shouldn't this be input component since answerComponent is of type UIInput?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.