my dog learned polymorphism*
The moose likes JSP and the fly likes design problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "design problem" Watch "design problem" New topic
Author

design problem

Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
I'm trying to get my result displayed in a JSP by using the JSTL SQL tag's implementation class and a struts 2 like MVC approach.
The problem is that i can't get a hold on the object from the jsp (i get null):
DAO.java gets the data, Data.java configures DAO, data.jsp can't get a hold of the object from either DAO or Data no matter what i tried.







Any thoughts?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The JSP is using the action itself as the "result" bean, not the action's property named "result". Just take out the useBean tag; S2 exposes the action on the value stack. I'm not sure why you're talking about SQL tags; I don't see any.
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
Thank you, it worked, now i need a redesign because i think its rather ugly like this, how would i subclass ResultImpl to have access directly to the properties?
I was refering to ResultImpl which is the class that populates the variable for the sql tag, i am using it in my code.

I lost a wonderful article on the context, value stack and objects on it with a garphical representation, and a ton of examples (not the struts 2 or OGNL docs as far as i remember), if someone could re-link me to it i would be most grateful.

Changed:


and added to Data.java

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh, now I see why you talked about SQL tags. I really have no idea why you're doing that; maybe someone else will help you out.
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
I'm trying getting into the habit of reusing existing functionality, speaking of which i have a further problem with it: the sorted stuff is sorted naturally by default, resulting in the id column beeing represented after the date column (because of alphabetical order is my guess). I also need some help fixing that behaviour from the root because i don't want the jsp doing any logic this time.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The sorting can be handled with the SQL.

Reusing existing functionality *is* a good goal, but it's also a good idea to reuse *appropriate* functionality--IMO this really, really isn't it. Many other, more common solutions exist. If it's just you that will ever work on the project then I suppose it doesn't really matter, but this is a pretty twisted dependency.
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
I changed the SQL, it doesn't work, it's because of the SortedMap (which is a blunder IMO - why would i need a sorted map for columns when SQL does the sorting):
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: design problem