6
votes
How to avoid hardcoding Visualforce Page names in PageReferences?
I think you should use an explicit reference so it doesn't break while packaging:
PageReference p = Page.TheVisualforcePage;
p.getParameters().put('id', caseId);
Daniel Ballinger has an excellent ...
6
votes
Accepted
How to avoid page reload on standardController standard action (Save)?
try action="{!quickSave}" Standard Controller action
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" ...
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"....
5
votes
Accepted
CommandButton with JavaScript and controller method
Make the variable "doc" static to avoid view state error
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"
...
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 ...
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">
<...
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 ...
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 ...
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}"
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.
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">
<...
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
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 ...
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">
<...
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 ...
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(!...
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" ...
3
votes
Accepted
CommandButton oncomplete JS function not firing
The following works in my testing:
<apex:commandButton value="Reject (Entry Criteria)" onclick="if(!confirm('Are you sure?')){return false};"
action="{!debugSomething}" oncomplete="refreshPage();"...
3
votes
Accepted
How to detect which command button is clicked?
You can pass the parameter in the Javascript function and then check the value for both the case. For example Pass Save from the save button and pass SaveAndNew from save and new button.
Below will ...
3
votes
Accepted
Visualforce CommandButton Open in Existing Window
Add target to the parent tag, as you can see the following code i have added to the <apex:form>, i have tested and it's working
<apex:page standardController="Account" >
<apex:form ...
3
votes
Displaying a list returned from a method on a Visualforce page
Apex is a case-insensitive language. The identifiers pgm and PGM are the same as far as the compiler is concerned. In addition, there is a key logical error in the code populating this variable. Let's ...
3
votes
Accepted
How to include Find Duplicates standard button in visualforce page
As per VF developer guide it would be FindDup
<apex:commandButton action="{!URLFOR($Action.Lead.FindDup, Lead.Id, null, true)}" value="FindDup" />
3
votes
Lightning cancel button in visualforce page
Method -
Using html-5 in doctype in visualforce page means you should use html-formnovalidate and immediate in cancel button. For example
<apex:commandButton action="{!cancel}" value="Cancel" ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
commandbutton × 231visualforce × 175
apex × 87
javascript × 37
rerender × 18
actionfunction × 18
controller × 13
commandlink × 12
pagereference × 9
action × 8
custom-button × 7
button × 7
onclick × 7
jquery × 6
inputtext × 6
apex-param × 6
visualforce-component × 5
css × 5
pageblocktable × 5
repeat × 5
oncomplete × 5
html × 4
controller-extension × 4
method × 4
actionsupport × 4