jsp - Persist a value in a local datastructure in Spring MVC -
experts
my requirement persists/store values user editing against field , edited values should persist next time user opens same page perticular field.
currently page displays total no of registered users against field total registration. totalcount data gets database against field total registration im showing following image display data now when user wants edit total no of registration , user can click pencil image , can edit total registration no. on click of floppy image edited count should saved locally in data structure , next time user visits page again,
user should see last edited/updated value. code base below 1> div display total registration value is
<div class="row-fluid"> <div class ="span2"> <label><spring:message code="registration.total"></spring:message>: </label> </div> <div class = "span3"> <div class="input-mini"> <div class="textval "> <div class = "span3">${regstatusform.total} </div> </div> <div id="pencil" class="span3"> <img src="/static/img/pencil.png" alt="edit" > </div> <div id="save" class="span3"> <img src="/static/img/save.png" alt="save" > </div> <div id="close" class="span3"> <img src="/static/img/close.png" alt="close" > </div> </div> </div>
2> jquery code make editable is
var textvalue = ""; $('#pencil').on('click', function(){ textvalue = $('.textval').text(); $('.textval').html("<input type='textbox' id='textval' value='" + textvalue + "' />"); $(this).hide(); $('#save, #close').show(); }); $('#save').on('click', function(){ $('.textval').text($('#textval').val()); $(this).hide(); $('#close').hide(); $('#pencil').show(); }); $('#close').on('click', function(){ $('.textval').text(textvalue); $(this).hide(); $('#save').hide(); $('#pencil').show(); });
3> css code is
<style type="text/css"> .textbox { height:24px; width:90px; line-height:22px; padding:3px } #textval { width:35px; margin-right:5px } .icons { float:left; width:20px; height:20px; } #save, #close { display:none; width:20px; height:20px; float:left } .textval { float:left; width:35px; height:20px; margin-right:5px } #pencil { display:block } </style>
please suggest suitable way achieve this.
you have 2 options. store in server after form submitted or store on client after user entered text , left field.
in first case create table storing input ids , values , populate fields once render them. imagine there chance servletfilter modifies response.
the second 1 simpler implement jquery , localstorage. can if data can live in 1 browser , if machine used start scratch. easier because on page load run jquery on inputs , fill them values localstorage.
Comments
Post a Comment