You need to sign in to do that
Don't have an account?
Pass parameter from 1 controller to a visualforce page Url
Hi all,
I have this account search page given below:
<apex:form >
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockButtons location="both">
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Account Name</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection><br/>
<apex:actionStatus id="status" startText="Searching... please wait..."/>
<apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1">
<apex:pageBlockTable value="{!searchResults}" var="item" rendered="{!NOT(ISNULL(searchResults))}" width="100%" columns="3">
<apex:column headerValue="Select" width="10%">
<apex:commandButton value="Select" action="{!Redir}">
<apex:param name="msg" value="{!item.id}" assignTo="{!itemId}"/>
</apex:commandButton>
</apex:column>
<apex:column value="{!item.Name}" headerValue="Account Name" width="45%"/>
<apex:column value="{!item.Control_Number__c}" headerValue="Account Control Number" width="45%"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
On click of select button I want Account Id of selected accoutn to be passed into URL of another page:
Here is the cntroller:
public with sharing class ItemEditController {
public ItemEditController(ApexPages.StandardController controller) {
}
private ApexPages.StandardController controller {get; set;}
public List<Account> searchResults {get;set;}
public string searchText {get;set;}
public string itemID {get;set;}
// standard controller - Display all records present in the system
public ItemEditController()
{
String soql= 'select name, Control_Number__c from Account order by name';
Database.query(soql);
}
// fired when the search button is clicked
public PageReference search() {
String qry = 'select id, name,Control_Number__c from Account ' +
'where name LIKE \'%'+searchText+'%\' order by name';
searchResults = Database.query(qry);
return null;
}
// fired for redirection to proposal page when select button is clicked
public PageReference Redir(){
PageReference pageRef = new PageReference(Page.Proposal_Edit.getURL() );
//pageRef.getParameters().put('msg',itemID);
pageRef.setRedirect(false);
return pageRef;
}
public PageReference Redir1()
{
return null;
}
}
I am unable to pass the value in destination URL .please help !!!!!!
Hi
PageReference pageRef = new PageReference('/apex/yourpagename?id='+itemId );
return pageRef;
If not is working plese let me know
All Answers
Hi
PageReference pageRef = new PageReference('/apex/yourpagename?id='+itemId );
return pageRef;
If not is working plese let me know
Hi,
Thanks for your reply, that worked just fine. If it doesn't bother you much , can you please help me resolve one more issue.
I have a vf page that has <apex:inputField> 's in a form , some of them are mandatory . I also have a <apex:commandbutton> of name=cancel. When I click on that I want page to overcome the validations and redirect to another page. How can this be done?
Hey i help 24/7.
If it is StandardController just write
<apex:commandbutton action={!cancel} value=Cancel/>
it will redirect to the previous page.