How to retain value in struts 2 using <s:select></s:select> tag
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
Hi,
I am trying to retain selected values in .jsp using select tag but I could not get proper solution.Can anyone help with the better solution for this.
if you want to add like {companyCode + ',' + branchCode}"
then why you use ',' in between companyCode and branchCode.
Simple addition can looks like "{companyCode + branchCode}"
may be like that.
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
Actually, key sent from jsp is separated using " , " in action class and stored in string[ ] and then using these keys value data is retrieved from database.
#session.COMPANY_LIST is meaningless--you either need to use something like:
#session[@complete.pkg.reference@COMPANY_LIST]
or
#session['companyList']
or something else that makes sense. Other than that it should be fine.
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
By using the same #session value i am getting the values from session and is displayed in drop down list also, even the codes are displayed when tried to print.
Only problem is it is not retaining. :thumbup:
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
COMPANY_LIST is the key for the list<Company Object> stored in session
Sai can you be more clear on what you exactly mean by value is not retained.
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
when i select a value in drop down and click submit button i get related data in the table, but the selected option is not displayed in drop down list. it shows the default value " -- Select -- "
That may be, but a whole bunch of us use <s:select...> with no issues. Switching to an autocompleter brings its own set of issues, and the Dojo tags are deprecated and won't always be around.
Sai Prasad
Ranch Hand
Joined: Feb 08, 2009
Posts: 30
posted
0
Please anyone can help me out with the sample code please
Method to populate country, this part of code is also from action class, i am adding 2 countries hard coded, you can add them dynamically. and call this method in execute method.
If still you face any problem feel free to send a message.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How to retain value in struts 2 using <s:select></s:select> tag