Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Struts LinkedHashMap list request scope

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have an issue in struts 1.3,  getting data from database in the form of key , value pair , key is an Integer and value is a customer object,  able to display using logic iterate tag,

ActionForm having setter and getters of type LinkedHashMap (Integer, customer)
Scope of actionform request

Problem is when I submit request  lossing LinkedHashMap object data,  how to retain data in  action form  
 
Bartender
Posts: 9559
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 1.x is past end of life and is unsupported.  If it is at all possible, upgrade to the latest version of Struts 2 or another framework.
If you want to persist a collection to a JSP and recover it later, you have to use indexed properties.  If you aren't displaying the properties on the page, it may be easier to put the value in the session.
 
Chakravathy Rajan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am trying similar to the example given in indexed properties. able to successfully retain data using indexed properties  if i keep data in list.
but for LinkedHashMap if i got any example its very help ful.

how to declare in form and  how to iterate in jsp.

my code in form written like below
private LinkedHashMap<Integer,Customer> simTypeMaPlist;

public LinkedHashMap<Integer, Customer> getSimTypeMaPlist() {
return simTypeMaPlist;
}
public void setSimTypeMaPlist(
LinkedHashMap<Integer, Customer> simTypeMaPlist) {
this.simTypeMaPlist = simTypeMaPlist;
}

public Customer getSimMapItem( int key ) {
       if (this.simTypeMaPlist == null) {
           this.simTypeMaPlist = new LinkedHashMap<Integer, Customer>();
       }
       while (!(this.simTypeMaPlist.containsKey(key))) {
           this.simTypeMaPlist.put( key,new IndividualContact() );
       }
       return (Customer) this.simTypeMaPlist.get( key );


jsp
<logic:iterate id="simItem1" name="SampleForm" property="simTypeMaPlist"  indexId="idx">
<html:hidden name="simItem1" property ="key" indexed="true"/>
<html:hidden name="simItem1" property ="value" indexed="true"/>
            <bean:write name="simItem1" property="value.firstName"/>
<bean:write name="simItem1" property="key"/>
               
</logic:iterate>


please correct  , so that i can retain values when i form submit.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!