Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

design problem

 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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):
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic