Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Latest commit

 

History

History
49 lines (43 loc) · 2.07 KB

hello_world_web.md

File metadata and controls

49 lines (43 loc) · 2.07 KB

Quick Start with "Hello World"

With Efw,it is easily to start web programming if you know Javascript & JQuery.

JSP

Create a file with the next codes, and name it as "helloworld.jsp" in your web application folder "efw".
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="efw" uri="efw" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Hello World</title>
	<efw:Client/>
</head>
<body>
	<input type=text id="txtMessage">
	<input type=button value="Send" onclick="Efw('helloWorld_sendMessage')">
	<fieldset><legend>Messages</legend></fieldset>
</body>

You will see the next image, if you call it from a web browser by the url http://localhost:8080/efw/helloworld.jsp .

you will see an error, if you click the "Send" button before you complete the next step.

Server Event

Create a file with the next codes, and name it as "helloWorld_sendMessage.js" in the server event folder "efw/WEB-INF/efw/event/".
var helloWorld_sendMessage={};
helloWorld_sendMessage.paramsFormat={
		"#txtMessage":"required:true;display-name:the input message"
};
helloWorld_sendMessage.fire=function(params){
	return (new Result())
		.runat("body")
		.withdata({"#txtMessage":""})
		.runat("fieldset")
		.append("<span>{message}<br></span>")
		.withdata([{"message":params["#txtMessage"]}]);
};
The entering in the input messsage will be moved into the messsages, after you click the "Send" button.


You will see an alert and a hightlight, if you click the "Send" button without entering.