Write the Struts application with WebSphere Studio V5

xiaoxiao2021-03-06  74

Struts is an open source framework funded by the Apache Software Foundation. You can use it to maintain and extend web applications. IBM® WebSphere® Studio Application Developer Version 5.0 (hereinafter, WebSphere Studio) has built-in support for Struts, supports Struts 1.02 and 1.1 (Beta 2). The Struts Configuration editor in WebSphere Studio allows you to easily modify the struts-config.xml file. This article describes how to create a Struts example in WEBSPHERE Studio.

Struts

The Struts framework is completely written in Java, and the standard J2EE API is used. In addition, it also adopts several famous J2EE design patterns, such as model-view-controller, and FrontController.

Model - View - Controller (MVC)

Model - View-Controller (MVC) is a design pattern that makes a clear distinction when defining the following three application layers.

Model is a collection of data and business rules for applications. Usually referred to as the application's business logic. View (View) is the user interface of the application. Controller defines how the application interacts with the user input and model. It is called application logic.

By clearly distinguishing the individual layers, the MVC allows each component to which each of the layers is loosely coupled. This makes it more flexible and can be reused. For example, if you have developed several user interfaces for an application, you need to develop view components because each application layer is loosely coupled.

The Struts framework is the view and controller components of the MVC. The following shows how Struts maps to the MVC framework. Struts has three main components:

Action Bean ActionServlet ActionForm Bean and customized tags.

Figure 1. MVC and STRUTS framework

Action Bean and ActionServlet Struts provide a separate ActionServlet (Org.apache.struts.Action.ActionServlet) to process all browser requests. This type of framework is called FrontController mode. Each browser request is processed by the Struts's action subclass (subclass of Org.apache.Struts.Action.Action). Each browser request is mapped to an Action subclass in the struts-config.xml file. ActionServlet loads this mapping during initialization. To configure a web project to pass all browser requests to the ActionServlet, all the URIs ending in .do (for example, * .do) are mapped to the ActionServlet in the Web Deployment Descriptor. You can then provide the actual Action subclass map for each request URI (such as /submit.do) in the STRUTS configuration file. ActionForm bean browser requests a band. When the user submits the HTML form, the Struts framework places the parameters in an org.Apache.Struts.Action.Actionform bean. You can also use ActionForm Beans to pre-implant a form in advance, which can be obtained from databases or other backend systems. If the user enters an incorrect value in the form, the ActionForm can verify. You can re-display your form with previous input. Customized tag Struts provides a number of JSP custom tags that support ActionForm Beans. These customized tags support: Pre-implant the value obtained from the ActionForm subclass into the HTML form. Internationalization, such as the text that is determined by the user locale. Logic, such as displaying different titles based on people's way of use.

Struts is a universal framework that you can easily use it with WebSphere Studio. Let's start the first Struts example.

Write a simple Struts application

prerequisites:

Start WebSphere Studio version 5.0:

Go to the Window Start menu. Select Programs => IBM WebSphere Studio => Application Developer 5.0.

Step 1: Start a new Struts Web project

Create a 1.3 EAR project (not including EJB / Client or Web project):

Select New => Projects => Enterprise Application Project. Select Create 1.3 J2EE Enterprise Application Project. Press NEXT. Cancel the selection of all three subproducts (Application Client Project, EJB Project, and Web Project). Enter StrutSear as the project name. Click Finish.

Create a web project and add Struts support:

Select New => Projects => Web => Web Project. Enter StrutssampleWeb as a web project. Select the Add Struts Support check box. Click Next. Select EXISTING Enterprise Application Project. Browse the new EAR project. Click Next again. Select Override Default Settings in the Struts Setting page and select 1.1 (Beta 2) in the drop-down box, as shown in Figure 2. As mentioned earlier, when the form is submitted, the HTML form data is automatically implanted with Struts ActionForm. Struts 1.0.1 only supports simple Java types. Struts 1.1 (Beta 2) also supports java.util.hashmap or other Collection type. This will be discussed in the back of this article. Click Finish. Figure 2. Covering the default settings in the WEB Project Creating Wizard

