Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
I am trying to create two buttons that inserts Up and Down on a record by clicking a command button. Here is my code so far:

VF Page:

 

<apex:form id="votingSection">

<apex:pageBlock mode="edit">

<apex:pageBlockButtons location="bottom">

<apex:commandButton styleclass="btn-lg btn-data" value="Vote Up" action="{!voteUp}" reRender="votingSection"/>

<apex:commandButton styleclass="btn-lg btn-data" value="Vote Down" action="{!voteDown}" reRender="votingSection"/>

</apex:pageBlockButtons>

</apex:pageBlock>

</apex:form>

Extension:

  

public class detExt2 {

private final my_object__c myObject;

public detExt2() {

myIdea = [SELECT Id, Vote_Button__c, Name FROM my_object__c

WHERE Id = :ApexPages.currentPage().getParameters().get('id')];

}

public my_object__c getObject() {

return myObject;

}

public PageReference voteUp() {

myIdea.Vote_Button__c = 'Up';

update myObject;

return null;

}

public PageReference voteDown() {

myIdea.my_object__c = 'Down';

update myObject;

return null;

}

}

Any ideas on how to make this work? Also, I'm trying to figure out how to implement unique votes by user. 

Thanks!
1 answer
  1. Feb 4, 2015, 8:17 PM
    Hello,

    What is not working in your VF?

    Regards.
0/9000