File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes How to access beans from OGNL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to access beans from OGNL" Watch "How to access beans from OGNL" New topic

How to access beans from OGNL

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Im having problems accessing beans from OGNL. It always returns null in the view page. The setters & getters in the actions seem to be working fine when I do a System.out.print. Ill bet Ive tried 100 different ways to access the bean but it always fails. Can anyone shed any lite on this?



Bean Class:

The View:
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Just a quick clarification on what I am trying to accomplish here. I have a site that will have 3 parts for people. A person can be a candidate, client or a customer. All three people types will have the exact same setters / getters. So instead of writing setters / getters in all the Actions for all three person sections of the website I want 1 bean that contains all the setters and getters for a person.

Now the Action will create a new instance of the bean, set/get then the view will pull the values the action set. If I put my setters/getters in the Action the OGNL works fine on the view page. But if I try and have a common bean that is initialized from the action OGNL does not seem to want to pull the values set into the view.

I agree. Here's the link:
subject: How to access beans from OGNL
It's not a secret anymore!