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
Dea73Dea73 

Query String help!!!!

Hi, i'm working on a page in VF that displays summary information of an already existing page.

 

The idea is to select an option from a location lookup field and the information about the selected location is to appear. But to be able to do this i need to pass the id of the selected location to my controller to get the information like a sum of certain fields.

 

Could someone tell my how i can accomplish this? I'm a newbie at this.

 

Thanks in advance.

Cool_DevloperCool_Devloper

You can append the ID in the URL of the VF page and then let the controller get it using the "ApexPages.currentPage().getParameters().get()" method!

 

Cool_D

Dea73Dea73

That's what i'm having problems with, i don't know how to append it in the URL. I even tried with a commandbutton but still nothing is working.

 

Any concrete ideas????

Cool_DevloperCool_Devloper

Actually, i think i am confused bout wat ur tryin to do .... :(

Are you trying to open a new page with the sum of values on the previous page? What does this location mean exactly?

Cool_D

Dea73Dea73

OK, here it goes. I have a location page and a Central Office page. These two are linked by a lookupfield in Central Offfice .Data is entered in the central Office page when equipment is ordered for a certain location. Now they want to see summaries of some of that info in a seperate page. Like the total of equipment per location hence the location lookup field in the new VF page.

So my idea was to create a VF page where you select the location and the summary information pertaining the selected location is displayed. But i need the ID of the location selected in the URL so it can be used by my controller, but so far i have not managed to find out how to do it.

I have created a button (to submit the form after selecting a location) that i used URL as the content source and added this

/apex/ViewCOInfo?id=Central_Office_Info__c.LocationId__c} doesn't work either.

 

SO, i'm kinda clueless..been wondering if this is even possible

Cool_DevloperCool_Devloper

Lemme juz sum it up ....

you have a VF page, where you have a list of locations of which the user can select one, and can submit the form.

After this another page is to be opened showing the details of the selected location!

Is this correct? I hope so :)

Cool_D

Dea73Dea73

No, i would like to do a partial refresh on the same page and then show the info on that same page.

Makes sense???:smileyhappy:

Dea73Dea73

in other words, your first statement is correct. The Second statement should be replaced with my previous reply :)

Cool_DevloperCool_Devloper

Cool .. gotcha!

 

Well, what you can do is use the selectRadio component of VF. So that at a time, the user can select only one location.

Now, in the controller, have a getMethod for holding this value selected by the user.

Store the values as ID's in the selectOption method but show them as names in thepage.

So, once you get the selected value in the controller,your job is done and you can fetch the requisite details of the selected location.

You just need to reRender s section for showing it on the same page!

Cool_D

Dea73Dea73

That sounds doable, but only one thing. There are more tahn 20 locations so radio buttons will not be efficient (according to me) is it possible to do it with a selectList ( i think it's almost the same as a drop down list)???

 

 

Cool_DevloperCool_Devloper

Absolutely, you can use a dropdown list as well in the same way!

Definitely doable and easy :)

Cool_D 

Dea73Dea73

Hi, i still can't figure this out and i don't know why.

I keep getting this error and it's driving me crazy.

 

Below is my VF page and controller class...HELP PLEASE!!!

 

 I get this error message when i try to save my VF page: Unknown property 'locations'

<apex:page standardController="Central_Office__c" extensions="OfficeTotal" tabstyle="Central_Office_Info__c">
<apex:actionRegion >
<apex:pageBlock title="Central Office Information">
<apex:form >
Choose a Central Office:&nbsp;&nbsp; <apex:selectList value="{!locations}" size="1">
                         <apex:selectOptions value="{!items}"/>
                         </apex:selectList>&nbsp;
                         <apex:outputPanel onclick="{!centralOfficeTotal}" styleClass="btn">Submit</apex:outputPanel>
                         <apex:actionFunction action="{!centralOfficeTotal}" name=" methodOneInJavascript" rerender="thePageBlock" >
                         <apex:param name="paramid" value="{!items}" />
                         </apex:actionFunction>
                        
                        
</apex:form>
</apex:pageBlock>
</apex:actionRegion>
<apex:outputPanel id="thePageBlock">
<apex:pageBlock title="Information">
<apex:outputField value="{!Central_Office__c.Location_Details__c}"/>
<apex:outputText value="{!TotalDS1}"/>
</apex:pageBlock>
</apex:outputpanel>
</apex:page> 

 

 

I get this error when i try to save my class:Compile Error: Non-void method might not return a value at line 26 column 1

 

public class OfficeTotal {
   
    public double totalDS1 { get; private set; }
    public ID locationNumber{get;set;}
    private final Central_Office__c centralOfficeObj;

    public OfficeTotal(ApexPages.StandardController controller) {
    this.centralOfficeObj = (Central_Office__c)controller.getRecord();
     TotalDS1 = 0;
     locationNumber = ApexPages.currentPage().getParameters().get('paramid');
     getTotals();  
    }
   

public List<SelectOption> getItems() {
        List<SelectOption> lo = new List<SelectOption>();
        for(Location__c p : [SELECT Id, Name
                             FROM Location__c
                             WHERE Location_Type__c = 'CO' and Status__c = 'Lit'])
        lo.add(new SelectOption(p.Id, p.Name));
        return lo;
}  
   
private double getTotals() {
  
for(Central_Office__c ds1:[select DS_Quantity__c
                           from Central_Office__c
                           where Central_Office__c.Location__c = :locationNumber and
                                   DS_Quantity__c != null]) {
                                                totalDS1 += ds1.DS_Quantity__c;}
}
}

Cool_DevloperCool_Devloper

Modified ur controller code-

 

public class OfficeTotal {
   
    public double totalDS1 { get; private set; }

    public String locations { get; set; }
    public ID locationNumber{get;set;}
    private final Central_Office__c centralOfficeObj;

    public OfficeTotal(ApexPages.StandardController controller) {
    this.centralOfficeObj = (Central_Office__c)controller.getRecord();
     TotalDS1 = 0;
     locationNumber = ApexPages.currentPage().getParameters().get('paramid');
     getTotals();  
    }
   

public List<SelectOption> getItems() {
        List<SelectOption> lo = new List<SelectOption>();
        for(Location__c p : [SELECT Id, Name
                             FROM Location__c
                             WHERE Location_Type__c = 'CO' and Status__c = 'Lit'])
        lo.add(new SelectOption(p.Id, p.Name));
        return lo;
}  
   
private void getTotals() {
  
for(Central_Office__c ds1:[select DS_Quantity__c
                           from Central_Office__c
                           where Central_Office__c.Location__c = :locationNumber and
                                   DS_Quantity__c != null]) {
                                                totalDS1 += ds1.DS_Quantity__c;}
}
}

 

try this and see if it compiles successfully;)

Cool_D

Message Edited by Cool_Devloper on 11-30-2009 10:21 AM