• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use s:set in Struts 2

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a service which returns a list of manufacturers.
In the JSP file I have the following

<s:bean id="manufacturerService" name="service.ManufacturerService"/>
<s:set name="manufacturers" value="manufacturerService.allManufacturers"/>
${manufacturerService}
${manufacturers}

The ${manufacturerService} produces an output but the getAllManufacturers() method is never called and ${manufacturers} is empty.

Ideally I'd like ${manufacturers} to be a session bean so that the service is only called at the start of the session.

Where am I going wrong? And how do I set the collection in the session? I'm relatively new to Struts 2.

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You wrote: Ideally I'd like ${manufacturers} to be a session bean so that the service is only called at the start of the session.


That's not what makes the service only be called at the start of the session; only *you* control that.

Normally this kind of operation would take place in an action or an interceptor (and if the manufacturers are application-wide data it could happen at application startup).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic