Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Static fields are not populated

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Im new to Struts, I try to execute few of the examples and I struck in one of the issue.
Issue : The action class has static field which is a list. How to populate that list in jsp.

Action Class

struts.xml


while i try to populate the list I got an error ------> str is not a collection/arrray/list (similarly to this)
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's static, it will be shared across the instances of the action and it will be accessed from multiple threads, you'll have to synchronize access to the list!

Why did you make it static? Probably there is a better solution...

while i try to populate the list I got an error ------> str is not a collection/arrray/list (similarly to this)



Can you show us the code..?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Lorand: Actions are instantiated per-request.

We need to see the JSP in order to help.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:@Lorand: Actions are instantiated per-request.



I know that. :confused:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Lorand Komaromi wrote:

David Newton wrote:@Lorand: Actions are instantiated per-request.



I know that. :confused:


Besides that it's a read-only list in the context of a JSP option tag, it's much, much less important to worry about static action properties, unlike in Struts 1. Even a user with multiple tabs/windows open would be hard-pressed to cause a problem.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:
Besides that it's a read-only list in the context of a JSP option tag, it's much, much less important to worry about static action properties, unlike in Struts 1.



Correct me, if I'm wrong, but whether the action gets instantiated for each request or not has nothing to do with the thread safety of a static member, it's still accessed from multiple threads!

And it was not obvious to me that by "populating that list" he referred to the the UI tag in the JSP, I thought he wanted to insert elements in the List... :rolleyes:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Lorand Komaromi wrote:Correct me, if I'm wrong, but whether the action gets instantiated for each request or not has nothing to do with the thread safety of a static member, it's still accessed from multiple threads!


Oh, I understand what you're saying. Yeah, you're right, although my impression was still that it wasn't populating the dropdown as the original poster expected.

I'm not exactly sure what I was thinking, really.
 
lokesh rajarathnam
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize for incomplete posting of my issue.....
The issue is solved.....

Thanks all for your valuable time.....
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic