This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Portals and Portlets and the fly likes Retaining selected values in a portlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Retaining selected values in a portlet" Watch "Retaining selected values in a portlet" New topic
Author

Retaining selected values in a portlet

yudi raj
Greenhorn

Joined: Nov 11, 2011
Posts: 12
I have few states listed in a drop down menu in a portlet. After clicking on a state, the portlet processes the action method and displays their cities. I have linked the cities with states through SQL. However, when the city is loaded, I need the state value to remain selected. Here is my code


code from processAction method
----------------------------------------


I need to know how would I keep the state as selected after the portlet had loaded cities. I know it had got to do something with boolean flags but I really don't know how to approach the problem. Also, after iterating through cities, I need the first value of the city to be selected. Further, after clicking on a city and submitting, both city and state value should remain selected with previously selected values. Thanks in advance.
Ashish Sarin
author
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
    
    5
Hi Uday,

I would suggest that you look at actionScopedRequestAttributes container-runtime option to retain values. Also, I would recommend using something like Spring Portlet MVC and Spring form tag library to simplify developing your portlets.

regards
ashish


Author of
Getting started with Spring Framework
Portlets in Action
Spring Roo 1.1 Cookbook
Portlets blogSpring Roo blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retaining selected values in a portlet
 
Similar Threads
retreiving data through jsp
problem in inserting session data in jsp/servlet application
<jsp:setProperty> sets null values in the bean
Refresh everything in jsp and start over
help with validation/ 2 functions on submit.