Here is a story about 15th and 16th hours. In this hour I have learnt about few basic HTML elements in JSF and how to pass control to Java code. How to show a message pop-up when a button is clicked, how to show List, Menu controls, Checkbox and Options.
Here is a one small application:
FileName: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>JSP Page</title>
</head>
<body>
<h1><h:outputText value="JavaServer Faces"/></h1>
<h:form>
<h:commandButton value="Click" action="#{Msg.plain}"/>
</h:form>
</body>
</html>
</f:view>
FileName: newclass.java
package newpackage;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author satya
*/
public class NewClass {
public String plain() {
JOptionPane.showMessageDialog(null, "Plain Message", "PLAIN", JOptionPane.PLAIN_MESSAGE);
return "success";
}
}
FileName:faces-config.xml
Added this much in the file:
<managed-bean>
<managed-bean-name>Msg</managed-bean-name>
<managed-bean-class>newpackage.NewClass</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
F***king thing is the new dialog goes behind Main browser window and I keep on wondering what has happened. Got suggestion here that I need to use JDialog for this. I will see.
Comments (1)