SoFunction
Updated on 2025-04-07

Relationships saved and modified in jsp action

Code snippets in Action

Copy the codeThe code is as follows:

private String epid;//Global variables get a comma-separated string
public String getEpid() {
        return epid;
}

public void setEpid(String epid) {
        = epid;
}

public String edit() {
        try {
if ("save".equals(save)) {//Execute when clicking the save button
                return save();
            } else {
                loadInfo();
                return RETURN_EDIT;
            }
        } catch (Exception e) {
            ((), e, className);
            return RETURN_ERROR;
        }
}

private void loadInfo() throws Exception {
epid = ().getParameter("id");//Get a single epid
        Long userid = getLoginUser().getUser().getUserID();
        /**
Function:
Get a single object and put each object into the VO object
The value of the data displayed on the page

        **/

        Ep ep = new Ep();
        ((epid));
        ep = (ep);
        (ep);
// Depart object
        Depart depart = new Depart();
        (());
        (());
        (userid);
        (("0"));
        String str[] = ().split(";");
        String s1 = "";
        for (int i = 0; i < ; i++) {
            s1 = str[0];
        }

        if ("".equals(s1) || null == s1) {
("No route yet");
        } else {
            (s1);
        }
        (depart);
// Dept object
        Dept dept = new Dept();
        dept = (());
        (dept);

}


    public String save() {

        Long deptid = ().getDeptid();
        try {
            Depart depart = ();
            (deptid);

            (depart);
((), "Save successfully!");

            cleanObject();
        } catch (Exception e) {
            ((), e, className);
            return RETURN_ERROR;
        }

        return list();
    }

jap page

Copy the 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/" prefix="web"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:///TR/html4/">
<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/">
        <script language="javascript" type="text/javascript" src="scripts/DatePicker/"></script>
        <script language="javascript" type="text/javascript" src="scripts/"></script>
    </head>
    <body>
        <form action="" method="POST" name="tableform">
        <web:error />
<web:tableTitle name="Modify payment information" />
<s:hidden name="" />//Hide the passed value
        <s:hidden name=""  />
        <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 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 = ("tableform");
        = '<s:property value="#"/>';
        var submitbtn = ("submitbtn");
();//Submit events through js time control
    }
//exhibit
    function query(){
        ='<s:url value="/"/>';
    }
//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>