Check the Struts file structure in Figure 3.

Figure 3. Web project supporting Struts

You will then modify the following files later:

ApplicationResources.properties is the resource binding of the Struts application. Details and error messages in the language environment are placed in this property file. Struts-config.xml is the Struts XML configuration file. WebSphere Studio provides a GUI editor for this file.

Now do the following:

Check the web.xml file. Expand the StrutssampleWeb project and double-click Web Deployment Descriptor to open the editor. Go to the servlets page. Please pay attention to the following two points:

The definition of the struts org.apache.struts.action.ActionServlet called action. URL mapping from this servlet, *.

Note that in the Initialization section, Validate is set to True. ActionServlet uses an XML parser to verify and process profiles. It has nothing to do with form verification, and you will see this later.

* .do how to get the correct Action class?

As mentioned earlier, the ActionServlet and Action class are the core of the controller layer in the MVC model. The controller is responsible for processing the user's request, routes the request to business logic, and selects the view to respond to the user (see the Struts User Guide, Section 4.4). After the form is submitted to Submit.do, the Struts ActionServlet will use the correct Action class based on in the struts-config.xml file.

The Struts Action subclass is responsible for processing user data. In this example, create a Struts Action subclass called SubmitArt. It consists of an operation such as reading and processing form data. Each form is associated with an instance of the Struts ActionForm subclass. Please create this form class that inherited Actionform. SubmitForm is a subclass of ActionForm, which is created with the domain's getter and setter methods. Getter and setter methods are must be available in the Actionform subclass.

How does SUBMITFORM work?

Each Struts Action class must be associated with a Struts ActionForm class. You can define the SubmitForm class in the FormBean page of the Struts-Config.xml editor in WebSphere Studio. You can then associate it with the SUBMITACTION map in the struts-config.xml file. After a request is submitted, the ActionServlet automatically implants the data obtained from the actual form on the web browser to SubmitForm. In the SubmitAction class, the form data is accessed with SubmitForm f = (SubmitForm) Form. Step 2: Build a JSP form with Struts Taglib

Struts provides many HTML tags for the input domain and provides a lot of hyperlinks for the JSP form. There are several commonly used:

Check box - hidden domain -

Most HTML tags support JavaScript events such as ONMOUSECLICK, ONMOUSEOVER and other events. For more information, see the HTML Bean API.

Let's create a JSP page for this example. In Web Perspective, create a JSP page with the Struts model:

Expand the StrutssampleWeb project until the / web content folder is seen. Right click on / web content. Select New => JSP file. Enter SubmitPage.jsp in Name. Select Struts JSP from the drop-down box as Model. Click Next, pay attention to the Taglib of HTML and Bean. If you want to use Taglib in other tag libraries, such as Logic Taglib, select Add Tag Libraries, then select /Web-inf/Struts-Logic.TLD. Click Finish.

Figure 4. JSP Creating Wizard - Struts Tag Library

Modify SubmitPage.jsp Pages in the Source Code Editor and save:

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

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

<% @ PAGE

Language = "java"

ContentType = "text / html; charSet = ISO-8859-1"

PageEncoding = "ISO-8859-1"

%>

TYPE = "text / css">

