This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm having a really bizarre problem... actually I'm probably just missing something obvious, but I can't seem to figure it out.
I'm writing a bean to the session here (facilityView is my bean with the getter/setter methods):
Here is the form definition in my struts config file:
(I only have two properties defined right now so that I can test it)
Here is a simple JSP I put together to test it out:
The logic:present stuff is what I've been using to debug. Here's the weird thing - outside of the html:form it says the bean exists, and outputs the correct values. Inside the html:form, though, it says the bean exists, but the values are blank. It seems like maybe Struts is overwriting the values I passed in the bean for some reason. I've got this set up exactly like one of my other forms (I think) which works fine. Any ideas?
Once you're inside the form tag I'd imagine that non-scope-specific references to the bean name are referring to the form bean defined by the action config, rather than the session bean. (That sentence sucked; sorry.) If you intended them to be the same actual instance, then you don't need to set anything into session scope or use the jsp:useBean tag--it's just the form for that action, and it'll always be stored in the session.
If you *don't* want them to be the exact same instance, i.e. you want to transfer bean values, you'd need to name the session bean something different so there's no name collision, or just do it in the action itself (preferable).
Joined: Jun 30, 2010
OK, that makes perfect sense. I thought maybe that there was some sort of name collision going.
EDIT: Nevermind... silly question Thanks again for the help.