• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 7633
177
  • 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: 7633
177
  • 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)
 
Normally trees don't drive trucks. Does this tiny ad have a license?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic