function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sugandhi VermaSugandhi Verma 

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];

    }

}
Best Answer chosen by Sugandhi Verma
Sugandhi VermaSugandhi Verma
I have not used apex:param and pass the id in value...it resolves my problem.

All Answers

RishavRishav
Hii Sugandhi ,
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
Sampath KumarSampath Kumar

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.
Sugandhi VermaSugandhi Verma
Hii,
Thanks for answering.My problem is resolved.
RishavRishav
If ur problem resolved then please close this thread by marking the best answer which solved ur problem. it will help others.
Sugandhi VermaSugandhi Verma
I have not used apex:param and pass the id in value...it resolves my problem.
This was selected as the best answer