Pizza Order Page </ Title></p> <p></ HEAD></p> <p><Body></p> <p><P> <h1> Pizza Order Page </ h1> </ p></p> <p><html: form action = "/ submit.do"></p> <p>Name: <html: Text Property = "Customer.Name" /> <br></p> <p>Address: <html: Text Property = "Customer.Address" /> <br></p> <p>Size: <html: Radio Property = "size" value = "s" /> small</p> <p><html: Radio Property = "size" value = "m" /> medium</p> <p><html: Radio Property = "size" value = "l" /> large</p> <p>TOPPINGS: <br></p> <p>Pepperoni <html: checkbox print = "Topping (pepperoni)" /> <br></p> <p>Onion <html: checkbox proty = "Topping (onion)" /> <br></p> <p>Mushroom <html: checkbox proty = "TOPPING (Mushroom)" /> <br></p> <p>Hot pepper <html: checkbox proty = "TOPPING (Hot Pepper" /> <br></p> <p>Bacon <html: checkbox proty = "TOPPING (BACON)" /> <br></p> <p><HTML: Select Property = "Type"></p> <p><html: Option value = "a"> Delivery </ html: option></p> <p><html: option value = "b"> Pickup </ html: option></p> <p></ html: select></p> <p><html: submit /></p> <p><html: reset /></p> <p></ html: form></p> <p></ Body></p> <p></ html: html></p> <p>Ignore the warning message from Submit.do in the task list. Create a /confirm.jsp page for the Struts Action class for forwarding.</p> <p>In Web Perspective, create a Confirm.jsp page:</p> <p>Right click on / web content. Select New => JSP file. Enter CONFIRM.JSP in the NAME domain. Click Finish.</p> <p>Modify the JSP file with the following code:</p> <p><! Doctype html public "- // w3c // DTD HTML 4.01 Transitional // En"></p> <p><% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%></p> <p><% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%></p> <p><html: html></p> <p><HEAD></p> <p><% @ PAGE</p> <p>Language = "java"</p> <p>ContentType = "text / html; charSet = ISO-8859-1"</p> <p>PageEncoding = "ISO-8859-1"</p> <p>%></p> <p><Meta http-equiv = "content-type" content = "text / html; charSet = ISO-8859-1"></p> <p><Meta name = "generator" content = "IBM WebSphere Studio"></p> <p><Meta http-equiv = "content-style-type" content = "text / css"></p> <p><Link href = "theme / master.css" rel = "stylesheet"</p> <p>TYPE = "text / css"></p> <p><Title> </ title></p> <p></ HEAD></p> <p><Body></p> <p><P> thank you <% = request.getattribute ("name")%> </ p></p> <p></ Body></p> <p></ html: html></p> <p>In SubmitPage.JSP, the Customer.Name property references one domain within the object. Topping (pepperoni) attribute is a key / value pair of java.util.hashmap. Struts 1.1 (Beta 2) HTML Taglib supports nested properties.</p> <p>Step 3: Create a Struts ActionForm SubmitForm class</p> <p>You must define a subclass of inheriting the Struts ActionForm class. It must have setter and getter for all form fields. The ActionForm class is pre-implanted in advance by pre-submitting the form. The ActionForm class has a verification method and reset method (optional) to verify the form input and reset the form, respectively. They will be discussed herein later. If your application has a form across multiple web pages, you can use only one an actionform. Define an actionform bean that contains properties of all domains, which is displayed on which page is displayed regardless of the field. Similarly, you can submit each page of the same form to the same Action class. With this design, the Web site designer does not have to change the business logic to rearrange the domain.</p> <p>Create a Java class, which inherits the org.apache.struts.Action.ActionForm in the / java source folder under the Web Project.</p> <p>In Web Perspective, right-click the / Java Source folder under the StrutssampleWeb project. Select New => Other => Web. Expand Web => Struts. Select ActionForm Class and click Next. Figure 5. Starting the Struts ActionForm class wizard Enter com.ibm.sample.struts as the name of Java Package. Enter SubmitForm as the Name of the class. Click Next. This page allows you to choose the domain that wants to choose Setter and getter. Expand the directory tree like Figure 6. Select these items: Customer.Name, Size, Topping (Pepperoni) and Type. Figure 6. Select a new access program (SETTER and GETTER) for the HTML form Click Next. Change Customer.Name to Customer (without quotation marks) and change its type to Customer. Change Topping (Pepperoni) to Toppings and change its type to java.util.hashmap. Change String [] to the String type. Add Name, type String. Add Address, type String. Figure 7. Modify the Access program Click Next. The ActionServlet decides to transfer the control to which Action form associated with the Struts-Config.xml file. The Actionform class associated with it. This page automatically defines the SubmitForm Actionform Bean in the Struts configuration XML file. Figure 8. Configure the ActionForm Configure mapping in Struts-Config.xml. Click Finish.</p> <p>ActionForm contains all the domains in the form, and each domain must have a getter and a setter. You need to manually change the Customer object and the implementation of the TopPings HashMap's Getter and Setter. Please click this to modify the black body code in the SubmitForm you just created:</p> <p>Package com.ibm.sample.struts;</p> <p>Import java.util.hashmap;</p> <p>Import javax.servlet.http.httpservletRequest;</p> <p>Import org.apache.struts.Action.Actionerror;</p> <p>Import org.apache.struts.Action.Actionerro;</p> <p>Import org.apache.struts.Action.actionform;</p> <p>Import org.apache.struts.action.actionmapping; public class submitform extends actionform {</p> <p>Private Customer Customer = New Customer ();</p> <p>PRIVATE STRING SIZE = NULL;</p> <p>Private java.util.hashmap Toppings = New java.util.hashmap ();</p> <p>PRIVATE STRING TYPE = NULL;</p> <p>Private string name = NULL;</p> <p>Private string address = null;</p> <p>Public string getsize () {</p> <p>Return size;</p> <p>}</p> <p>Public hashmap gettoppings () {</p> <p>Return Toppings;</p> <p>}</p> <p>Public void setsize (string size) {</p> <p>THIS.SIZE = Size;</p> <p>}</p> <p>Public void settoppings (havehmap pageings) {</p> <p>THIS.TOPPINGS = TOPPINGS;</p> <p>}</p> <p>Public string gettype () {</p> <p>Return Type;</p> <p>}</p> <p>Public void settype (String type) {</p> <p>THIS.TYPE = TYPE;</p> <p>}</p> <p>Public customer getcustomer () {</p> <p>Return Customer;</p> <p>}</p> <p>Public void setcustomer (Customer Customer) {</p> <p>THIS.CUSTOMER = Customer;</p> <p>}</p> <p>Public string getaddress () {</p> <p>Return Customer.Getdress ();</p> <p>}</p> <p>Public string getname () {</p> <p>Return Customer.getName ();</p> <p>}</p> <p>Public void setaddress (String address) {</p> <p>Customer.SetAddress (address);</p> <p>}</p> <p>Public void setname (String name) {</p> <p>Customer.setName (Name);</p> <p>}</p> <p>Public void settopping (String Key, Object value) {// * new * method</p> <p>Toppings.Put (key, value);</p> <p>}</p> <p>Public Object Gettopping (String Key) {// * New * Method</p> <p>Return Toppings.get (key);</p> <p>}</p> <p>Public void reset (actionMapping mapping, httpservletRequest request) {</p> <p>This.customer = new customer ();</p> <p>Name = new string ();</p> <p>Address = new string ();</p> <p>SIZE = new string ();</p> <p>Toppings.clear ();</p> <p>TYPE = new string ();</p> <p>}</p> <p>}</p> <p>Because SubmitForm uses a Customer Bean, create a Java class called Customer under the com.ibm.sample.struts package:</p> <p>In Web Perspective, right-click on the / Java Source folder under the Web project. Select New => Class. Enter or browse to select com.ibm.sample.struts as the name of the package. Enter Customer as the name of the name. Click Finish. Enter the following code for this class: package com.ibm.sample.struts;</p> <p>Public class customer {</p> <p>PRIVATE STRING NAME;</p> <p>PRIVATE STRING ADDRESS;</p> <p>Public string getaddress () {</p> <p>Return Address;</p> <p>}</p> <p>Public string getname () {</p> <p>Return Name;</p> <p>}</p> <p>Public void setaddress (String address) {</p> <p>THIS.ADDRESS = Address;</p> <p>}</p> <p>Public void setname (String name) {</p> <p>THIS.NAME = Name;</p> <p>}</p> <p>}</p> <p>To map the INPUT text field in the form to the Name domain of the Customer object, use the <html: text property in the HTML tag. To access the HashMap key / value or any collections, use the Property = "TOPPINGS (key) in the HTML tag, where toppings is the name of the HashMap in the example. Note: Only Struts 1.1 (Beta 2) supports the use of HashMap or other Collectes properties.</p> <p>After pressing the RESET button, the reset () method is called.</p> <p>Step 4: Create an Action SubmitAction class</p> <p>The Struts Action class is the application logic. It performs JDBC calls, calls other business beans and calls EJB, and so on. We recommend separate business logic to other beans without embedding it into this Action class. This class calls a bean with business logic. You should implement the execute () method. It returns an ActionForWard object that identifies the next page (such as a JSP page).</p> <p>Public ActionForward Execute (ActionMApping Mapping, Actionform Form, HttpServletRequest Request,</p> <p>Httpservletresponse response</p> <p>The execute () method can access the form data you can use. Because all requests are routed to an instance of the Action class, make sure that your code can be executed correctly in a multi-threaded environment. When returns an ActionForward that identifies the JSP page, define a logical name for the JSP page in the Struts-Config.xml editor. For example, define logical names Success for /confirm.jsp. In an Execute () method, return ("Success"); this line code transfers the control power to the /confirm.jsp page.</p> <p>Create a category called SubmitAction under the / Java Source folder:</p> <p>In Web Perspective, right-click on the / Java Source folder under the Web project. Select New => Other => Web => struts => Action Class. Enter com.ibm.sample.struts as the name of the package. Enter SubMitAction as the name of the name. Press NEXT. In the Forwards section, press Add to add a forwards, this transferred Name is success, Path is /confirm.jsp. Select SubmitForm as the value of the Form Bean Name domain. Select Session as the value of the Form Bean Scope domain. Click Finish. Figure 9. Creating an Action class wizard.</p> <p>Enter the following code in the SubmitAction class:</p> <p>Package com.ibm.sample.struts;</p> <p>Import javax.servlet.http.httpservletRequest;</p> <p>Import javax.servlet.http.httpservletResponse;</p> <p>Import org.apache.struts.Action.action;</p> <p>Import org.apache.struts.Action.Actionerror;</p> <p>Import org.apache.struts.Action.Actionerro;</p> <p>Import org.apache.struts.Action.actionform;</p> <p>Import org.apache.struts.Action.actionForward;</p> <p>Import org.apache.struts.action.actionmapping;</p> <p>/ **</p> <p>* @version 1.0</p> <p>* @Author</p> <p>* /</p> <p>Public class submitArtus action {</p> <p>/ **</p> <p>* Constructor</p> <p>* /</p> <p>Public SubmitAction () {</p> <p>Super ();</p> <p>}</p> <p>Public ActionForward Execute</p> <p>ActionMapping mapping,</p> <p>Actionform Form,</p> <p>HTTPSERVLETREQUEST REQUEST,</p> <p>Httpservletresponse response</p> <p>Throws exception {</p> <p>ActionerroS Errors = new actionerrors ();</p> <p>ActionForward Forward = New ActionForward ();</p> <p>// Return Value</p> <p>SubmitForm SubmitForm = (SubmitForm) Form;</p> <p>Try {</p> <p>// Getting the value from the Form</p> <p><B> string name = SubmitForm.getCustom (). Getname ();</p> <p>System.out.println ("The name is:" name);</p> <p>Request.setttribute ("name", name); </ b></p> <p>} catch (exception e) {</p> <p>// Report The Error Using The Appropriate Name and ID.</p> <p>Errors.Add ("Name", New ActionError ("ID"));</p> <p>}</p> <p>// if a message is required, save the specified key (s)</p> <p>// INTO The Request for use by the <struts: errors> tag.</p> <p>IF (! errors.empty ()) {</p> <p>SaveerRors (Request, Errors);</p> <p>}</p> <p>// Write logic determining how the user shop be forward.</p> <p>Forward = mapping.findforward ("Success");</p> <p>// Finish with</p> <p>Return (Forward);</p> <p>}</p> <p>}</p> <p>Step 5: Run the sample</p> <p>At this point, you have completed this example and now you can run it. To run SubmitPage.jsp in WebSphere Test Environment V5:</p> <p>Right click SubmitPage.jsp => Run on Server. Make sure the WebSphere Test Environment V5 Server is selected. Click OK.</p> <p>Step 6: Verification</p> <p>You can verify in the Struts ActionForm. After a form is submitted, the validate () method in the SubmitForm is implemented. Add the following validate () method to SubmitForm:</p> <p>Public ActionerRors Validate</p> <p>ActionMapping mapping,</p> <p>HttpservletRequest request) {</p> <p>ActionerroS Errors = new actionerrors ();</p> <p>IF ((Customer.GetName () == null) || (Customer.getName (). Equals ("))) {</p> <p>// if the name is empty -> ErrorS</p> <p>Errors.Add ("Name", New Actionerror ("Error.customer.name");</p> <p>System.out.println ("ERRORS ....");</p> <p>}</p> <p>Return Errors;</p> <p>}</p> <p>After saving the SubmitForm class, please note that the ActionError compile error is not resolved. Right-click ActionError => Source => Organize Imports.</p> <p>Error.customer.Name property is obtained from resource binding. Open ApplicationResources.properties from the / Java Source folder in an editor. Add the following code line to this properties file:</p> <p># Optional Header and Footer for <Errors /> TAG.</p> <p>Title = Pizza Store</p> <p>Errors.Header = <hr> <h3> Errors </ h3> <ul></p> <p>Errors.footer = </ ul> <hr></p> <p>Error.customer.Name = <li> name is Empty</p> <p>When the error is displayed in the JSP page, it is enclosed in <HR> <H3> ErrorS </ h3> <ul> and </ ul>. You must use errors.header and errors.footer to define the header (footer) and foot (Footer). After the error is detected, they are returned to the form and the input value is saved.</p> <p>You need to add a code row in the JSP file <html: errors />, which is the error to display. At the beginning of the submitpage.jsp file (just before <html: form>), enter <html: errors />. Modify / Input Domain in the Struts-Config.xml Editor:</p> <p>Open the struts-config.xml file in the editor. This file is in the / Web Content folder. The Action and ActionForm beans are created by the Struts to configure, except for the INPUT field in the Actions page. In order to make verification, this domain is required. Under the Actions page of the Struts-Config.xml Editor, select / Submit and enter /submitpage.jsp in the INPUT domain. Save the modifications made.</p> <p>You can put error messages and other messages in the ApplicationResources.properties file. For example, you can use <bean: message key = "title" /> to display titles in JSP, and content can be obtained from resource binding.</p> <p>Resource binding also supports internationalization (I18N - 18 characters between I and N). You can create ApplicationResources_xx.properties for the ISO language code for XX.</p> <p>Run the sample again and verify</p> <p>Since we have modified the web project, then restart the server and try to run the sample again. To restart the server, go to the server view, right-click and select Restart.</p> <p>If the submitted name is empty, return to the form page, and an error message is listed in the properties file.</p> <p>Figure 10. Run samples and verify</p> <p>Struts application graphical representation</p> <p>WebSphere Studio allows you to create a web chart to represent the Struts application.</p> <p>In Web Perspective, right-click on the / Java Source folder under the Web project. Select File => New => Other => Web => Struts => Web Diagram. Enter SubmitDiaGram as File Name. Press Finish. This creates a file called SubmitDiagram.gpg under the / Java Source folder. Go to the web structure view. This view and Outline view are located on the same stack. Expand <Default Module> => Actions => / SUBMIT. Drag the icon with / Submit to the chart. Right click on the icon on the chart => DRAW => Draw All from. Double-click the icon to enter the editor. For example, double-click the / submit icon to enter the Struts-Config.xml editor.</p> <p>Figure 11. Struts web chart</p> <p>Conclude</p> <p>Struts is a powerful framework that is very flexible, and its three application layers are loosely coupled together. Using Struts in the application simplifies future maintenance work and makes the web site easy to expand. WebSphere Studio Version 5.0 provides an easy-to-use Struts plug-in to help you maintain and extend your Web site.</p> <p>Related Information</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-88178.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="88178" 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.038</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 = 'IUzBu8t1pMWNxZIUluL2TQoSeRG9Bq5LXoKMSAYQnGMM9uacEkm2AWiP_2FVBkXpHb45JzaH0K05YE1jyxvkjA7A_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>