This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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)
Lorand Komaromi
Ranch Hand
Joined: Oct 08, 2009
Posts: 276
posted
0
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)
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
Joined: Oct 08, 2009
Posts: 276
posted
0
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:
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
Joined: May 17, 2007
Posts: 35
posted
0
I apologize for incomplete posting of my issue.....
The issue is solved.....
Thanks all for your valuable time.....
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.