Develop CMP entity beans and its full client with WSAD 5.0 ​​and SQLServer2k (Part 2: Optimization of client development and per

zhaozj2021-02-16  52

Develop CMP entity beans and its full client with WSAD 5.0 ​​and SQLServer2k (Part 2: Optimization of client development and performance)

ABNERCHAI (Chai Zheng) June 2004

Next: 14, below we write a sessionBean to test our CMP entity bean. Our usual practice is to encapsulate CMP entity beans with sessionBean, and then reference the sessionBean in JavaBean and Servlets and JSP. This makes the CMP entity bean is invisible to the user. The process of creating the sessionbean is as follows: First, then the above steps, build a package in the J2EE view, and name it: com.employee.session, then right click on this package -> New-> Other As shown: Then select EJB-> Enterprise Bean in the pop-up box, as shown in the following figure, and select "Next" into the following figure, after selecting, click Next to enter the picture shown below: In the above figure, select "Session Bean" and enter: Employeesession in the bean name, and select the default package to: com.employee.Session, then click Next. Enter as shown below: There is no need to change here, click "Finish". This creates a Stateless SessionBean, which includes three files: transployeession.java home interface: EmployeessionHome.java bean itself: EmployeessionBean.java • Let's modify SessionBean so that CMP entity bean is packaged.

In the J2EE view, double-click the EmployeessionBean.java file below the com.employee.session package, open it edit, add the method in the class, add the amount of EmployeessionBean.java files as follows: package com.employee.Session; import java .rmi.RemoteException; import java.util.Collection; import java.util.Iterator; import java.util.Vector; import javax.ejb.CreateException; import javax.ejb.FinderException; import javax.naming.InitialContext; import javax. naming.NamingException; import javax.rmi.PortableRemoteObject; import com.employee.com.Employee; import com.employee.com.EmployeeHome; import com.employee.com.EmployeeKey; / ** * Bean implementation class for Enterprise Bean: EmployeeSession * / public class EmployeeSessionBean implements javax.ejb.SessionBean {private javax.ejb.SessionContext mySessionCtx; / ** * getSessionContext * / public javax.ejb.SessionContext getSessionContext () {return mySessionCtx;} / ** * setSessionContext * / public void SetSessionContext (javax.ejb.sessionContext CTX) {MySessionCTX = CTX;} / ** * ejbcreate * / public void ejbcreate () throws javax.ejb.CreateException {} / ** * ejbActivate * / public void ejbActivate () {} / ** * ejbPassivate * / public void ejbPassivate () {} / ** * ejbRemove * / public void ejbRemove () {} / ** * private method to obtain entity Bean Home Interface * @return return entities Bean Home Interface objects * / private EmployeeHome getEmployeeHome () {initialContext initialContext = null; EmployeeHome employeeHome = null; try {initialContext = new initialContext (); Object employeeHomeObject = initialContext.lookup ( "ejb / com / employee / com / EmployeeHome"); employeeHome = (EmployeeHome) PortableRemoteObject.narrow (employeeHomeObject, EmployeeHome class.);} catch (NamingException e) {System.err.println ( " CaughtException: "

E.toString ()); employeeHome = null; e.printStackTrace ();} finally {! If (initialContext = null) try {initialContext.close ();} catch (NamingException e) {}} return employeeHome;} / ** * Private method: Get an entity bean entity object of a corresponding ID, if not found, create an entity bean object * @Param ID: give a given ID * @return returned to the object you want to find entity object corresponding to a given ID * / private Employee getEmployee (int id) {Employee employee = null; EmployeeHome employeeHome = this .getEmployeeHome (); try {try {if (! employeeHome = null) {employee = employeeHome.findByPrimaryKey ( New Employeekey (ID));}} catch (FINDEREXCEPTION E) {system.out.println ("can not find a employee with gived id, so try to create one."); Employee = Employehome.create (ID, NULL, NULL);}} Catch (Exception E) {system.err.println ("caughteption:" E.TOSTRING ()); EMPLOYEE = NULL; E.PrintStackTrace ();} finally {employehome = null;} Return Employee; } / ** * Remote method: Generate an entity bean object record with a given message.

* @Param ID: Given Id * @Param Name given to create an object to create an object's name * @Param email: given an email * @return to create an object to successfully create ID * / public int createoneemployee (int id, String name, String email) {employeeHome employeeHome = this .getEmployeeHome (); try {if (employeeHome = null!) {employeeHome.create (id, name, email);}} catch (RemoteException e) {System .rr.println ("Caughtexception:" E.TOString ()); E.PrintStackTrace ();} catch (createException e) {system.err.println ("caughxt:" E.toString ()); e. PRINTSTACKTRACE ();} finally {EmployeeHome = NULL;} Return ID;} / ** * Remote method: Returns a given ID corresponding object Name * @Param ID: a given ID * @return Returns Name characters of the corresponding ID object string * / public String getNameById (int id) {String name = null; Employee employee = null; employee = this .getEmployee (id); if (! employee = null) try {name = employee.getName ();} catch ( RemoteException e) {system.err.println ("can not get name by given ID!"); EMPLOYEE = NULL; E.PrintStackTrace ();} return name;} / ** * remote method: Return to a given ID corresponding object Email * @Param ID: a given id * @return return Back to the corresponding object id's email string * / public String getEmailById (int id) {String email = null; Employee employee = null; employee = this .getEmployee (id); if (! Employee = null) try {email = employee. Getemail ();} catch (transoteException e) {system.err.println ("can not get email by given ID!"); EMPLOYEE = NULL; E.PrintStackTrace ();} Return Email;} / ** * Remote method : Given an ID and NAME, set the Name corresponding to the ID to a given name * @Param ID: a given ID * @param name, the new name * @return returns the ID * * / Public int setnamebyid (int id, string name) {Employee Employee = NULL; Employee = this .geTemPloyee (ID);

Try {Employee.setName (Name); (RemoteException E) {system.err.println ("can not set name by given ID!"); EMPLOYEE = NULL; E.PrintStackTrace ();} returnid;} / ** * Remote method: given an ID and email, set the Email corresponding to the ID to a given Email * @Param ID: a given ID * @param name, new email * @return returns the setting object the id * * / public int setEmailById (int id, String email) {Employee employee = null; employee = this .getEmployee (id); try {employee.setEmail (email);} catch (RemoteException e) {System.err. Println ("Can Not Set Email By Given (" Can Not Set Email By Given; EMPLOYEE = NULL; E.PrintStackTrace ();} Return ID;} / ** * Remote method: Find all entity bean objects * @return returned all id entity Bean object set is saved Integer * / public collection findAllEmployees () {Vector allId = new Vector (); employeeHome employeeHome = this .getEmployeeHome (); try {if (! employeeHome = null) {collection allEmployee = employeeHome.findAllEmployees (); Iterator iterator = allEmployee.iterator (); while (iterator.hasNext ()) {Employee employee = (Employee) iterator.next (); allId.add (new Integer (employee.g ETID ()));} // end while} // end if} catch ("FindalleMPloyees Caught Exception!"); EMPLOYEEHOME = NULL; E.PrintStackTrace ();} Return AllID } / ** * Remote method: given all the corresponding entity bean objects * @Param Name: The given name * @return returns a collection of all entity bean objects for all entity bean objects, is an Integer saved * / public Collection findAllEmployeesByName (String name) {Vector allId = new Vector (); EmployeeHome employeeHome = this .getEmployeeHome (); try {if (employeeHome = null!) {Collection allEmployee = employeeHome.findByName (name); Iterator iterator = allEmployee .iterator ();

While (item.hasnext ()) {Employee Employee = (EMPLOYEE) Iterator.next (); allid.add (new integer ());} // end while} // end if} catch (Exception e) {System.err.Println ("FindalleMployeesbyName Caught Exception!"); EMPLOYEEHOME = NULL; E.PrintStackTrace ();} return allid;} / ** * Remote method: Give Email Find all corresponding entity bean objects * @param email: set id given email * @return returned to find all entities Bean object is saved Integer * / public collection findAllEmployeesByEmail (String email) {Vector allId = new Vector (); EmployeeHome employeeHome = this .getEmployeeHome (); try {if (employeeHome = null!) {Collection allEmployee = employeeHome.findByEmail (email); Iterator iterator = allEmployee.iterator (); while (iterator.hasNext ()) {Employee employee = (Employee) Iterator.next (); allid.add (new integer ());} // end while} // end if} catch (exception e) {system.err.println ("FindalleMployeesbyemail Caught Exception!" ); EMPLOYEEHOME = NULL; E.PrintStackTrace ();} return allid;}} • then increase the increased PUBLIC method to remote Method, the remote method to improve the following methods: createOneEmployee (), getNameById, getEmailById, setNameById, setEmailById, findAllEmployees, findAllEmployeesByName, findAllEmployeesByEmail, after lifting, profile view of the lower left corner of the screen as shown below: Then, this SessionBean be generated Deploy code, in the hierarchy in the J2EE view, select the Employeesession, right-click, generate deployment code, as shown below: • Note that we have access to entity beans in the SESSIONBEAN above, is the actual JNDI name of the entity bean To obtain references to entity beans. At the same time, the entity bean references the database connection pool is also the JNDI name that uses the database connection to reference the database connection.

However, in many cases, we can use "resource mapping" to access entity beans, that is, when accessing entity beans, use Lookup ("Java: Comp / ENV / EMPLOYEE") to find entity beans, and here The lookup is a standard name space recommended by J2EE. The Employee here is an alias, here it corresponds to our Employee entity bean, which is determined by the resource mapping, that is, the resource map defines here. The correspondence between the JNDI of the alias Employee and entity beans. The advantage of this way of use is that the alias can be written in the program, which is the actual call which EJB is defined in the resource map when the actual call is deployed by the deployment. If you accept the best use of the Fa will bring your EJB development and deployment, please continue to see how to do it to define these resource references, if you don't accept this point of view, you think that you will write EJB's JNDI name in the program, Then please skip the next paragraph and go directly to 18 hours to read. Ok, let's take a look at how to modify our sessionBean, enabling it to access our entity beans by using resource mapping. The first step, modify the code to open the file EmployeeSessionBean.java, wherein Found: private EmployeeHome getEmployeeHome () method, it modified as follows: private EmployeeHome getEmployeeHome () {InitialContext initialContext = null; EmployeeHome employeeHome = null; try { initialContext = new initialContext (); // Object employeeHomeObject = initialContext.lookup ( "ejb / com / employee / entity / EmployeeHome"); // using resource references, not directly using jndi Find Object employeeHomeObject = initialContext.lookup ( "java: comp / env / EmployeeRef "); employeeHome = (EmployeeHome) PortableRemoteObject.narrow (employeeHomeObject, EmployeeHome class);} catch (NamingException e) {System.err.println (." CaughtException: " e.toString ()); employeeHome = NULL; E.PrintStackTrace ();} finally {if (initialContext! = null) Try {INITIALCONTEXT.CLOSE ();} catch (namingexception e) {}} Return EmployeeHome;} In the above code, we only modified One sentence, the method used JNDi to find the entity bean to change the way of using the resource reference, where we use Employeeref alias to reference entity beans. Let's modify the deployment descriptor file to increase the resource reference section.

In the J2EE hierarchical view in the WSAD left J2EE view, open the session bean under the EJB module, double-click the EMPLOYEESSSION, open its deployment descriptor file in the view, select the "Reference" page, as shown below: Select EMPLOYEESSSION, then click the Add button below, as shown below: Select "EJB" reference, click "Next", as shown below: In the figure, select "Enterprise Bean in the current EJB project ", Then select" EMPLOYEE "in the list and modify the EJB / EMPLOYEE to" EMPLOYEEREF "in the" Name ", which is the alias that we are referenced in the program. Then click "Next" and "Finish" in the next step. Return to the deployment descriptor file. As shown below: The system is automatically filled out. Save and exit deployment descriptor write. Regenerate the deployment code of the Employeess, and recompile EJB. • Then, we can launch a universal test client as in step 11 to test our sessionBean. In the J2EE hierarchy in the J2EE view, select the EmployEesession, right-click, run on the server. • Performance, in this section, let's take a look at how to optimize SessionBean to call entity beans performance, because SessionBean passes the remote interface LookUp entity bean, so most of the TOOKUP. To optimize the performance of the SESSIONBean calling entity bean, we will give a reference scheme to use the "reuse home handle" technology. That is, the HOME handle of the entity bean that needs to be called in SessionBean is saved. In order to achieve this, we need to introduce single mode to design an EJBHomeCachehelper class. In the J2EE view, like the SESSIONBEAN in front, create a new package and name: com.ejbhome.helper, then create a new class in this package, and name: EJBHomeCacheHelper, all of which is as follows: (its code is self interpretation) package com.ejbhome.helper; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import com.employee. Entity.emPloyeeHome; / ** * @Author Abnerchai * This method uses single mode to store all entity beans's Home handles, so how many entity beans are stored in the system, then how many home objects are stored in this object. Handle, in this object * When the first initialization is initialized, put all the entity beans's HOME handle is placed in memory. When the other * sessionBean wants to call the entity bean, simply get from the memory, this can Greatly increase the call of * speed and performance.

* / public class ejbhomecachehelper {// Define all references to entity beans here, there are several entity beans, here define several reference constants private static final string Employeeref = "EMPLOYEEREF"; // Using single mode private Static ejbhomecachehelper ejbhomecache = null; // Definition Save All Home Handle Reference Table Private HashTable EjBhometable = New HashTable (); // Using Single Mode, Set the constructor to private private ejbhomecachehelper ()} // Return Table Private Hashtable getejbHomeTable () {return ejbHomeTable;} private synchronized static EjbHomeCacheHelper getInstance () {if (ejbHomeCache == null) {// first run empty, then a build, so that all the shared ejbHomeCache = new EjbHomeCacheHelper (); / / Construction entity BEAN handle set ejbHomeCache.buildHomeHandleCache ();} return ejbHomeCache;} // build all Home Bean entities handle set and saved private void buildHomeHandleCache () {Context ctx = null; Object homeObject = null; EmployeeHome employeeHome = null; Hashtable env = new Hashtable (); env.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); try {ctx = new InitialContext (env); homeObject = ctx.lookup ( " Java: comp / env / employeref "); Emplo YeeHome = (EmployeeHome) PortableRemoteObject.Narrow (HomeObject, EmployeeHome. Class); getejbhometable (); put (EMPLOYEEREF, EMPLOYEHOME); // You can add another reference to entity beans and put it into the cache table, need Quote several entities beans, //, add a few ways to find and put method} catches (Exception e) {E.PrintStackTrace ();} finally {if (ctx! = Null) {Try {ctx.close () (Namingexception E1) {E1.PrintStackTrace ();}} // end if} // end finally} // end BuildHomeHandlecache // The following method is open to external reference entity beans to obtain entity beans HOME handle / / There are several entities Beans,

Here, there are several methods public static employeehome geteMPloyehome () GetInstance (). Getjbhometable (). Get (EMPLOYEEREF);}} // end class then, we use this tool class to call our entity bean Add a method in the EmployeesessionBean.java file: name is: getEmployeeHomeFromCache (), its contents are as follows: / ** * Private method, through entity bean cache to get EMPLOYEHOME interface * can greatly improve performance * @return Return Entity Bean Home interface object * / private employehome getEmployehomefromcache () {return ejbhomecacachehelper.geteMPloyeeHome ();}. This method is used to replace this method when you need to call entity beans to get home. • Let's develop a JavaBean and a JSP page to call our EJB, the process is as follows: In the J2EE view, "File" -> "New" -> "Project" in the point menu, as shown below: Select the left Web, select "Dynamic Web Project" in the middle, click Next. As shown in the figure below: Fill in the HelloWorldWebProject in the project name, and select "Configure Advanced Options" and click "Next" to see the following figure: Select the EAR project as shown in the image to be helloWorldearProject, context root Can't change. Then click "Next", as shown in the figure below: What does not choose in the above picture, click "Finish", in the dialog box shown below, select "OK Modify Server Configuration" and " Do not switch to the web view ". Then, in the left J2EE view of the WSAD, the following figure shows: In the above image, a WebProject project has been created in the current EAR project, which includes two parts: one is Java Source (Java resource), The other is the web content. The former is used to manage and store JavaBean and servlets, which are used to store and manage pages such as JSP and HTML. Next, in the above figure, right click "Java Resources", click the "New" -> "Pack" as shown in the following figure: Pop in the Dialog box shown below: Enter: " com.employee.bean "package name. Click to complete. Then select the J2EE view of the left side, right-click, "New" -> "Class" as shown below: Pop in the dialog box shown below: In this figure, the name column is filled in "Employeejavabean" is made as our JavaBean name, then click "Finish" to open the editing of this JavaBean code window. At this point, right-click on the EmployeWebProject in the J2EE view, select "Properties", then select "Project Reference" on the pop-up dialog box, as shown below: On the right, choose HelloWorldejbProject,.

Next, select the "Java Build Path" on the left side of this figure, select "Project" one in the window on the right, as shown below: Select "HelloWorldejbProject" in the above image, then click OK. In this way, our web project can call EJB. Let's write JavaBean our EmployeeJavabean is used to provide the JSP page to call EJB.

Code written as follows: package com.employee.bean; import java.rmi.RemoteException; import java.util.Hashtable; import javax.ejb.CreateException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import javax.servlet.http.HttpServletRequest; import com.employee.session.EmployeeSessionHome; import com.employee.session.EmployeeSession; public class EmployeeJavaBean {private HttpServletRequest _request = null ; public void init (HttpServletRequest req) {this ._request = req;} private EmployeeSession getEmployeeSession () {Context ctx = null; Object homeObject = null; employeeSessionHome employeeSessionHome = null; EmployeeSession employeeSession = null; Hashtable env = new Hashtable (); env.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); try {ctx = new InitialContext (env); homeObject = ctx.lookup ( "ejb / com / employee / session / EmployeeSessionHome"); Employeessionho me = (EmployeeSessionHome) PortableRemoteObject.narrow (homeObject, EmployeeSessionHome class.); employeeSession = employeeSessionHome.create ();} catch (Exception e) {e.printStackTrace ();} finally {if (! ctx = null) {try { ctx.close ();} catch (NamingException e1) {e1.printStackTrace ();}} // end if} // end finally return employeeSession;} public String getNameByEmployeeID () {String id = this ._request.getParameter ( " ID "); if (id == null) return null; int = null; string name = null; try {name = this .geTemPloyEsession (). GetNameById (int_id);} catch (remoteExce) {E.PrintStackTrace ();} return name

}} Note that for demonstration, I only write only one method in Javabean, which calls the method in the sessionbean. Below we create a new JSP file to call our javabean, the process is as follows: In the J2EE view, right click on WebContent, "New" -> "JSP file" as shown below: In the pop-up dialog box, as shown below: Fill in The file name is index.jsp. Then click Finish. Go to the editing JSP page.

The modified JSP file code as follows: <% @ page language = "java" contenttype = "text / html; charset = GBK "PageEncoding =" GBK "%> index.jsp </ title> </ head> <body > <% String name = null; if (Request.getMethod (). Equalsignorecase ("post")) {Employeejb.init (request); name = Employejb.getNameByEmployeeId ();}%> <p> Please enter you want to find ID: </ p> <form name = "base" method = "post" action = "index.jsp"> <input type = "version" value = "" name = "id"> <input type = "SUBMIT "Value =" Find! "> </ form> <% IF (name! = null) {Out.println (" <p> The name you look for is: " Name " </ p> ");}%> </ Body> </ html> • Test: Start the server, type in the IE address bar: http: // localhost: 9080 / helloworldWebProject / index.jsp, enter 1 in the input box, run as follows As shown in: • Here, our JavaBean is directly called sessionBean. In actual use, we can also use the "reusable home handle" method to carry out performance.</p> <p>First, we modify our JavaBean to invoke the sessionBean in the way, the method is as follows: Open the Employeejavabean .java file, modify the Private Employeesession GetEmployeESession () method. Put this method: HomeObject = ctx.lookup ("EJB / COM / EMPLOYEE / Session / EMPLOYEESSSIONHOME"); replace with: HomeObject = ctx.lookup ("java: comp / ENV / EMPLOYEESSSIONREF"); then, then on the left In the J2EE view, double-click Web.xml under the "Web Content" directory, start the web deployment editor, then select the page "reference" as shown below: In the above figure, single Hit "Add" and modify the name of the automatically generated reference to: "EMPLOYEESSESSIONREF", then select it, enter the necessary information in the right box, the method is as follows: In the right side of the link, click "Browse" on the right side, pop up as shown below Dialog: Double-click the EmployeESession in the figure. WSAD automatically fills the box in the figure. Save it as shown below. At this point, we have to call the JavaBean to change the way as the sessionbean to the resource reference. Below, we use the "reuse home handle" to optimize the performance of JavaBean calling SessionBean.</p> <p>• In order to improve the performance of JavaBean call sessionbean (EJB), we use the same way, we will create a new package under "Java Resources" and name: com.bean.ejbhelper, and create a new class in the package, named: ejbhomefindcachehelper its source code is as follows: package com.bean.ejbhelper; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import com. employee.session.EmployeeSession; import com.employee.session.EmployeeSessionHome; public class EjbHomeFindCacheHelper {// define all references to the name of SessionBean here, there are several SessionBean, a few references here on the definition of constants private static final String EmployeeSessionRef = "EMPLOYEESSESSIONREF"; // Using single mode private static ejbhomefindCachehelper ejbhomeche = null; // Define Save All session handles reference table private hashtable ejbhometable = new hashtable (); // uses single mode to set the constructor to private private EjbHomeFindCacheHelper () {} // return list private Hashtable getejbHomeTable () {return ejbHomeTable;} private synchronized static EjbHomeFindCacheHelper getInstance () {if (ejbHomeCache == null) {// first run empty, then construct a so All shared ejbhomecacche = new ejbhomefin dCacheHelper (); // Construction SessionBean handle set ejbHomeCache.buildHomeHandleCache ();} return ejbHomeCache;} // build the collection of all the Home SessionBean handle and saved private void buildHomeHandleCache () {Context ctx = null; Object homeObject = null; employeeSessionHome employeeSessionHome = null; Hashtable env = new Hashtable (); env.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); try {ctx = new InitialContext (env); // by Configuring resource references in web.xml to find EJB HomeObject = CTX.lookup ("Java: Comp / Env /" EmployeesessionRef; EmployeesessionHome =</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-21087.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="21087" 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.044</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 = 'wlqYpGErYASL46Z6_2FFSkaLbTTpGZk3h_2BYki19tx6DwlH3Q0fmnT5zxtbr98vvl_2Bj_2Bb3PmoBa9jJ_2B2c8R'; 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>