• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Total Votes of each post

 
Greenhorn
Posts: 24
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need help with Java in the Jforum. So, I've been trying to get the Total of votes from each post. For that:

In generic_queries.sql I put the following query where I supposed to get the total of votes, I tested in MySQL and I get the result I want:



Then, I want to get this result in post_show_action_buttons.htm with .

So, what I did in GenericKarmaDao.java



Then in KarmaDao.java



In



Please, I need your help. I always tried to create a new query and get information that I want to get, but I never succeed on the attempt. Please help me to identify where I'm wrong.

Thank you!!
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what does this code do now, where does that start to deviate from what you want it to do, and where are you stuck making the required changes?

The FreeMarker syntax is wrong, it should be "totalVotes" rather than "getTotalVotes()", similar to the change you needed to make in one of the other questions you asked.
 
Jackie Bermudez
Greenhorn
Posts: 24
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get "0" if I use ${post.karma.totalVotes}, it doesn't work. I need the total of votes of each post, for that I created a new query, so I want to pull the information that the query is giving me. The code that I put there is new to be able to display the number on the forum.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you need to investigate where it starts to go wrong. For example, is the if condition in line 13 ever true? If yes, is the value it retrieves correct? If the answers are both "yes", is the KarmaStatus object being used in the template the same one where you set the value?
 
Jackie Bermudez
Greenhorn
Posts: 24
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it working. That wasn't the problem, I didn't have to do anything on KarmaStatus(final KarmaStatus karma).

Classes that I used and steps:
generic_queries.sql (Create the query)
GenericKarmaDAO (Execute the query)
KarmaStatus.java (set and get)
KarmaDAO (get the post id)
Post.java (constructor)
GenericPostDAO.java (set the total of votes)
reply
    Bookmark Topic Watch Topic
  • New Topic