Implementation Code for introducing another page in jsp

Source: Internet
Author: User

Action code snippet

Copy codeThe Code is as follows:
Public String execute (){
String ret = super.exe cute ();

If (RETURN_LIST.equals (ret )){
Return list ();
} Else {
Return ret;
}
}

Public String list (){
String show = this. getRequest (). getParameter ("show ");
If ("show". equals (show )){
Return show ();
}
Deptid = getRequest (). getParameter ("deptid ");
If (StringUtils. isNotBlank (deptid )){
EpVO. getEp (). setDeptid (Long. valueOf (deptid ));
EpVO. setDeptid (deptid );
}
If (StringUtils. isNotBlank (deptname )){
EpVO. getDept (). setDeptname (deptname );
}
If (StringUtils. isNotBlank (plateno )){
EpVO. setPlateno (plateno );
}
If (StringUtils. isBlank (deptid )){
EpVO. getEp (). setDeptid (Long. parseLong ("1 "));
}

Int count = epService. getEpCount (epVO );
PageInfor pageInfor = this. pageInit (this. getRequest (), count );
EpVO. setRownum _ (pageInfor. getRownum _());
EpVO. setRownum (pageInfor. getRownum ());
EpVO. setOrderName (pageInfor. getOrderName ());
List <EpVO> list = epService. getEps (epVO );
This. getRequest (). setAttribute (Constants. QUERY_DATA, list );
This. getRequest (). setAttribute (Constants. PAGE_INFO, pageInfor );

List <Object> editors = new ArrayList <Object> ();
Editors. add (new EditorExt ("text", "deptname", "company "));
Editors. add (new EditorExt ("text", "plateno", "license plate number "));
Editors. add (new EditorExt ("text", "deptid", "ID "));
This. getRequest (). setAttribute ("editor", editors );
List <Object> header = new ArrayList <Object> ();
List <Object> header = new ArrayList <Object> ();
Header. add (new Header ("index", "Serial Number", "index", "2%"); // 1
Header. add (new Header ("epVO. dept. deptname "," department ", null," 6% "); // 2 in jQuery (function (), obtain a common value and use a subscript to take the subscript as its position
Header. add (new Header ("epVO. ep. name", "license plate number", null, "5%"); // 3
Header. add (new Header ("epVO. ep. epid", "internal ID", null, "5%"); // 4
Header. add (new Header ("epVO. ep. eptype", "type", null, "4%"); // 5
Header. add (new Header ("epVO. ep. devid", "device number", null, "8% "));
Header. add (new Header ("epVO. ep. devtype", "device type", null, "4% "));
Header. add (new Header ("epVO. ep. phone", "phone", null, "5% "));
Header. add (new Header ("epVO. ep. charge", "annual service fee", null, "5% "));
Header. add (new Header ("epVO.ep.info", "Remarks", null, "15% "));
This. getRequest (). setAttribute ("header", header );
This. getRequest (). setAttribute ("header", header );

Map <String, String> hidden = new LinkedHashMap <String, String> ();
Hidden. put ("epVO. ep. id", "vehicle ID ");
Hidden. put ("epVO. dept. deptid", "department ID"); // obtain the value in the hidden field from jQuery (function ().
Hidden. put ("epVO. ep. name", "license plate number"); // obtain the value in the hidden field in jQuery (function ().
Hidden. put ("epVO. ep. eptype", "type ");
This. getRequest (). setAttribute ("hidden", hidden );

String flag = this. getRequest (). getParameter ("flag ");
This. getRequest (). setAttribute ("flag", flag );
Return RETURN_LIST;
}

Jsp page reference code snippet

Copy codeThe Code is as follows:
<% @ Page language = "java" contentType = "text/html; charset = UTF-8"
PageEncoding = "UTF-8" %>
<% @ Taglib uri = "/struts-tags" prefix = "s" %>
<% @ Taglib uri = "/WEB-INF/web. tld" prefix = "web" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Base target = "_ self">
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Vehicle Information </title>
<Web: jquery validate = "true" formId = "tableform"/>
<Link type = "text/css" rel = "stylesheet" href = "styles/css.css">
<Script src = "scripts/DatePicker/WdatePicker. js"> </script>
<Script src = "scripts/Globals. js"> </script>
<Script src = "scripts/DhtmlTree/js/dhtmlxcommon. js"> </script>
<Script src = "scripts/DhtmlTree/js/dhtmlxtree. js"> </script>
<Link type = "text/css" rel = "stylesheet"
Href = "scripts/DhtmlTree/css/dhtmlxtree.css">
</Head>

<Body>
<Web: clean editorMeta = "editor"/>
<S: hidden name = "epVO. deptid" id = "deptid"/>
<Web: error/>
<Div id = "query" class = "framesytle">
<! -- Whether it is opened on the page -->
<S: if test = "# attr. flag = 'open'">
<Web: queryTable action = "listEp. action? Flag = open "editorMeta =" editor"
Title = "query condition"/>
<Web: tableList action = "listEp. action? Method = list & flag = open"
HeaderMeta = "header" hiddenMeta = "hidden" title = "query result"
Showlist = "hidden" top = "false" mode = "radio"/>
</S: if>
<S: else>
<Web: queryTable action = "listEp. action" editorMeta = "editor"
Title = "query condition"/>
<Web: tableList action = "listEp. action? Method = list "headerMeta =" header"
HiddenMeta = "hidden" title = "query result" showlist = "hidden" top = "false"
Mode = "radio"/>
</S: else>
</Div>
</Body>
</Html>
<Script language = "JavaScript" type = "text/JavaScript">
// Used for department Query
$ ("# QueryBtn"). removeAttr ('onclick'). click (
Function (){
Var obj = document. forms ['queryform'];
Obj. action = '<s: url value = "/listEp. action"/>'
+ '? Deptid = '+ document. getElementById ('demotid'). value;
Obj. submit ();
});

// The value to be passed when the page is opened
JQuery (function (){
Var flag = '<s: property value = "# attr. flag"/> ';
If (flag = "open "){
$ ("# DataTable tr"). removeAttr ("title"). removeAttr ("ondblclick ");
JQuery (". all_border. hs tbody tr"). attr ("title", "double-click to select ");
JQuery (". all_border. hs tbody tr: gt (0)"). removeAttr ('ondblclick ')
. Dblclick (
Function (){
// Hide the Value list () in the domain
Var name = $ (this). find ("input [name = 'name']")
. Val ();
// Var deptname = $ (this). find ("input [name = 'depptname']"). val ();
Var deptid = $ (this). find (
"Input [name = 'demotid']"). val ();
// Normal value
Var deptname = $ (this). children (). eq (2). text ()
Var info = $ (this). children (). eq (10). text ()
. Split (";") [0];
If (info = ""){
Info = "No route ";
}
Var arr = new Array ();
Arr [0] = name;
Arr [1] = deptname;
Arr [2] = deptid;
Arr [3] = info;

ReturnValue = arr;
Window. close ();
});
}
});

$ (Document)
. Ready (
Function (){
Var deptname = document. getElementById ('deptname'). value;
Var deptid = document. getElementById ('demotid'). value;
Var plateno = document. getElementById ('plateno'). value;

$ ("# QueryTable ")
. Html ("<tbody> <tr class = 'f1f1f1 '> <td align = 'right'> company: </td> <td class = 'r _ border '> <input type = 'text' value =' "+ deptname +" 'id = 'deptname' name = 'deptname' class = 'input _ sytle_1 '> </td> <td align = 'right'> license plate number: </td> <td class = 'r _ border '> <input type = 'text' value =' "+ plateno +" 'id = 'plateno' name = 'plateno' class = 'input _ sytle_1 '> <input type = 'den den' value = '"+ deptid +" 'id = 'deptid' name = 'deptid' class = 'input _ sytle_1 '> </td> </tr> </tbody> ");
Var tree = initDropDownTree ('orgtree ',
'<S: url value = "/commonPage. action? Method = getOrgTree "/> ');
SetTextBoxTree ('deptname', 'deptid', 'orgtree', tree );
});
</Script>

Js code snippet referenced by jsp

Copy codeThe Code is as follows:
<Script language = "JavaScript" type = "text/JavaScript">
// Another page
// The number of IDs on this page is determined based on the number of IDS transmitted from another page.
Function selPlateno (plateno, deptname, deptid, info)
{
Var ret = openWin ("listEp. action? Method = list & flag = open "," 900px "," 500px ");
If (ret! = Undefined ){
Document. getElementById (plateno). value = ret [0];
Document. getElementById (deptname). value = ret [1];
Document. getElementById (deptid). value = ret [2];
Document. getElementById (info). value = ret [3];

}
}

// Load the image to display another page
$ (Document). ready (function (){
//
$ ("# Plateno "). after (" \ "alt = \" select \ "border = \" 0 \ "> ");
});
</Script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.