Getting started with JDeveloper

xiaoxiao2021-03-06  55

JBuilder may be the most popular Java development tool, but it is not free. It will automatically send information to Borland in the latest version of JBuilder9, which is easy to be used to use pirated . Struts is now the most popular Web system architecture, and JBuilder9 comes with Struts 1.0. Of course, I personally still like Borland's products, but because of variety of reasons, the company has changed from Oracle's JDeveloper. JDeveloper1.0 is Oracle, bought JBuilder code from Borland, and heard very little. However, starting from JDeveloper 3.0, JDeveloper starts integrating Oracle's BC4J development component (this is a very powerful, easy-to-use development component), and JDevelPoer has begun to receive attention. Below, I will introduce how to develop the Struts system on the JDeveloper903.

Preparation

1.1 Download JDeveloper

First, download the latest version of JDeveloper9.03.3 from Oracle's website, JDeveloper is free.

1.2 About OC4J

An application server OC4J of Oracle is also bringing in JDeveloper. Unzip the downloaded compressed package, the J2EE folder under the JDeveloper directory is the directory where OC4J is located. If you want to start OC4J manually, we can perform Java? Cjar Oc4j.jar in its directory. OC4J usage and features are not described in detail here.

Two development struts system

2.1 Run JDeveloper

JDEVW.exe in [JDeveloperHome] JDEV / BIN in the directory where JDeveloper is located is the running program of JDeveloper in Windows. The rear interface running the JDeveloper is as follows:

figure 1

JDeveloper's Struts Development supports the latest version Struts1.1 of Struts, and provides the Struts Development Wizard. Below, we will show how to develop the Struts system with JDeveloper.

2.2 Build a struts system environment

1) First, we have to create a workspace (Workspace). There is a root workspace in JDeveloper, right-click on the root workspace, select "New Workspace ..." to create a new workspace in the pop-up menu.

2) Create an empty project called StrustDemo via FILE | New ... | General | Empty Project.

3) Complete the creation of the Struts development environment through the Struts System Wizard in new work.

In the File | New menu, select Struts under the branched Web-Tier, select "Starter Application" in the option on the right, click the "OK" button.

figure 2

Completed the above steps, a Struts developed the environment. From JDeveloper we can see the wizard adds web.xml, struts-config.xml, and a proterties file to our project.

2.3 Development Example of a Struts

This is just a simple instance, the user enters the URL, will pop up a JSP page, enter user information in the JSP page and submit, will display a list of information on the same page.

2.3.1 Editing Struts-Config.xml File

First, we add ActionMApping in Struts-Config.xml, which is used to receive the DynaActionForm for receiving user input information.

Right-click Struts-Config.xml, select the Edit Struts Config ... item in the pop-up menu, and the editor of the struts-config.xml file will pop up. image 3

As can be seen from Figure 3, JDevelPoer provides us with tools for configuring struts-config.xml files.

1) Select the Form Beans branch to add an actionform

Figure 4

2) First select the action mapping branch, then add two actionmapping, set the following

Figure 5

Figure 6

From Figure 3 we can see, you can also edit the new features of Struts 1.1 of Exception, plugs, etc. through this editor.

2.3.2 Editing JSP

In the File | New menu, select the JavaServer Page (JSP) under the web tier branch, select JSP Page in the right option, create a JSP called TestdyNaform.

A tool to write Struts Tag is available in JDeveloper, which can be opened in View | Component Palette.

Figure 7

Just check the logo you want to edit, and then drag it into the JSP file and complete a logo. Here is the code of TestdyNaForm.jsp:

<% @ Page language = "java"%>

<% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%>

Test Dynamics Form </ Title></p> <p><HTML: BASE /></p> <p></ hEAD></p> <p><body bgcolor = "white"></p> <p><html: form action = "TestdyNaForm"></p> <p><Table Border = "0" width = "100%"></p> <p><tr></p> <p><th align = "left"></p> <p>username</p> <p></ tH></p> <p><TD align = "left"></p> <p><html: text protety = "username" size = "30" maxlength = "30" /></p> <p></ td></p> <p></ TR></p> <p><tr></p> <p><th align = "left"></p> <p>gender</p> <p></ tH></p> <p><TD align = "left"></p> <p><HTML: Text Property = "SEX" size = "60" maxlength = "60" /></p> <p></ td></p> <p></ TR></p> <p><logic: present name = "result" scpe = "request"></p> <p><logic: Iterate ID = "item" name = "result" type = "mypackage1.user"> <TR></p> <p><TD> <bean: Write Name = "item" property = "username" /> </ td></p> <p><TD> <bean: Write Name = "Item" property = "sex" /> </ td></p> <p></ TR></p> <p></ logic: Iterate></p> <p></ logic: present></p> <p><tr colorspan = "1"></p> <p><TD></p> <p><html: Submit property = "submit" οnclick = "bcancel = false;"></p> <p>submit</p> <p></ html: Submit></p> <p></ td></p> <p></ TR></p> <p></ TABLE></p> <p></ html: form></p> <p></ body></p> <p></ html: html></p> <p>2.3.4 Write an action</p> <p>In the File | New menu, select Struts under the branched Web-Tier, select "Action" in the option on the right, click the "OK" button. Name the created action TestdyNaFormAction. Add the following code in the execute function generated by the code:</p> <p>Public ActionForward Execute (ActionMapping Mapping, ActionMApping Mapping, ActionMM Form, HttpservletRequest Request, HttpservletResponse Response) Throws oException, ServletException</p> <p>{</p> <p>DynaActionform DFORM = (DynaActionform) Form;</p> <p>String name = (string) DFORM.GET ("UserName");</p> <p>String sex = (string) DFORM.GET ("SEX");</p> <p>System.out.println ("Name =" Name ", SEX" SEX);</p> <p>String name1 = Name "1";</p> <p>String SEX1 = SEX "1";</p> <p>DFORM.SET ("UserName", Name1);</p> <p>DFORM.SET ("SEX", SEX1);</p> <p>User [] result = {new user (), new user (), new user ()};</p> <p>Result [0] .SetuserName (Name);</p> <p>Result [0] .SETSEX (SEX);</p> <p>Result [1] .SetuserName (Name1);</p> <p>Result [1] .SETSEX (SEX1);</p> <p>Result [2] .SetUserName (Name1 "1");</p> <p>Result [2] .SETSEX (Sex1 "1");</p> <p>Request.setttribute ("result", result); // ok</p> <p>Return mapping.findforward ("Success");</p> <p>}</p> <p>2.3.5 Write a bean</p> <p>Create a Class called User through File | New ... | Java Class, this class is a JavaBean for storing user information. Right-click User.java and select Class Editor in the pop-up menu. Figure 8</p> <p>Add two member variables in the Class editor</p> <p>Figure 9</p> <p>As long as the member variable is added, the corresponding geter and seter methods are automatically generated.</p> <p>2.3.6 Operating procedures</p> <p>Right-click INDEX under Struts-Config.xml, select "Run INDEX" in the pop-up menu to run the example created above.</p> <p>Figure 10</p> <p>The result of the operation is:</p> <p>Figure 11</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-109332.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="109332" 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.053</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 = 'j37_2FlxNIj7qHYBlseD2E7Tmkg1xzbyQaS9nbAqWLjpR_2BKytZsVeKlaVqGuwEIWMaK5MOySA7NNEMMXfTgpJGxQ_3D_3D'; 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>