6 votes
Accepted

How to avoid hardcoding Visualforce Page names in PageReferences?

I think you should use explicit reference so it doesn't breaks while packaging. PageReference p = Page.TheVisualforcePage; p.getParameters().put('id', caseId); Daniel Ballinger has an excellent ...
  • 7,843
6 votes
Accepted

How to avoid page reload on standardController standard action (Save)?

try action="{!quickSave}" Standard Controller action
  • 3,054
6 votes
Accepted

how to call another visualforce page from an apex command button

Put the below code in the controller action method that is being called on click of command button PageReference pr = new PageReference('/apex/yourVFPageName'); pr.getParameters().put('key','value'); ...
6 votes
Accepted

put an image in a command button

You can store the required image in static resource and use it in command button in the following way <apex:commandbutton image="{!URLFOR($Resource.Required_Image)}" id="SaveChanges" reRender="...
6 votes
Accepted

How to disable a apex command button

You should set the btnDisabled class name, as well as setting "disabled". Here's a live example for you to use: <apex:page standardStylesheets="true" lightningStylesheets="false" showHeader="true" ...
  • 462k
5 votes

How to return to the previous page from a Visualforce page?

Why not using JavaScript? Either you can store the previous URL in localStorage and go back there later with document.location or try simply to use window.history.back() http://www.w3schools.com/...
  • 34k
5 votes
Accepted

How do I generate 2 different documents from the same VisualForce page?

You can accomplish this with two buttons and the addition of a second parameter to the URL for the GrantDoc VF page. I would suggest using the ISO 639 language code to keep the language values ...
  • 22.7k
5 votes
Accepted

apex:commandButton updated by apex:actionFunction

One way use action status. Display loading symbol unit your process is not completed. <apex:actionFunction action="{!startRequest}" name="startRequest_JS" ...
  • 22.3k
5 votes
Accepted

Used html button instead of apex command button,controller action not updating new values?why

Values from your page are sent to a controller on form submit. You can see this if you view HTML code generated by your visualforce page <apex:commandButton/> will be an input with type="submit"....
  • 2,121
5 votes
Accepted

CommandButton with JavaScript and controller method

Make the variable "doc" static to avoid view state error
  • 2,168
5 votes
Accepted

How to call apex method from command button on custom visualforce page

You can't specify parameters as you would when calling a method directly from Apex Code. Instead, you have to use apex:param, as shown here: <apex:commandButton action="{!sendEmail}" value="Send ...
  • 462k
5 votes
Accepted

Passing Parameters Commandbutton

Need to be add a DummyID for reRedner. <apex:page controller="clicktest"> <apex:form> <apex:commandButton action="{!Stats_In}" value="click" reRender="dummyId"> <...
  • 2,505
5 votes
Accepted

Embedded VF page's refresh issue

No, that's expected. In fact, this probably shouldn't work at all, because you're prematurely cancelling the actionFunction (it's asynchronous). What you end up with is a situation that's a race ...
  • 462k
5 votes

How can I get this button to pass data to controller?

Take a look at the apex:actionFunction. This allows you to generate a JavaScript function and to call this function from JavaScript in your page (e.g. in an onclick event). The parameters to the ...
  • 31.4k
4 votes
Accepted

Same apex method different output

Even though you only have 1 SOQL statement in your code it gets executed 3 times, once for every call to Count(). If you use a map where the key is the status and the value is the count you can do ...
  • 12.2k
4 votes

Button Render depending on a boolean value

Your first condition is wrong if you are doing NOT in your condition correct syntax is rendered="{!!hasuser}"
  • 10.4k
4 votes
Accepted

commandbutton on a vf page inside a section

Change your javascript function name from new() to something else say new_method() as new is a keyword. It will work.
  • 510
4 votes
Accepted

Make a button on visualforce update the records in an object

If these are all fields that live directly on your custom object, then you can just use the standard controller on your custom object, and then invoke the standard {!save} function on a commandButton/...
4 votes
Accepted

Align a command button using float:center style

There's no such CSS value for "float" of "center." If you want your commandButton to be in the middle of the area, you should do something like this: <div style="text-align: center"> <...
  • 462k
4 votes
Accepted

Unintended Page refresh command button inside form

use reRender attribute on apex:commandButton here is a nice article Implementing Partial Page Updates with Command Links and Buttons where all required steps are listed First, create or identify the ...
3 votes
Accepted

commandButton only executes first row

The previous openWindowPopup function was always taking password value of first record because of below line, var passwordValue = document.getElementsByClassName("passwordId")[0].value; Hence i ...
  • 2,239
3 votes

ReRender doesn't work

The problem is your contactCreation property. If you check your controller's constructor, a default 'false' value is set for it and consequently your Visualforce page will not render your 'viewNew' ...
  • 931
3 votes

How to return to the previous page from a Visualforce page?

try this, PageReference returnPage = new PageReference(ApexPages.currentPage().getParameters().get('retURL'));
3 votes
Accepted

How does default command button of VF page work?

Visualforce does not allow you to change the default command button. It would in fact be difficult, because the default behavior comes from the browser. In most browsers, if enter is pressed while ...
  • 11.4k
3 votes
Accepted

Problem in reRender of <apex:detail> tag on click of commandbutton

It's look like inlineEdit couldn't be binded with dynamic boolean. Try to create two detail and render them accordingly: <apex:tab label="Details" name="AccDetails" id="tabdetails"> <...
  • 4,095
3 votes

Is there a apex command button that allows you to not refresh the page?

Ok, there are a couple of things going on here: When you include merge syntax in javascript they do not get updated when the properties in the controller get updated unless you rerender them. When I ...
  • 53.6k
3 votes
Accepted

Making a command button open in new tab

You can try with a CommandLink as: <apex:commandLink target="_blank" styleClass="btn" style="text-decoration:none;padding:4px;" action="https://c.eu6.visual.force.com/apex/AmountSpent2?core....
3 votes
Accepted

Using action and onclick together on command button

If you want to abort the action, return a value. If you do not want to abort the action, do not return a value. Example: <apex:commandButton value="Do Something" onclick="if(!...
  • 462k
3 votes

System.QueryException: unexpected token: = Error is in expression '{!dosearch}' in component

you have problem with string query. Do not use string for SOQL query, until you have to do it, because dynamic SOQL is vulnerable to SOQL Injections. There are two ways to prevent possible SOQL ...
3 votes
Accepted

Only allow one submission with apex CommandButton

I am assuming that your apex:commandbutton is within an apex:form, note that an apex:commandbutton reders to: <input id="thePage:theForm:theButton" type="submit" name="thePage:theForm:theButton" ...
  • 19.8k

Only top scored, non community-wiki answers of a minimum length are eligible