servlets - Edit form input details in jsp -


i have made input form takes input , stores in database using jsp , servlets. form has edit details button. want when user clicks button form should autofill old values , allow user change values. , new values should updated in database. here screenshot of form. please help...

enter image description here

it depends want do. can either client side or server side. client site refer post below. what best way track changes in form via javascript?

for server side

if orm can use saveorupdate() call. read does.

or

make 2 datatransfer objects lets call them loadtimeobject , submitobject.

assuming flow , domain model here.

  1. edit details button click -> row id or primary key/unique row/or id.
  2. load data fields make ajax call or if data available in javascript object, using row/object id - refer loadtimeobject
  3. user makes/does not make changes , click on submit. load form fields submitobject. in java validate if loadtimeobject , submitobject differ? track fields changes , persist them in db.

hint:you may use apache commons beanutils compareobjects(object loadtimeobject , object submitobject) methods.

or

use java reflection compare objects.

public static <t> void compare(t source, t target) throws illegalargumentexception, illegalaccessexception {              if(source == null) {                 throw new illegalargumentexception("null argument not excepted @ point");             }              field[] fields = source.getclass().getfields();              object sourceobject;             object targetobject;              for(field field : fields){                 sourceobject = field.get(source);                 targetobject = field.get(target);                  //compare object              }          } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -