Problem scenarios?
During project development, I submitted data in the form of a nested list inside the form, and submitted and saved the form data in the list at the same time. Sometimes I have added several new creden to the Administrator structure, but they are not actually saved to the database at this time. Instead, they are saved on the front end of the page for temporary storage and are waiting for the real submission. In this case, the deletion implementation method is as follows:
function delFundManage(obj){
$(obj).parent().parent().remove();
}
Removed, but when creating the list
To remove the first
Arr [1] is not changed to ARR [0]. After the data is submitted to the background, the following table is 1. Therefore, two data entries are displayed. This empty data cannot exist. Therefore, you need to judge the current object. whether all attribute values are empty
Go to the topic to determine whether the object's attribute value is null and use the reflection idea:
Private Boolean checkobjfiledsisnull (Object OBJ) {Boolean flag = false; int COUNT = 0; Class <?> Clazz = obj. getclass (); field [] fields = clazz. getdeclaredfields (); For (field: fields) {field. setaccessible (true); try {If (field. get (OBJ) = NULL) {count ++; If (COUNT = fields. length) {flag = true ;}} catch (exception e) {logger. error ("Object Property check exception:" + E) ;}return flag ;}
The difference between getfields () and getdeclaredfields () is designed here:
Getfield () obtains the public-modified attribute in the class.
All obtained by getdeclaredfields () does not include inheritance attributes.
When you are familiar with private operations, use the setaccessible (true) method to erase them.
Determines whether the object's property value is empty through reflection