This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Access static variable from form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Access static variable from form bean" Watch "Access static variable from form bean" New topic
Author

Access static variable from form bean

Michael Quirk
Greenhorn

Joined: Feb 23, 2011
Posts: 8
Sorry if I'm reposting, but I couldn't find a similar problem.

I'm looking to access a static variable on my jsp that is contained in a form bean. I'm developing with Struts and haven't figured out how to do it on my own.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

If it's got static elements it isn't a properly formed bean. Can you not just create an accessor and treat it like a non-static property?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Quirk
Greenhorn

Joined: Feb 23, 2011
Posts: 8
I could, but I would want to have the fields at least a 'final'. Does this break the form bean standard?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Don't give the field a mutator.

Bear in mind that makes the field read-only. For everything.
Michael Quirk
Greenhorn

Joined: Feb 23, 2011
Posts: 8
Okay, thanks for the help Bear.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Access static variable from form bean
 
Similar Threads
How does Spring framework handle Singleton in its implementation?
Can we define static properties in action form bean?
Drop down box in Struts
help with variable modifiers
How to access the gettr/setter method of embeded object inside the form bean.