java - Passing value to JSP in spring -
i have 3 tabs href links,
<ul > <li class="active"> <a href="#tab_0" id="tab1" data-toggle="tab">search booking id</a> </li> <li> <a href="#tab_1" id="tab2" data-toggle="tab">today's booking</a> </li> <li> <a href="#tab_2" id="tab3" data-toggle="tab">search date</a> </li> </ul>
when submitting form in each tab, i'm passing value server know tab i've selected, using hidden input field < input type=hidden value="tab1" id="view"/>. want same value on jsp page , select corresponding tab, on page load. i'm using spring framework. tried adding additional object in modelandview,
modelandview model = new modelandview(); model.addobject("view", view);
and script code is:
$(document).ready(function() { var activetab = ${view}; if(activetab == "tab1"){ $("#tab1").click(); } else if(activetab == "tab2"){ $("#tab2").click(); }else if(activetab == "tab3"){ $("#tab3").click(); }else{ $("#tab1").click(); } });
but not working. :( please help.
you don't need javascript
code. since adding view
value in response, can use el
enforce active
css class in jsp file specified tab, this
<ul > <li ${view eq "tab1"?'class="active"':''}> <a href="#tab_0" id="tab1" data-toggle="tab">search booking id</a> </li> <li ${view eq "tab2"?'class="active"':''}> <a href="#tab_1" id="tab2" data-toggle="tab">today's booking</a> </li> <li ${view eq "tab3"?'class="active"':''}> <a href="#tab_2" id="tab3" data-toggle="tab">search date</a> </li> </ul>
Comments
Post a Comment