Magazine
 
JSF Application
 

set and get those attributes. We will explain more about Managed Bean later in this section.

<h:commandButton action=”result” value=”#{message.button_text}” />

commandButton tag represents command button component. Here again the value attribute gets value of button_text param from “messages.properties” file. So in this example this line prints “Submit” on button component .The action attribute is used to see which page will be displayed next when we will press this button. This “result” value is matched in facesconfig. xml file in WEB- F folder where navigation rules are defined. How to define navigation rules in faces-config.xml file will be described later in this section. Here in this application the next page is “result.jsp” when submit button is pressed.

The collective output of tags used in inputname.jsp will give rise to the first page appeared in front of the user: Output of the page is given below:

When above page appears to the user, user enters name to the input text field and submits the button, a new page “result.jsp” is generated that welcomes the user with the user name. The code for “result.jsp” is:

3-result.jsp:

<%@ taglib uri=”http://java.sun.com/jsf/
html” prefix=”h” %>
<%@ taglib uri=”http://java.sun.com/jsf/
core” prefix=”f” %>
<f:loadBundle
basename=”javajazzup.messages”
var=”message”/>

 

<html>
<head><title>greeting page</title></
head>
<body>
<f:view>
<h3><h:outputText
value=”Hi,#{StoreNameBean.personName}!”
/>
<br/><h:outputText
value=”#{message.greeting_text}” /></h3>
</f:view>
</body>
</html>

Description:

First three lines are same as in “inputname.jsp” file.

<h:outputText value=”Hi, #{StoreNameBean.personName}!” />

The above line is used to access the value of personName attribute from Java Bean named “StoreNameBean” and prints this value (i.e. person’s name) on the page.

<h:outputText
value=”#{message.greeting_text}” />

This line looks the value of greeting_text in “message.prorerties” file and prints this value to the page Here this line prints “Welcome In Java Jazz Up”.

Output of result.jsp:

So output will be like this (if “rose” is entered in the text field of “inputname.jsp” page):

 

Oct 2007 | Java Jazz Up | 58
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70, 71, 72, 73, 74, 75, 76, 77, 78,   Download PDF