Red Hat Bugzilla – Bug 131756
Drop lists currently have to be added as Session variables
Last modified: 2007-04-18 13:11:37 EDT
All our other UI widgets are added as request attributes. But because
of struts we have to add them to the Session.
EMAIL Conversation about the issue:
Yeah, I wasn't pleased with this either, I didn't want to use a
session variable for a widget. Not something that should go in the
So, the reason its there is I did the following while getting
validation to work (this was a few weeks ago, so I could be getting
some of the details off):
1) Started out treating it like a standard request variable:
This works fine if your form is a:
2) Switched the form over to a:
Then, upon hitting the page I got a nasty stacktrace:
javax.servlet.ServletException: Cannot find bean under name
I was like, WTF, what is broken in DynaValidatorForm that makes it no
longer able to recognize Objects within the request when using the:
tag. I did lots of digging and messing around. I tried the following:
a) Adding the collection on the form class as a <form-property> in the
struts-config. This did nothing, lame. Same error.
b) Adding the above collection in step a) and also did a <bean:define>
above the <html:options> tag so it would force it to be available to
the JSP. This sort of worked but once you submitted the page, the
list would become empty.
c) Added it to the session. This worked, but made me feel dirty.
After spending about a day on this annoying problem I felt it was time
to move onto other things. This problem only seems to be related to
the usage of html:options. All the other components on the pages
behaved the same once validation was turned on. One way around it
would be to re-write our own html:options tag, but that seemed a bit
over the top.
It would be interesting to try this with Struts 1.2 and leaving it as
a request variable to see if it was any different.
If anyone else has thoughts on how to *not* use a session variable to
solve this problem, I'd definitely appreciate it.
Chip Turner wrote:
> EditAddressAction uses a setSession to set the list of available
> countries for a user; is this absolutely necessary? It makes sense to
> put something like this at the -request- scope, but session scope
> means it'll last around foreverandever... is that what we really want?
> Likewise for prefixes on the CreateUserAction?
> There is a comment that says struts throws them away if validation
> fails, but when validation fails, shouldn't it be sending a failure to
> a page that has as its pre-render-action the code that sets these up
> at the request scope? I'm not quite following the flow of what
*** Bug 137431 has been marked as a duplicate of this bug. ***