JAVA SERVER FACES (JSF)

JSF PROJECTS

JSF PROJECT 1

JSF Examples

JSF EXAMPLE

Param Application
Previous Home Next

Tag description: JSF <f:param> Tag is use to add a child UIParameter component to the UIComponent associate with the enclosing parent tag. This tag is used for build compound messages by replacing placeholder

Code

<f:param>

Example :

Step 1: Welcome page of Example

<%--
Name= welcomeJSF.jsp
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%--
This file is an entry point for JavaServer Faces application.
--%>
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>r4r.co.in</title>
</head>
<body>
<h1><h:outputText value=" Tag <f:param> Example"/></h1>
<h:form id="param">
<h:commandButton value="Click me" action="#{paramBean.submit()}" >
<%--
 Tag <f:param> is use to Add a child UIParameter component to parent UIComponent.
--%>
<f:param name="name" value="R4R tech Soft" />
</h:commandButton>   
<BR><BR>
<%-- Display result --%>
<h:panelGrid rendered="#{paramBean.flag != false}" >
<p>Check param tag value here:</p>
Value:<h:outputText value="#{paramBean.name}" />
</h:panelGrid>
</h:form>
</body>
</html>
</f:view>

Step 2: ManagedBean class for provide logic in program.

/*
 * Save as a paramBean.java
 */
package r4r.JSF2;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class paramBean {
private String name;
private boolean flag = false;
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/* -- submit method -- */
public String submit() {
flag= true;
return "success";
}
}

Step 3: face-config.xml file provide mapping and control flow in Example

<?xml version='1.0' encoding='UTF-8'?>
<!-- =========== FULL CONFIGURATION FILE ========= -->
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
   <navigation-rule>
<from-view-id>/welcomeJSF.jsp</from-view-id>
<navigation-case>
 <!-- add success from ManageBean class  -->
<from-action>success</from-action>
<!-- Destination file -->
<to-view-id>/welcomeJSF.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>paramBean</managed-bean-name>
<managed-bean-class>r4r.JSF2.paramBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<!--  Param property send to destination file -->
<managed-property>
<property-name>name</property-name>
<value>#{param.name}</value>
</managed-property>
</managed-bean>
</faces-config>

 

Output :

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: