We want to write a simple JSF application that gets an input text from a user an
ID: 3577542 • Letter: W
Question
We want to write a simple JSF application that gets an input text from a user and echoes the input text. inputText.xhtml gets input text from a user. echoText.xhtml echoes the input text value entered from the user. Refer to the following two figures. please fill the gaps inputText.xhtml code snippet <h:form> <h:inputText value="#{textBean.inputText}" /> <h:commandButton value="Echo the Input Text" action="#{textBean.doEcho}" /> </h:form> (1) Write a JSF managed Bean based on the following code template import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @Named(value = "__________") @SessionScoped public class _____________________________ { //Write code declaring instance variable //methods including action controller method } (2) Complete echoText.xhtml code snippet shown below <h:body> <h1>Echo the input text value</h1> Echo the input text value : <h:outputText value=__________________________ /> </h:body>
Explanation / Answer
Managed Bean
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@Named(value = "textbean")
@SessionScoped
public class textbean{
//Write code declaring instance variable
//methods including action controller method
private string inputText;
public void setInputText(String inputText)
{
this.inputText=inputText;
}
public String getInputText()
{
return inputText;
}
}
echoText.xhtml
<h:body>
<h1>Echo the input text value</h1>
Echo the input text value : <h:outputText value= #{textbean.inputText} />
</h:body>
Blanks to be fiiled are high lighted in bold
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.