You need to sign in to do that
Don't have an account?

not getting result on 2nd visualforce page
hi, i want create 2 visualforce pages with a controller using custom object.In the first page, i want to select the one record and pass it's id to another visual force page which will show it's details using query string.But i am getting no result in 2nd page ,in the url i am getting the id but it is appending with AAK.
Please review my code.
1st Visualforce page:
<apex:page controller="MytranschController">
<apex:form >
<apex:dataList value="{!myaccounts}" var="tr">
<apex:outputField value="{!tr.Name}"> </apex:outputField><br></br>
<apex:outputLink onclick="accountClicked()" value="/apex/secondpage" >
<apex:param name="oid" value="{!tr.Id}" assignTo="{!selectedAccount}"/>
View
</apex:outputLink>
</apex:dataList></apex:form>
</apex:page>
2nd Visualforce page:
<apex:page controller="MytranschController">
<apex:outputPanel id="id1">
<apex:repeat value="{!contactsInformation}" var="t">
<apex:detail subject="{!$CurrentPage.parameters.oid}" relatedList="false" title="false" />
<p> <apex:outputField value="{!t.Name}"/> </p>
<p>
<apex:outputField value="{!t.Transp_Image__c}"> </apex:outputField></p>
</apex:repeat>
</apex:outputPanel>
</apex:page>
Class
public class MytranschController {
//String value = ApexPages.currentPage().getParameters().get(name);
public Id selectedAccount{get; set;}
public List<Transportation_Mediums__c> contactsInformation{ get; set;}
public List<Transportation_Mediums__c> getMyAccounts() {
return [Select Id,Name,Trans_Image__c,Transportaion_Cost__c from Transportation_Mediums__c ];
}
public void accountClicked()
{
contactsInformation=[Select Name,Transp_Image__c from Transportation_Mediums__c where Id=:selectedAccount];
}
}
Please review my code.
1st Visualforce page:
<apex:page controller="MytranschController">
<apex:form >
<apex:dataList value="{!myaccounts}" var="tr">
<apex:outputField value="{!tr.Name}"> </apex:outputField><br></br>
<apex:outputLink onclick="accountClicked()" value="/apex/secondpage" >
<apex:param name="oid" value="{!tr.Id}" assignTo="{!selectedAccount}"/>
View
</apex:outputLink>
</apex:dataList></apex:form>
</apex:page>
2nd Visualforce page:
<apex:page controller="MytranschController">
<apex:outputPanel id="id1">
<apex:repeat value="{!contactsInformation}" var="t">
<apex:detail subject="{!$CurrentPage.parameters.oid}" relatedList="false" title="false" />
<p> <apex:outputField value="{!t.Name}"/> </p>
<p>
<apex:outputField value="{!t.Transp_Image__c}"> </apex:outputField></p>
</apex:repeat>
</apex:outputPanel>
</apex:page>
Class
public class MytranschController {
//String value = ApexPages.currentPage().getParameters().get(name);
public Id selectedAccount{get; set;}
public List<Transportation_Mediums__c> contactsInformation{ get; set;}
public List<Transportation_Mediums__c> getMyAccounts() {
return [Select Id,Name,Trans_Image__c,Transportaion_Cost__c from Transportation_Mediums__c ];
}
public void accountClicked()
{
contactsInformation=[Select Name,Transp_Image__c from Transportation_Mediums__c where Id=:selectedAccount];
}
}
All Answers
Please follow this link once if u want to make visualforce wizard:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_wizard.htm
thanks
Rishav
Hi Sugandhi,
I am using <apex:commandButton> instead of <apex:outputLink> and modified below code.
1st Visualforce page:
<apex:page controller="MytranschController">
<apex:form >
<apex:dataList value="{!myaccounts}" var="tr">
<apex:outputField value="{!tr.Name}"> </apex:outputField><br></br>
<apex:commandButton onclick="accountClicked()" value="click me" rerender="all">
<apex:param name="oid" value="{!tr.Id}" assignTo="{!selectedAccount}"/>
View
</apex:CommandButton>
</apex:dataList></apex:form>
</apex:page>
2nd Visualforce page:
<apex:page controller="MytranschController">
<apex:outputPanel id="id1">
<apex:repeat value="{!contactsInformation}" var="t">
<apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false" />
<p> <apex:outputField value="{!t.Name}"/> </p>
<p>
<apex:outputField value="{!t.Transp_Image__c}"> </apex:outputField></p>
</apex:repeat>
</apex:outputPanel>
</apex:page>
Class
public class MytranschController {
//String value = ApexPages.currentPage().getParameters().get(name);
public Id selectedAccount{get; set;}
public List<Transportation_Mediums__c> contactsInformation{ get; set;}
public List<Transportation_Mediums__c> getMyAccounts() {
return [Select Id,Name,Trans_Image__c,Transportaion_Cost__c from Transportation_Mediums__c ];
}
public PageReference accountClicked()
{
contactsInformation=[Select Name,Transp_Image__c from Transportation_Mediums__c where Id=:selectedAccount];
pageReference MyNewPage = new pageReference('/apex/your 2nd visualforce page goes here');
MyNewPage.getParameters().put('id',selectedAccount);
MyNewPage.setRedirect(true);
return MyNewPage;
}
}
Mark this as best answer if this solves your query.
Thanks for answering.My problem is resolved.