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

Doubt : how to pass the standard state and country picklist to apex controller page
Hi,
My scenario is,
I have to get the details by location(State or Country).1st preference is State.
My output will be,

The input fields are Standard Country and State picklist .
The state or country (input) has pass to the apex controller.
[ Eg:
1.country :USA State: NY---- input will be NY(State)
2. country:Iceland State : No States ,------ input will be Iceland(Country)
]
I dont know how to pass theat selected state picklist value to apex controller.
But i written some piece of codes.Please verify it and correct it. If anyone knows please tell me.
My Apex Code:
Public with sharing class SOSLController{
Public List<loc__c> location {get;set;} // location
public String imageURL{get;set;} // display a image
Public String searchStr{get;set;} // find a string
private ApexPages.StandardController stdController;
/* display a image -method*/
public SOSLController(ApexPages.StandardController stdController)
{
imageURL='/servlet/servlet.FileDownload?file=';
List< document > documentList=[select name from document where
Name='logo'];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}
}
/* find a string and run the sosl query*/
Public void soslDemo_method(){
location = New List<loc__c>();
if(searchStr.length() > 1){
String searchStr1 = searchStr;
// System.debug('message');
String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c )';
List<List <sObject>> searchList = search.query(searchQuery);
location = ((List<loc__c>)searchList[0]);
/* Message */
if(location.size() == 0){
apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
return;
}}
else{
apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
return;
}}}
My VFP:
<apex:page standardController="Contact" extensions="SOSLController" sidebar="false" showHeader="false">
<apex:form >
<apex:image url="{!imageURL}">
</apex:image>
<apex:pageBlock title="Enter a location" id="acct1">
<apex:outputLabel value="Country" />
<apex:inputField value="{!contact.MailingCountryCode}" />
<apex:outputLabel value="State" />
<apex:inputField value="{!contact.MailingStateCode}" />
<apex:commandButton value="Submit" action="{!soslDemo_method}" reRender="acct,error,acct1" />
<apex:outputPanel title="" id="error">
<apex:pageMessages ></apex:pageMessages>
</apex:outputPanel>
</apex:pageBlock>
<apex:pageBlock title="Details of technical events" id="acct">
<apex:pageblockTable value="{!location }" var="acc">
<apex:column value="{!acc.Comp__c}"/>
<apex:column value="{!acc.Type__c}"/>
<apex:column value="{!acc.Client__c}"/>
<apex:column value="{!acc.Competitor__c}"/>
<apex:column value="{!acc.Event_Name__c}"/>
<apex:column value="{!acc.evt_Des__c}"/>
<apex:column value="{!acc.Et_Addr__c}"/>
<apex:column value="{!acc.Dt_Ti__c}"/>
<apex:column value="{!acc.Ct_Person__c}"/>
<apex:column value="{!acc.Ph_Num__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks and Regards,
Sivasankari.M
My scenario is,
I have to get the details by location(State or Country).1st preference is State.
My output will be,
The input fields are Standard Country and State picklist .
The state or country (input) has pass to the apex controller.
[ Eg:
1.country :USA State: NY---- input will be NY(State)
2. country:Iceland State : No States ,------ input will be Iceland(Country)
]
I dont know how to pass theat selected state picklist value to apex controller.
But i written some piece of codes.Please verify it and correct it. If anyone knows please tell me.
My Apex Code:
Public with sharing class SOSLController{
Public List<loc__c> location {get;set;} // location
public String imageURL{get;set;} // display a image
Public String searchStr{get;set;} // find a string
private ApexPages.StandardController stdController;
/* display a image -method*/
public SOSLController(ApexPages.StandardController stdController)
{
imageURL='/servlet/servlet.FileDownload?file=';
List< document > documentList=[select name from document where
Name='logo'];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}
}
/* find a string and run the sosl query*/
Public void soslDemo_method(){
location = New List<loc__c>();
if(searchStr.length() > 1){
String searchStr1 = searchStr;
// System.debug('message');
String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c )';
List<List <sObject>> searchList = search.query(searchQuery);
location = ((List<loc__c>)searchList[0]);
/* Message */
if(location.size() == 0){
apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
return;
}}
else{
apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
return;
}}}
My VFP:
<apex:page standardController="Contact" extensions="SOSLController" sidebar="false" showHeader="false">
<apex:form >
<apex:image url="{!imageURL}">
</apex:image>
<apex:pageBlock title="Enter a location" id="acct1">
<apex:outputLabel value="Country" />
<apex:inputField value="{!contact.MailingCountryCode}" />
<apex:outputLabel value="State" />
<apex:inputField value="{!contact.MailingStateCode}" />
<apex:commandButton value="Submit" action="{!soslDemo_method}" reRender="acct,error,acct1" />
<apex:outputPanel title="" id="error">
<apex:pageMessages ></apex:pageMessages>
</apex:outputPanel>
</apex:pageBlock>
<apex:pageBlock title="Details of technical events" id="acct">
<apex:pageblockTable value="{!location }" var="acc">
<apex:column value="{!acc.Comp__c}"/>
<apex:column value="{!acc.Type__c}"/>
<apex:column value="{!acc.Client__c}"/>
<apex:column value="{!acc.Competitor__c}"/>
<apex:column value="{!acc.Event_Name__c}"/>
<apex:column value="{!acc.evt_Des__c}"/>
<apex:column value="{!acc.Et_Addr__c}"/>
<apex:column value="{!acc.Dt_Ti__c}"/>
<apex:column value="{!acc.Ct_Person__c}"/>
<apex:column value="{!acc.Ph_Num__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks and Regards,
Sivasankari.M