Saved and modified relationship in jsp action

Source: Internet
Author: User

Code snippet in Action

Copy codeThe Code is as follows:
Private String epid; // The global variable returns a comma-separated String.
Public String getEpid (){
Return epid;
}

Public void setEpid (String epid ){
This. epid = epid;
}

Public String edit (){
Try {
If ("save". equals (save) {// run the command when you click the save button.
Return save ();
} Else {
LoadInfo ();
Return RETURN_EDIT;
}
} Catch (Exception e ){
Super. printErrors (this. getRequest (), e, className );
Return RETURN_ERROR;
}
}

Private void loadInfo () throws Exception {
Epid = this. getRequest (). getParameter ("id"); // obtain a single epid
Long userid = getLoginUser (). getUser (). getUserID ();
/**
Function:
Obtain a single object and place each object in the VO object
Data value displayed on the page

**/

Ep ep = new Ep ();
Ep. setId (Long. parseLong (epid ));
Ep = epService. getEpById (ep );
EpVO. setEp (ep );
// Depart object
Depart depart = new Depart ();
Depart. setDeptID (ep. getDeptid ());
Depart. setPlateNumber (ep. getName ());
Depart. setCreateBy (userid );
Depart. setJudgeType (Integer. parseInt ("0 "));
String str [] = ep. getInfo (). split (";");
String s1 = "";
For (int I = 0; I <str. length; I ++ ){
S1 = str [0];
}

If ("". equals (s1) | null = s1 ){
Depart. setRoute ("No route available ");
} Else {
Depart. setRoute (s1 );
}
EpVO. setDepart (depart );
// Dept object
Dept dept = new Dept ();
Dept = deptService. getDeptById (ep. getDeptid ());
EpVO. setDept (dept );

}


Public String save (){

Long deptid = epVO. getDept (). getDeptid ();
Try {
Depart depart = epVO. getDepart ();
Depart. setDeptID (deptid );

Using service. insertDepart (depart );
Super. printMsg (this. getRequest (), "saved successfully! ");

CleanObject ();
} Catch (Exception e ){
Super. printErrors (this. getRequest (), e, className );
Return RETURN_ERROR;
}

Return list ();
}

Jap page

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>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> modify payment information </title>
<Web: jquery validate = "true" formId = "tableform"/>
<Link type = "text/css" rel = "stylesheet" href = "styles/css.css">
<Script language = "javascript" type = "text/javascript" src = "scripts/DatePicker/WdatePicker. js"> </script>
<Script language = "javascript" type = "text/javascript" src = "scripts/Globals. js"> </script>
</Head>
<Body>
<Form action = "" method = "POST" id = "tableform" name = "tableform">
<Web: error/>
<Web: tableTitle name = "modifying payment information"/>
<S: hidden name = "epVO. dept. deptid" id = "deptid"/> // hide the passed Value
<S: hidden name = "epVO. depart. createBy"/>
<S: hidden name = "id"/>
<Div class = "table_border">
<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" class = "hs">

</Table>
</Div>
<Div class = "t_center">
<Input id = "submitbtn" type = "submit" value = "save" style = "display: none"/>
<A href = "#" class = "sava_ B B" onclick = "save ()"> save </a>
</Div>
</Form>
</Body>
</Html>

<Script language = "JavaScript" type = "text/JavaScript">
// Save
Function save (){
Var obj = document. getElementById ("tableform ");
Obj. action = '<s: property value = "# request. saveUrl"/> ';
Var submitbtn = document. getElementById ("submitbtn ");
Submitbtn. click (); // submit an event through js Time Control
}
// Display
Function query (){
Window. location. href = '<s: url value = "/listEp. action"/> ';
}
// Load the date Control
$ (Document). ready (function (){
AddFormValidator ();
$ ("# SendTime"). attr ("readonly", "readonly ");
$ ("# SendTime "). click (function () {WdatePicker ({isShowClear: false, dateFmt: 'yyyy-MM-dd HH: mm: ss '});});
});

</Script>

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.