Beehive Pageflow Tutorial

xiaoxiao2021-03-06  41

BEEHIVE Page Flow Tutorial

1. Development of the development environment [lp1]

1) Download and install Beehive, J2SE5, ANT

1.6.2

Tomcat5

2) Modify BeeHiveUser.cmd under Beehive_Home and run it to set some classpath

3) Add an administrator role in Tomcat (optional)

Catalina_home / conf / tomcat-users.xml

4) Start Tomcat (optional)

% Catalina_home% / bin / startup.bat or

ANT -F% Beehive_Home% / Ant / BuildWebapp.xml Start

2. Simple application development process

1) First ensure the following directory structure, you can copy from / Samples / Netui-Blank.

Resources

WEB-INF

Controller.jpf

Error.jsp

Index.jsp

2) Copy the runtime jars to the corresponding folder and use the ANT command to complete.

ANT -F% Beehive_Home% / Ant / BuildWebapp.xml -dwebapp.dir = deploy.beehive.Webapp.Runtime

Note: The name of the folder and files cannot have symbols other than alphanumeric underscores, such as "-".

3) Create a JSP file and JPF file.

4) Compile and configure Page Flow to ensure that Tomcat is already started. WebApp-Blank is a WebApp name, and is a full path to WebApp.

ANT -F% Beehive_Home% / Ant / BuildWebapp.xml -dwebapp.dir = -dcontext.path = Webapp-blank build.Webapp deploy

Note: If you throw a Context Path Already Exists error, use the ANT command first Undeploy Application. Then use the above command to recompile and configure it. ANT -F% Beehive_Home% / Ant / BuildWebapp.xml -dwebapp.dir = -dcontext.path = Webapp-Blank undeploy

5) Re-build and configure it after the JPF is modified.

ANT -F% Beehive_Home% / Ant / BuildWebapp.xml -dwebapp.dir = -dcontext.path = Webapp-blank undeploy build.Webapp Deploy

3. Data Submit

1) JSP file, add:

name:

age:

Submit

2) Represents the Java class submitting the form

Create a Java class that represents the submit form. When the data is submitted, the class is instantiated, and the form data is loaded into the member of the class.

You can put it under / web-inf / src / forms.

Package Forms;

Public Class Profileform

{

PRIVATE INT AGE;

PRIVATE STRING NAME;

Public void setname (String name)

{

THIS.NAME = Name;

}

Public string getName ()

{

Return this.name;

}

Public void setage (int Age)

{

THIS.AGE = AGE;

}

Public int getage ()

{

Return this.Age;

}

}

3) JPF file, modified as follows:

Import Org.apache.beehive.Netui.pageFlow.Forward;

Import org.apache.beehive.netui.pageflow.pageflowController;

Import org.apache.beehive.netui.pageflow.annotations.jpf;

Import Forms.profileform;

@ JPF.Controller

Public Class Controller Extends PageFlowController

{

@ JPF.Action

FORWARDS = {

@ JPF.Forward (name = "success", Path = "index.jsp")

}

)

Public Forward Begin ()

{

Return New Forward ("Success");

}

@ JPF.Action

FORWARDS = {

@ JPF.Forward (name = "success", Path = "Page2.jsp")}

)

Public Forward Topage2 ()

{

Return New Forward ("Success");

}

@ JPF.Action

FORWARDS = {

@ JPF.Forward (name = "success", Path = "Page2.jsp")

}

)

Public Forward ProcessData (Profileform Form)

{

System.out.println ("Name:" form.getname ());

System.out.println ("Age:" form.getage ());

Return New Forward ("Success");

}

}

4. Data display

1) JSP file

<% @ page language = "java" contenttype = "text / html; charSet = UTF-8"%>

<% @ Taglib Uri = "http://beehive.apache.org/netui/tags-html-1.0" prefix = "Netui"%>

displayData.jsp </ title></p> <p><NetUI: Base /></p> <p></ hEAD></p> <p><NetUI: Body></p> <p><p> name: <netui: span value = "$ {requestscope.data.name}" /></p> <p><p> age: <netui: span value = "$ {requestscope.data.age}" /></p> <p></ NetUI: Body></p> <p></ netui: html></p> <p>2) JPF file</p> <p>@ JPF.Action</p> <p>FORWARDS = {</p> <p>@ JPF.Forward (Name = "Success", Path = "DisplayData.jsp")</p> <p>}</p> <p>)</p> <p>Public Forward ProcessData (Profileform Form)</p> <p>{</p> <p>System.out.println ("Name:" form.getname ());</p> <p>System.out.println ("Age:" form.getage ());</p> <p>GetRequest (). SetAttribute ("Data", Form);</p> <p>Return New Forward ("Success");</p> <p>}</p> <p>5. Database control</p> <p>1) Insert</p> <p>@SQL (statement = "INSERT INTO EMPLOYEE" </p> <p>(ID, FNAME, LNAME, TITLE) </p> <p>"VALUES ({Emp.id}, {Emp.FName}, {Emp.Title})")</p> <p>Public void insertemployee (Employee EMP) THROWS SQLEXCEPTION;</p> <p>Note: Variable name sensation sensitive</p> <p>2) query. Note If returns to integer, be sure to return to Integer, not int.</p> <p>l Returns a value. Title's VARCHAR type determines how to return to String</p> <p>@SQL (statement = "SELECT TIOM EMPLOYEE WHERE ID = {id})</p> <p>Public String GetEmployeetitle (Int ID) THROWS SQLEXCEPTION;</p> <p>l Returns a record. The return type can be a user-defined object (as EMPLOYEE below), or a java.util.hashmap object. If the former, the user-defined object must contain all column, and ensure that the variable names of the two correspondence.</p> <p>@SQL (statement = "select * from Employee where id = {id}")</p> <p>Public Employee FindemPloyee (Int ID) throws SqlexCeption;</p> <p>Public Class Employee</p> <p>{</p> <p>Public int ID;</p> <p>Public String Fname;</p> <p>Public String Lname;</p> <p>Public String Title;</p> <p>}</p> <p>l Returns multiple records. The return type can be an array, or java.util.ITerator, or java.sql.resultset. If it is Iterator, it must define IteRaulementType. MaxRows defines the number of records returned up to.</p> <p>@SQL (statement = "select * from employee order by lname", ituteElelementType = Employee.class, maxRows = 500)</p> <p>Public iterator getEmployeessORTEDBYLASTNAME () THROWS SQLEXCEPTION;</p> <p>3) Data control defines two Annotation: SQL and ConnectionDataSource.</p> <p>l SQL Annotation defines query statements and related properties. If you return multiple records, you need to define iterateorelementType.</p> <p>Public @Interface SQL</p> <p>{</p> <p>String statement () Default "";</p> <p>Int maxrows () default maxrows_all;</p> <p>@ AnnotationMembertypes.Option</p> <p>Class iteratorelementType () default undefinedItemType.class;</p> <p>}</p> <p>l ConnectionDataSource Annotation Defines the data source for data control to get the connection.</p> <p>Public @Interface ConnectionDataSource</p> <p>{</p> <p>String Jndiname (); // no default ... Value Is Required</p> <p>}</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-72009.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="72009" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.033</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'iSQ50EZudXfKwJQmSG5rfLw8DVoOs5SVkVQGoAJFHEyoSmDjFwwlkXU_2FsjVB1SImbHUjGQNrOWv8oHnU'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>