You need to sign in to do that
Don't have an account?
Page Redirect Issue
Hi,
I have two button on visual force page. One is apex command button and another is outputpanel with styleclass= btn.From apex command button I am calling execute method using action while in outputpanel I am calling execute method using actionFunction.In Execute, code create lead record and redirect to lead defualt list page.
It is working fine in case of apex command button but in case of outputpanel, code redirect the page on lead defualt page but it does not change url and also keeping page editor and component in page. Please guide.
Please help
<apex:page controller="VFJavaScriptDemo" >
<apex:form id="actionForm">
<apex:actionFunction id="executeId" name="executeData" action="{!execute}" reRender="dataForm"/>
</apex:form>
<apex:form id="dataForm" >
<apex:inputText id="value" value="{!name}"/>
<apex:commandButton id="Save" value="Submit" action="{!execute}"/>
<apex:outputPanel onclick="checkJavaScript()" styleClass="btn">
Click Me
</apex:outputPanel>
</apex:form>
<script>
function checkJavaScript() {
alert('inside');
executeData();
}
</script>
</apex:page>
public class VFJavaScriptDemo {
public String name { get; set;}
public PageReference execute() {
Lead l = new Lead(
lastname = 'VFJavaScript Testing',
company = 'sungard'
);
insert l;
PageReference pg = new PageReference('/00Q/o');
pg.setRedirect(true);
return pg;
}
}
no, really.
if you turn off developer mode,
both the edit window goes away and the redirect occurs correctly, nothing to do with the code.
All Answers
I think you are calling Visualforce method from Javascript. You might have to use actionFunction
Look at this example from docs: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm
I have not used it but try somethink like
Ryan
no, really.
if you turn off developer mode,
both the edit window goes away and the redirect occurs correctly, nothing to do with the code.
As a follow up i would like to point out that this page is best written with one apex : form tag
each form tag carries a seperate viewstate and this can make your page larger and slower, for no gain.
I think this is related to page redirect
I have a custom controller, and 2 visual force pages.
My page1 is Inside account page layout. Page 1 has a button that post page2
Page 2 posts inside the section of account. How do I post my page 2 to new page.
When I test with the following URL it works - page 2 is posted properly
https://cs2.salesforce.com/apex/MytestPage1?id=066Q000000001ZM
When I test with following URL after adding to account page layout Page 2 is inside the account section
https://cs2.salesforce.com/066Q000000001ZM
Here my code:
Controller:
Page1 - added to account page layout
Page2 - post from with button click on page1
I tried using commandLink instead of Commandbutton and used target="_blank" But the page does not display header and sidebar.
NOTE: My page 1 has showHeader="false" Page 2 has showHeader="true"
I turned off DevelpmentMode in user setting.