• Adutt
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 13
    Replies

Hi All ,

Please suggest me with the below scenerio.

I have created a vf page , which displays selected products from another vf page . I have used <apex:outputLabel> component to display the selected products names in this page . Based on clicking a certain product from this list , I want to display some xyz output text .

 

The problem I am facing is :

 

I am not able to select a particular product out of the many .

Currently , I am using 'onclick' event on output label , which calls the javascript , which as a result calls the action function , and based on true/false value on the action function method , the "xyz" output text is displayed for all the products , irrelevant to the one I am clicking . What my requirement is : the "xyz" output text should only be displayed for the products which I am selecting out of the many.


I am pasting my current code :

 

VF Page :

 

<apex:page controller="productSelectController" sidebar="false">
<script type="text/javascript">
function expandDetails(){
alert('test');
<!--var a = document.getElementById('{!$Component.tex1}').value;-->
details();
}
</script>
<apex:form >

<apex:pageBlock >
<apex:outputPanel >
<apex:pageBlockSection title="test" />

<apex:pageBlockTable value="{!selectedProduct}" var="sp">
<apex:column >
<apex:outputLabel value="{!sp.name}" onclick="expandDetails();return true;" id="tex1">
<apex:pageBlock >
<apex:outputPanel id="second" >
<apex:pageBlock rendered="{!IF(proDetails,true,false)}">
<apex:outputText >xyz</apex:outputText>
</apex:pageBlock>
</apex:outputPanel>
</apex:pageBlock>
</apex:outputLabel>
</apex:column>
</apex:pageBlockTable>

</apex:outputPanel>
</apex:pageBlock>

<apex:actionFunction name="details" action="{!expandDetailsAction}" reRender="second" oncomplete="alert('After Apex Method');">
</apex:actionFunction>
</apex:form>
</apex:page>

 

 

Controller:

 

public with sharing class productSelectController {


//public Boolean offPB{get;set;}
//public String searchString{get;set;}
//public Filter thisProduct{get;set;}
//public String oppVar;
//public Opportunity oppId{get;set;}
public list<wrapClass> wrpList=new list<wrapClass>();
//public list<PriceBookEntry>listPE;
public wrapClass wrp ;
//public String par{get;set;}
public list<Product2> selectedProduct{get;set;}
public Boolean proDetails= false;
public String second;

public list<Product2> chooseProduct{get;set;}

public productSelectController ()
{
//thisProduct=new Filter();
}
//////PLEASE NEGLECT THIS PART//////  (This controller is shared by 2 pages , this part is for the 1st page)


/*public void Search() {
wrpList.clear();
oppVar=apexPages.currentPage().getParameters().get('oppId');
system.debug('aaaaaaaaa'+oppVar);
String searchLT = '%' + searchString +'%';
system.debug('bbbbbbbb'+searchLT );
oppId=[Select Id, Pricebook2Id,Pricebook2.Name From Opportunity Where Id =: oppVar];
system.debug('ccccccc'+oppId);
if(!offPB){

string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =\''+oppId.Pricebook2Id+'\' ';
system.debug('dddddddddd'+strQuery);

if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('eeeeeeeee'+strQuery );
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
listPE.sort();
system.debug('ffffffff'+listPE);
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}

for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}
system.debug('bbbbbbbbbbbb'+wrpList);

}else{

searchString = '';
string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id != \''+oppId.Pricebook2Id+'\' ';
system.debug('********'+strQuery);
if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('+++++++++++++'+strQuery);
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id !=:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
system.debug('==========='+listPE);
listPE.sort();
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}
for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}

}
}
*//

 

/This is the "Next " button on page 1 , based on which , selected products are displayed on the 2nd page.
public PageReference Next() {
selectedProduct = new list<Product2>();
for(wrapClass wc : wrpList)
{
if(wc.chkProduct == true)
{
selectedProduct.add(wc.pbeVar);
system.debug('aaaaaa'+selectedProduct);
}
}
return Page.productDetails;
}

 

// This is the method to display the output text ////
public void expandDetailsAction()
{
if(!proDetails)
proDetails = true;
else
proDetails = false;
system.debug('eeeessss'+proDetails );
}
///////////// PLEASE NEGLECT THIS PART /////////  This is related to the first page.
/*public String offProducts()
{
if(!offPB)
offPB=true;
else
offPB=false;

return null;
}

public class Filter
{
public Product2 prdFlter{get;set;}

public Filter(){
prdFlter=new Product2();
}
}

*/

public class wrapClass
{
public boolean chkProduct{get;set;}
public Product2 pbeVar{get;set;}
public wrapClass(Product2 p)
{
pbeVar= p;
chkProduct = false;
}
}

 

public list<wrapClass> getWrpList() {
return wrpList;
}

public list<Product2> getSelectedProduct()
{
return selectedProduct;
}

public Boolean getProDetails()
{

System.debug('999999999'+proDetails );
return proDetails;
}
public void setProDetails(boolean b)
{
this.proDetails = b;
System.debug('mmmmmmmmmmmm'+proDetails );
}

public String getSecond() {
return second;
}

}

 

 

 

Please help!!

Thanks in Advance.

  • October 21, 2013
  • Like
  • 0

Hi All ,

Please suggest me with the below scenerio.

I have created a vf page , which displays selected products from another vf page . I have used <apex:outputLabel> component to display the selected products names in this page . Based on clicking a certain product from this list , I want to display some xyz output text .

 

The problem I am facing is :

 

I am not able to select a particular product out of the many .

Currently , I am using 'onclick' event on output label , which calls the javascript , which as a result calls the action function , and based on true/false value on the action function method , the "xyz" output text is displayed for all the products , irrelevant to the one I am clicking . What my requirement is : the "xyz" output text should only be displayed for the products which I am selecting out of the many.


I am pasting my current code :

 

VF Page :

 

<apex:page controller="productSelectController" sidebar="false">
<script type="text/javascript">
function expandDetails(){
alert('test');
<!--var a = document.getElementById('{!$Component.tex1}').value;-->
details();
}
</script>
<apex:form >

<apex:pageBlock >
<apex:outputPanel >
<apex:pageBlockSection title="test" />

<apex:pageBlockTable value="{!selectedProduct}" var="sp">
<apex:column >
<apex:outputLabel value="{!sp.name}" onclick="expandDetails();return true;" id="tex1">
<apex:pageBlock >
<apex:outputPanel id="second" >
<apex:pageBlock rendered="{!IF(proDetails,true,false)}">
<apex:outputText >xyz</apex:outputText>
</apex:pageBlock>
</apex:outputPanel>
</apex:pageBlock>
</apex:outputLabel>
</apex:column>
</apex:pageBlockTable>

</apex:outputPanel>
</apex:pageBlock>

<apex:actionFunction name="details" action="{!expandDetailsAction}" reRender="second" oncomplete="alert('After Apex Method');">
</apex:actionFunction>
</apex:form>
</apex:page>

 

 

Controller:

 

public with sharing class productSelectController {


//public Boolean offPB{get;set;}
//public String searchString{get;set;}
//public Filter thisProduct{get;set;}
//public String oppVar;
//public Opportunity oppId{get;set;}
public list<wrapClass> wrpList=new list<wrapClass>();
//public list<PriceBookEntry>listPE;
public wrapClass wrp ;
//public String par{get;set;}
public list<Product2> selectedProduct{get;set;}
public Boolean proDetails= false;
public String second;

public list<Product2> chooseProduct{get;set;}

public productSelectController ()
{
//thisProduct=new Filter();
}
//////PLEASE NEGLECT THIS PART//////  (This controller is shared by 2 pages , this part is for the 1st page)


/*public void Search() {
wrpList.clear();
oppVar=apexPages.currentPage().getParameters().get('oppId');
system.debug('aaaaaaaaa'+oppVar);
String searchLT = '%' + searchString +'%';
system.debug('bbbbbbbb'+searchLT );
oppId=[Select Id, Pricebook2Id,Pricebook2.Name From Opportunity Where Id =: oppVar];
system.debug('ccccccc'+oppId);
if(!offPB){

string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =\''+oppId.Pricebook2Id+'\' ';
system.debug('dddddddddd'+strQuery);

if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('eeeeeeeee'+strQuery );
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
listPE.sort();
system.debug('ffffffff'+listPE);
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}

for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}
system.debug('bbbbbbbbbbbb'+wrpList);

}else{

searchString = '';
string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id != \''+oppId.Pricebook2Id+'\' ';
system.debug('********'+strQuery);
if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('+++++++++++++'+strQuery);
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id !=:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
system.debug('==========='+listPE);
listPE.sort();
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}
for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}

}
}
*//

 

/This is the "Next " button on page 1 , based on which , selected products are displayed on the 2nd page.
public PageReference Next() {
selectedProduct = new list<Product2>();
for(wrapClass wc : wrpList)
{
if(wc.chkProduct == true)
{
selectedProduct.add(wc.pbeVar);
system.debug('aaaaaa'+selectedProduct);
}
}
return Page.productDetails;
}

 

// This is the method to display the output text ////
public void expandDetailsAction()
{
if(!proDetails)
proDetails = true;
else
proDetails = false;
system.debug('eeeessss'+proDetails );
}
///////////// PLEASE NEGLECT THIS PART /////////  This is related to the first page.
/*public String offProducts()
{
if(!offPB)
offPB=true;
else
offPB=false;

return null;
}

public class Filter
{
public Product2 prdFlter{get;set;}

public Filter(){
prdFlter=new Product2();
}
}

*/

public class wrapClass
{
public boolean chkProduct{get;set;}
public Product2 pbeVar{get;set;}
public wrapClass(Product2 p)
{
pbeVar= p;
chkProduct = false;
}
}

 

public list<wrapClass> getWrpList() {
return wrpList;
}

public list<Product2> getSelectedProduct()
{
return selectedProduct;
}

public Boolean getProDetails()
{

System.debug('999999999'+proDetails );
return proDetails;
}
public void setProDetails(boolean b)
{
this.proDetails = b;
System.debug('mmmmmmmmmmmm'+proDetails );
}

public String getSecond() {
return second;
}

}

 

 

 

Please help!!

Thanks in Advance.

 

 

  • October 21, 2013
  • Like
  • 0

Hi All,

 

I need to create a visualforce template on Opportunity. Based on certain conditions of a WFR, this template needs to be sent to the account team member of a particular role of the account , to which the opportunity is related.

 

My issue is, how do I fetch the account team member name (of a particular role) of the  account, to which the opportunity is related.

 

Please advice...

 

Thanks!!

  • July 29, 2013
  • Like
  • 0

Hi All,

I am trying to get the count() of a particular set of accounts based on the search criteria. In the controller everything looks good and also in the debug logs , I am getting the desired outputs. The problem is when I try fetching the aggregate result in the page, I am getting the following error : Unknown property 'String.inti'

 

I am posting my code hereby,

 

page:

<apex:page controller="accountSearch">
<script>
function information()
{
method1();
alert('ddd');
var pbs1=true;
alert(pbs1);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>
<apex:commandLink value="Search" action="{!getAccounts}" />


<apex:pageBlockTable value="{!accList}" var="acc" rendered="{!IF(count,true,false)}" >
<apex:column headerValue="Account Name">
<apex:commandLink action="{!getID}" value="{!acc.name}">
<apex:param name="var1" value="{!acc.id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>

<apex:dataTable value="{!wrapList}" var="wrp" rendered="{!IF(count,true,false)}" border="1" >
<apex:column >
<apex:facet name="header">Count:</apex:facet>
<apex:outputText value="{!wrp.inti}"></apex:outputText>
</apex:column>
</apex:dataTable>

<apex:actionFunction name="method1" action="{!method1Action}"/>

<apex:pageBlockSection title="Account Information" rendered="{!IF(op1,true,false)}" collapsible="false" onclick="information()">
<apex:outputPanel rendered="{!IF(pbs1,true,false)}">
<apex:repeat value="{!selectedAccount}" var="selectedAcc" >
<td>
<tr>
<apex:pageBlockSection >
<apex:outputField value="{!selectedAcc.Name}"></apex:outputField>
</apex:pageBlockSection>
</tr>
</td>
</apex:repeat>

</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller :

public with sharing class accountSearch {


public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public Account selectedAccount{get;set;}
public list<Account> accList = new list<Account>();
public boolean op1=false;
public boolean pbs1=false;
public boolean count=false;
public list<wrapClass>wrapList = new list<wrapClass>();
public list<AggregateResult> agr = new list<AggregateResult>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select id,name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
count=true;
getResult();
system.debug('ddddddddddddddddd');
return null;
}

public list<wrapClass> getResult()
{
agr=[Select name,Count(id) quantity from Account where id IN : accList GROUP BY name ];
system.debug('ccccccccccc'+agr);
String str='';
for(AggregateResult a:agr)
{
str +=a.get('quantity');
system.debug('nnnnnnnn'+str);
wrapList.add(new wrapClass(str)); ---here I am adding string to the wrapper class list
}
system.debug('rrrrrrrrrrr'+wrapList);
return wrapList;
}

public list<Account> getAccList(){
return accList;
}
public String getID()
{
String strId = apexpages.currentpage().getparameters().get('var1');
system.debug('lllllllllll'+strId);
selectedAccount=[Select name,OwnerId,Site,AccountSource,AnnualRevenue,NumberOfEmployees,Fax,Industry,Ownership,Phone,Rating,Type from Account
where id=:strId];
op1=true;
pbs1=false;
return null ;
}
public String getWrapList() {
return null ;
}

public String getWrp(){
return null;
}


public Boolean getOp1()
{
return op1;
}

public void setOp1(Boolean abc)
{
this.op1=abc;
}
public Boolean getPbs1()
{
return pbs1;
}

public void setPbs1(Boolean abc)
{
this.pbs1=abc;
}
public void method1Action()
{
pbs1=true;
}
public Boolean getCount()
{
return count;
}

public void setcount(Boolean abc)
{
this.count=abc;
}

public class wrapClass{
public wrapClass wrp{get;set;}
public String inti{get;set;}
public wrapClass(String agg
{
inti=agg;
system.debug('ssssssssss'+inti);
}
}
}

---------------------------------------------------------------------------------------------------------------------------

I am not sure as of why I am getting this error :  Unknown property 'String.inti' . Am I missing something?

 

 

 

Please help.

 

Cheers!!

  • April 28, 2013
  • Like
  • 0

Hi All,

I am trying to get the count() of a particular set of accounts based on the search criteria. In the controller everything looks good and also in the debug logs , I am getting the desired outputs. The problem is when I try fetching the aggregate result in the page, I am getting the following error : Unknown property 'String.inti'

 

I am posting my code hereby,

 

page:

<apex:page controller="accountSearch">
<script>
function information()
{
method1();
alert('ddd');
var pbs1=true;
alert(pbs1);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>
<apex:commandLink value="Search" action="{!getAccounts}" />


<apex:pageBlockTable value="{!accList}" var="acc" rendered="{!IF(count,true,false)}" >
<apex:column headerValue="Account Name">
<apex:commandLink action="{!getID}" value="{!acc.name}">
<apex:param name="var1" value="{!acc.id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>

<apex:dataTable value="{!wrapList}" var="wrp" rendered="{!IF(count,true,false)}" border="1" >
<apex:column >
<apex:facet name="header">Count:</apex:facet>
<apex:outputText value="{!wrp.inti}"></apex:outputText>
</apex:column>
</apex:dataTable>

<apex:actionFunction name="method1" action="{!method1Action}"/>

<apex:pageBlockSection title="Account Information" rendered="{!IF(op1,true,false)}" collapsible="false" onclick="information()">
<apex:outputPanel rendered="{!IF(pbs1,true,false)}">
<apex:repeat value="{!selectedAccount}" var="selectedAcc" >
<td>
<tr>
<apex:pageBlockSection >
<apex:outputField value="{!selectedAcc.Name}"></apex:outputField>
</apex:pageBlockSection>
</tr>
</td>
</apex:repeat>

</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller :

public with sharing class accountSearch {


public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public Account selectedAccount{get;set;}
public list<Account> accList = new list<Account>();
public boolean op1=false;
public boolean pbs1=false;
public boolean count=false;
public list<wrapClass>wrapList = new list<wrapClass>();
public list<AggregateResult> agr = new list<AggregateResult>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select id,name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
count=true;
getResult();
system.debug('ddddddddddddddddd');
return null;
}

public list<wrapClass> getResult()
{
agr=[Select name,Count(id) quantity from Account where id IN : accList GROUP BY name ];
system.debug('ccccccccccc'+agr);
String str='';
for(AggregateResult a:agr)
{
str +=a.get('quantity');
system.debug('nnnnnnnn'+str);
wrapList.add(new wrapClass(str)); ---here I am adding string to the wrapper class list
}
system.debug('rrrrrrrrrrr'+wrapList);
return wrapList;
}

public list<Account> getAccList(){
return accList;
}
public String getID()
{
String strId = apexpages.currentpage().getparameters().get('var1');
system.debug('lllllllllll'+strId);
selectedAccount=[Select name,OwnerId,Site,AccountSource,AnnualRevenue,NumberOfEmployees,Fax,Industry,Ownership,Phone,Rating,Type from Account
where id=:strId];
op1=true;
pbs1=false;
return null ;
}
public String getWrapList() {
return null ;
}

public String getWrp(){
return null;
}


public Boolean getOp1()
{
return op1;
}

public void setOp1(Boolean abc)
{
this.op1=abc;
}
public Boolean getPbs1()
{
return pbs1;
}

public void setPbs1(Boolean abc)
{
this.pbs1=abc;
}
public void method1Action()
{
pbs1=true;
}
public Boolean getCount()
{
return count;
}

public void setcount(Boolean abc)
{
this.count=abc;
}

public class wrapClass{
public wrapClass wrp{get;set;}
public String inti{get;set;}
public wrapClass(String agg
{
inti=agg;
system.debug('ssssssssss'+inti);
}
}
}

---------------------------------------------------------------------------------------------------------------------------

I am not sure as of why I am getting this error :  Unknown property 'String.inti' . Am I missing something?

 

 

 

Please help.

 

Cheers!!

 

 

 

  • April 28, 2013
  • Like
  • 0

Hi All,
I have a custom VF page which performs the normal search functionality on Account and based on the selected account value wants to proceed further.
Problem:
I am not able to pass the selected account's id as action function is not working in the following code:

<apex:page controller="accountSearch">
<apex:form >
<script>
function toGetAccountId(id)
{
alert('test1');
variable1=document.getElementById(id).value;
xyz(variable1);
alert('test2');
}
</script>
<apex:pageBlock >

<apex:actionFunction name="xyz" action="{!samepage}">
<apex:param value="" assignTo="{!var1}"/>
</apex:actionFunction>


<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>

<apex:commandLink value="Search" action="{!getAccounts}" />

<apex:pageBlockTable value="{!accList}" var="acc">
<apex:column headerValue="Account Name" > <apex:outputLink id="olId" onclick="toGetAccountId('{!$Component.olId}')">{!acc.name}
</apex:outputLink></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
-----------------------------------------------------
controller:
public with sharing class accountSearch {
public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public String var2;
public list<Account> accList = new list<Account>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
return null;
}

public list<Account> getAccList(){
return accList;
}
public pagereference samepage()
{
//PageReference curPage = ApexPages.currentPage();
system.debug('lllllllllll');
var2=var1;
system.debug('dddddddddddddd'+var2);
PageReference curPage = new Pagereference('/apex/testpage2');
curPage.setRedirect(true);
return curPage ;
}
}

After the list of accounts returned, if I select a particular account (onclick of a output link),the javascript is getting invoked and I am getting the alerts. But the action method (samepage()) is not invoked. (for testing purpose, I am just redirecting a test page on the action method and its not working)
Also, if I try saving <apex:actionFunction name="xyz" action="{samepage}"> instead of <apex:actionFunction name="xyz" action="{!samepage}"> , its getting saved which is wrong.

I am at lost. Please help..

Thanks.

  • April 08, 2013
  • Like
  • 0

Hi All,

I have a custom VF page which performs the normal search functionality on Account and based on the selected account value wants to proceed further.

Problem:

I am not able to pass the selected account's id as action function is not working in the following code:

 

<apex:page controller="accountSearch">
<apex:form >
<script>
function toGetAccountId(id)
{
alert('test1');
variable1=document.getElementById(id).value;
xyz(variable1);
alert('test2');
}
</script>

<apex:pageBlock >


<apex:actionFunction name="xyz" action="{!samepage}">  

   <apex:param value="" assignTo="{!var1}"/>

</apex:actionFunction>



<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>

<apex:commandLink value="Search" action="{!getAccounts}" />

<apex:pageBlockTable value="{!accList}" var="acc">
<apex:column headerValue="Account Name" > <apex:outputLink id="olId" onclick="toGetAccountId('{!$Component.olId}')">{!acc.name}
</apex:outputLink></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

-----------------------------------------------------

controller:

public with sharing class accountSearch {

public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public String var2;
public list<Account> accList = new list<Account>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
return null;
}

public list<Account> getAccList(){
return accList;
}
public pagereference samepage()
{
//PageReference curPage = ApexPages.currentPage();
system.debug('lllllllllll');
var2=var1;
system.debug('dddddddddddddd'+var2);
PageReference curPage = new Pagereference('/apex/testpage2');
curPage.setRedirect(true);
return curPage ;
}
}

 

After the list of accounts returned, if I select a particular account (onclick of a output link),the javascript is getting invoked and I am getting the alerts. But the action method (samepage()) is not invoked. (for testing purpose, I am just redirecting a test page on the action method and its not working)

Also, if I try saving <apex:actionFunction name="xyz" action="{samepage}"> instead of  <apex:actionFunction name="xyz" action="{!samepage}"> , its getting saved which is wrong

 

I am at lost. Please help..

 

Thanks.

 

 

 

  • April 08, 2013
  • Like
  • 0

Hi All ,

Please suggest me with the below scenerio.

I have created a vf page , which displays selected products from another vf page . I have used <apex:outputLabel> component to display the selected products names in this page . Based on clicking a certain product from this list , I want to display some xyz output text .

 

The problem I am facing is :

 

I am not able to select a particular product out of the many .

Currently , I am using 'onclick' event on output label , which calls the javascript , which as a result calls the action function , and based on true/false value on the action function method , the "xyz" output text is displayed for all the products , irrelevant to the one I am clicking . What my requirement is : the "xyz" output text should only be displayed for the products which I am selecting out of the many.


I am pasting my current code :

 

VF Page :

 

<apex:page controller="productSelectController" sidebar="false">
<script type="text/javascript">
function expandDetails(){
alert('test');
<!--var a = document.getElementById('{!$Component.tex1}').value;-->
details();
}
</script>
<apex:form >

<apex:pageBlock >
<apex:outputPanel >
<apex:pageBlockSection title="test" />

<apex:pageBlockTable value="{!selectedProduct}" var="sp">
<apex:column >
<apex:outputLabel value="{!sp.name}" onclick="expandDetails();return true;" id="tex1">
<apex:pageBlock >
<apex:outputPanel id="second" >
<apex:pageBlock rendered="{!IF(proDetails,true,false)}">
<apex:outputText >xyz</apex:outputText>
</apex:pageBlock>
</apex:outputPanel>
</apex:pageBlock>
</apex:outputLabel>
</apex:column>
</apex:pageBlockTable>

</apex:outputPanel>
</apex:pageBlock>

<apex:actionFunction name="details" action="{!expandDetailsAction}" reRender="second" oncomplete="alert('After Apex Method');">
</apex:actionFunction>
</apex:form>
</apex:page>

 

 

Controller:

 

public with sharing class productSelectController {


//public Boolean offPB{get;set;}
//public String searchString{get;set;}
//public Filter thisProduct{get;set;}
//public String oppVar;
//public Opportunity oppId{get;set;}
public list<wrapClass> wrpList=new list<wrapClass>();
//public list<PriceBookEntry>listPE;
public wrapClass wrp ;
//public String par{get;set;}
public list<Product2> selectedProduct{get;set;}
public Boolean proDetails= false;
public String second;

public list<Product2> chooseProduct{get;set;}

public productSelectController ()
{
//thisProduct=new Filter();
}
//////PLEASE NEGLECT THIS PART//////  (This controller is shared by 2 pages , this part is for the 1st page)


/*public void Search() {
wrpList.clear();
oppVar=apexPages.currentPage().getParameters().get('oppId');
system.debug('aaaaaaaaa'+oppVar);
String searchLT = '%' + searchString +'%';
system.debug('bbbbbbbb'+searchLT );
oppId=[Select Id, Pricebook2Id,Pricebook2.Name From Opportunity Where Id =: oppVar];
system.debug('ccccccc'+oppId);
if(!offPB){

string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =\''+oppId.Pricebook2Id+'\' ';
system.debug('dddddddddd'+strQuery);

if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('eeeeeeeee'+strQuery );
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
listPE.sort();
system.debug('ffffffff'+listPE);
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}

for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}
system.debug('bbbbbbbbbbbb'+wrpList);

}else{

searchString = '';
string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id != \''+oppId.Pricebook2Id+'\' ';
system.debug('********'+strQuery);
if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('+++++++++++++'+strQuery);
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id !=:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
system.debug('==========='+listPE);
listPE.sort();
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}
for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}

}
}
*//

 

/This is the "Next " button on page 1 , based on which , selected products are displayed on the 2nd page.
public PageReference Next() {
selectedProduct = new list<Product2>();
for(wrapClass wc : wrpList)
{
if(wc.chkProduct == true)
{
selectedProduct.add(wc.pbeVar);
system.debug('aaaaaa'+selectedProduct);
}
}
return Page.productDetails;
}

 

// This is the method to display the output text ////
public void expandDetailsAction()
{
if(!proDetails)
proDetails = true;
else
proDetails = false;
system.debug('eeeessss'+proDetails );
}
///////////// PLEASE NEGLECT THIS PART /////////  This is related to the first page.
/*public String offProducts()
{
if(!offPB)
offPB=true;
else
offPB=false;

return null;
}

public class Filter
{
public Product2 prdFlter{get;set;}

public Filter(){
prdFlter=new Product2();
}
}

*/

public class wrapClass
{
public boolean chkProduct{get;set;}
public Product2 pbeVar{get;set;}
public wrapClass(Product2 p)
{
pbeVar= p;
chkProduct = false;
}
}

 

public list<wrapClass> getWrpList() {
return wrpList;
}

public list<Product2> getSelectedProduct()
{
return selectedProduct;
}

public Boolean getProDetails()
{

System.debug('999999999'+proDetails );
return proDetails;
}
public void setProDetails(boolean b)
{
this.proDetails = b;
System.debug('mmmmmmmmmmmm'+proDetails );
}

public String getSecond() {
return second;
}

}

 

 

 

Please help!!

Thanks in Advance.

  • October 21, 2013
  • Like
  • 0

Hi All ,

Please suggest me with the below scenerio.

I have created a vf page , which displays selected products from another vf page . I have used <apex:outputLabel> component to display the selected products names in this page . Based on clicking a certain product from this list , I want to display some xyz output text .

 

The problem I am facing is :

 

I am not able to select a particular product out of the many .

Currently , I am using 'onclick' event on output label , which calls the javascript , which as a result calls the action function , and based on true/false value on the action function method , the "xyz" output text is displayed for all the products , irrelevant to the one I am clicking . What my requirement is : the "xyz" output text should only be displayed for the products which I am selecting out of the many.


I am pasting my current code :

 

VF Page :

 

<apex:page controller="productSelectController" sidebar="false">
<script type="text/javascript">
function expandDetails(){
alert('test');
<!--var a = document.getElementById('{!$Component.tex1}').value;-->
details();
}
</script>
<apex:form >

<apex:pageBlock >
<apex:outputPanel >
<apex:pageBlockSection title="test" />

<apex:pageBlockTable value="{!selectedProduct}" var="sp">
<apex:column >
<apex:outputLabel value="{!sp.name}" onclick="expandDetails();return true;" id="tex1">
<apex:pageBlock >
<apex:outputPanel id="second" >
<apex:pageBlock rendered="{!IF(proDetails,true,false)}">
<apex:outputText >xyz</apex:outputText>
</apex:pageBlock>
</apex:outputPanel>
</apex:pageBlock>
</apex:outputLabel>
</apex:column>
</apex:pageBlockTable>

</apex:outputPanel>
</apex:pageBlock>

<apex:actionFunction name="details" action="{!expandDetailsAction}" reRender="second" oncomplete="alert('After Apex Method');">
</apex:actionFunction>
</apex:form>
</apex:page>

 

 

Controller:

 

public with sharing class productSelectController {


//public Boolean offPB{get;set;}
//public String searchString{get;set;}
//public Filter thisProduct{get;set;}
//public String oppVar;
//public Opportunity oppId{get;set;}
public list<wrapClass> wrpList=new list<wrapClass>();
//public list<PriceBookEntry>listPE;
public wrapClass wrp ;
//public String par{get;set;}
public list<Product2> selectedProduct{get;set;}
public Boolean proDetails= false;
public String second;

public list<Product2> chooseProduct{get;set;}

public productSelectController ()
{
//thisProduct=new Filter();
}
//////PLEASE NEGLECT THIS PART//////  (This controller is shared by 2 pages , this part is for the 1st page)


/*public void Search() {
wrpList.clear();
oppVar=apexPages.currentPage().getParameters().get('oppId');
system.debug('aaaaaaaaa'+oppVar);
String searchLT = '%' + searchString +'%';
system.debug('bbbbbbbb'+searchLT );
oppId=[Select Id, Pricebook2Id,Pricebook2.Name From Opportunity Where Id =: oppVar];
system.debug('ccccccc'+oppId);
if(!offPB){

string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =\''+oppId.Pricebook2Id+'\' ';
system.debug('dddddddddd'+strQuery);

if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('eeeeeeeee'+strQuery );
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id =:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
listPE.sort();
system.debug('ffffffff'+listPE);
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}

for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}
system.debug('bbbbbbbbbbbb'+wrpList);

}else{

searchString = '';
string strQuery='Select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id != \''+oppId.Pricebook2Id+'\' ';
system.debug('********'+strQuery);
if(searchString != null && searchString.trim() != ''){
strQuery += 'AND Product2.Name LIKE : searchLT ';
system.debug('+++++++++++++'+strQuery);
listPE=[select Product2Id,Product2.Name,Product2.Business_Unit__c,Product2.Family from PricebookEntry where Pricebook2Id !=:oppId.Pricebook2Id AND Product2.Name LIKE :searchLT AND IsActive = true];
system.debug('==========='+listPE);
listPE.sort();
}
else {
String str_Family;
String str_BU;

if(thisProduct.prdFlter.Business_Unit__c != null && thisProduct.prdFlter.Business_Unit__c != '' )
{
str_BU = '%'+ thisProduct.prdFlter.Business_Unit__c + '%';
system.debug('qqqqqq'+str_BU);
strQuery += 'AND Product2.Business_Unit__c LIKE : str_BU';
system.debug('zzzzzzzz'+strQuery );
}
if(thisProduct.prdFlter.Family != null && thisProduct.prdFlter.Family !='')
{
str_Family = '%' + thisProduct.prdFlter.Family + '%';
system.debug('zzzzzzzz'+str_Family);
strQuery += ' AND Product2.Family LIKE : str_Family';
system.debug('zzzzzzzz'+strQuery );
}
listPE=database.query(strQuery );
system.debug('vvvvvvvvv'+listPE);
}
for(PriceBookEntry pbe : listPE)
{
wrp = new wrapClass(pbe.Product2);
system.debug('xxxxxx'+wrp);
wrpList.add(wrp );
}

}
}
*//

 

/This is the "Next " button on page 1 , based on which , selected products are displayed on the 2nd page.
public PageReference Next() {
selectedProduct = new list<Product2>();
for(wrapClass wc : wrpList)
{
if(wc.chkProduct == true)
{
selectedProduct.add(wc.pbeVar);
system.debug('aaaaaa'+selectedProduct);
}
}
return Page.productDetails;
}

 

// This is the method to display the output text ////
public void expandDetailsAction()
{
if(!proDetails)
proDetails = true;
else
proDetails = false;
system.debug('eeeessss'+proDetails );
}
///////////// PLEASE NEGLECT THIS PART /////////  This is related to the first page.
/*public String offProducts()
{
if(!offPB)
offPB=true;
else
offPB=false;

return null;
}

public class Filter
{
public Product2 prdFlter{get;set;}

public Filter(){
prdFlter=new Product2();
}
}

*/

public class wrapClass
{
public boolean chkProduct{get;set;}
public Product2 pbeVar{get;set;}
public wrapClass(Product2 p)
{
pbeVar= p;
chkProduct = false;
}
}

 

public list<wrapClass> getWrpList() {
return wrpList;
}

public list<Product2> getSelectedProduct()
{
return selectedProduct;
}

public Boolean getProDetails()
{

System.debug('999999999'+proDetails );
return proDetails;
}
public void setProDetails(boolean b)
{
this.proDetails = b;
System.debug('mmmmmmmmmmmm'+proDetails );
}

public String getSecond() {
return second;
}

}

 

 

 

Please help!!

Thanks in Advance.

 

 

  • October 21, 2013
  • Like
  • 0

Hi All,

I am trying to get the count() of a particular set of accounts based on the search criteria. In the controller everything looks good and also in the debug logs , I am getting the desired outputs. The problem is when I try fetching the aggregate result in the page, I am getting the following error : Unknown property 'String.inti'

 

I am posting my code hereby,

 

page:

<apex:page controller="accountSearch">
<script>
function information()
{
method1();
alert('ddd');
var pbs1=true;
alert(pbs1);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>
<apex:commandLink value="Search" action="{!getAccounts}" />


<apex:pageBlockTable value="{!accList}" var="acc" rendered="{!IF(count,true,false)}" >
<apex:column headerValue="Account Name">
<apex:commandLink action="{!getID}" value="{!acc.name}">
<apex:param name="var1" value="{!acc.id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>

<apex:dataTable value="{!wrapList}" var="wrp" rendered="{!IF(count,true,false)}" border="1" >
<apex:column >
<apex:facet name="header">Count:</apex:facet>
<apex:outputText value="{!wrp.inti}"></apex:outputText>
</apex:column>
</apex:dataTable>

<apex:actionFunction name="method1" action="{!method1Action}"/>

<apex:pageBlockSection title="Account Information" rendered="{!IF(op1,true,false)}" collapsible="false" onclick="information()">
<apex:outputPanel rendered="{!IF(pbs1,true,false)}">
<apex:repeat value="{!selectedAccount}" var="selectedAcc" >
<td>
<tr>
<apex:pageBlockSection >
<apex:outputField value="{!selectedAcc.Name}"></apex:outputField>
</apex:pageBlockSection>
</tr>
</td>
</apex:repeat>

</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller :

public with sharing class accountSearch {


public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public Account selectedAccount{get;set;}
public list<Account> accList = new list<Account>();
public boolean op1=false;
public boolean pbs1=false;
public boolean count=false;
public list<wrapClass>wrapList = new list<wrapClass>();
public list<AggregateResult> agr = new list<AggregateResult>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select id,name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
count=true;
getResult();
system.debug('ddddddddddddddddd');
return null;
}

public list<wrapClass> getResult()
{
agr=[Select name,Count(id) quantity from Account where id IN : accList GROUP BY name ];
system.debug('ccccccccccc'+agr);
String str='';
for(AggregateResult a:agr)
{
str +=a.get('quantity');
system.debug('nnnnnnnn'+str);
wrapList.add(new wrapClass(str)); ---here I am adding string to the wrapper class list
}
system.debug('rrrrrrrrrrr'+wrapList);
return wrapList;
}

public list<Account> getAccList(){
return accList;
}
public String getID()
{
String strId = apexpages.currentpage().getparameters().get('var1');
system.debug('lllllllllll'+strId);
selectedAccount=[Select name,OwnerId,Site,AccountSource,AnnualRevenue,NumberOfEmployees,Fax,Industry,Ownership,Phone,Rating,Type from Account
where id=:strId];
op1=true;
pbs1=false;
return null ;
}
public String getWrapList() {
return null ;
}

public String getWrp(){
return null;
}


public Boolean getOp1()
{
return op1;
}

public void setOp1(Boolean abc)
{
this.op1=abc;
}
public Boolean getPbs1()
{
return pbs1;
}

public void setPbs1(Boolean abc)
{
this.pbs1=abc;
}
public void method1Action()
{
pbs1=true;
}
public Boolean getCount()
{
return count;
}

public void setcount(Boolean abc)
{
this.count=abc;
}

public class wrapClass{
public wrapClass wrp{get;set;}
public String inti{get;set;}
public wrapClass(String agg
{
inti=agg;
system.debug('ssssssssss'+inti);
}
}
}

---------------------------------------------------------------------------------------------------------------------------

I am not sure as of why I am getting this error :  Unknown property 'String.inti' . Am I missing something?

 

 

 

Please help.

 

Cheers!!

  • April 28, 2013
  • Like
  • 0

Hi All,

I am trying to get the count() of a particular set of accounts based on the search criteria. In the controller everything looks good and also in the debug logs , I am getting the desired outputs. The problem is when I try fetching the aggregate result in the page, I am getting the following error : Unknown property 'String.inti'

 

I am posting my code hereby,

 

page:

<apex:page controller="accountSearch">
<script>
function information()
{
method1();
alert('ddd');
var pbs1=true;
alert(pbs1);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>
<apex:commandLink value="Search" action="{!getAccounts}" />


<apex:pageBlockTable value="{!accList}" var="acc" rendered="{!IF(count,true,false)}" >
<apex:column headerValue="Account Name">
<apex:commandLink action="{!getID}" value="{!acc.name}">
<apex:param name="var1" value="{!acc.id}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>

<apex:dataTable value="{!wrapList}" var="wrp" rendered="{!IF(count,true,false)}" border="1" >
<apex:column >
<apex:facet name="header">Count:</apex:facet>
<apex:outputText value="{!wrp.inti}"></apex:outputText>
</apex:column>
</apex:dataTable>

<apex:actionFunction name="method1" action="{!method1Action}"/>

<apex:pageBlockSection title="Account Information" rendered="{!IF(op1,true,false)}" collapsible="false" onclick="information()">
<apex:outputPanel rendered="{!IF(pbs1,true,false)}">
<apex:repeat value="{!selectedAccount}" var="selectedAcc" >
<td>
<tr>
<apex:pageBlockSection >
<apex:outputField value="{!selectedAcc.Name}"></apex:outputField>
</apex:pageBlockSection>
</tr>
</td>
</apex:repeat>

</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller :

public with sharing class accountSearch {


public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public Account selectedAccount{get;set;}
public list<Account> accList = new list<Account>();
public boolean op1=false;
public boolean pbs1=false;
public boolean count=false;
public list<wrapClass>wrapList = new list<wrapClass>();
public list<AggregateResult> agr = new list<AggregateResult>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select id,name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
count=true;
getResult();
system.debug('ddddddddddddddddd');
return null;
}

public list<wrapClass> getResult()
{
agr=[Select name,Count(id) quantity from Account where id IN : accList GROUP BY name ];
system.debug('ccccccccccc'+agr);
String str='';
for(AggregateResult a:agr)
{
str +=a.get('quantity');
system.debug('nnnnnnnn'+str);
wrapList.add(new wrapClass(str)); ---here I am adding string to the wrapper class list
}
system.debug('rrrrrrrrrrr'+wrapList);
return wrapList;
}

public list<Account> getAccList(){
return accList;
}
public String getID()
{
String strId = apexpages.currentpage().getparameters().get('var1');
system.debug('lllllllllll'+strId);
selectedAccount=[Select name,OwnerId,Site,AccountSource,AnnualRevenue,NumberOfEmployees,Fax,Industry,Ownership,Phone,Rating,Type from Account
where id=:strId];
op1=true;
pbs1=false;
return null ;
}
public String getWrapList() {
return null ;
}

public String getWrp(){
return null;
}


public Boolean getOp1()
{
return op1;
}

public void setOp1(Boolean abc)
{
this.op1=abc;
}
public Boolean getPbs1()
{
return pbs1;
}

public void setPbs1(Boolean abc)
{
this.pbs1=abc;
}
public void method1Action()
{
pbs1=true;
}
public Boolean getCount()
{
return count;
}

public void setcount(Boolean abc)
{
this.count=abc;
}

public class wrapClass{
public wrapClass wrp{get;set;}
public String inti{get;set;}
public wrapClass(String agg
{
inti=agg;
system.debug('ssssssssss'+inti);
}
}
}

---------------------------------------------------------------------------------------------------------------------------

I am not sure as of why I am getting this error :  Unknown property 'String.inti' . Am I missing something?

 

 

 

Please help.

 

Cheers!!

 

 

 

  • April 28, 2013
  • Like
  • 0

Hi All,
I have a custom VF page which performs the normal search functionality on Account and based on the selected account value wants to proceed further.
Problem:
I am not able to pass the selected account's id as action function is not working in the following code:

<apex:page controller="accountSearch">
<apex:form >
<script>
function toGetAccountId(id)
{
alert('test1');
variable1=document.getElementById(id).value;
xyz(variable1);
alert('test2');
}
</script>
<apex:pageBlock >

<apex:actionFunction name="xyz" action="{!samepage}">
<apex:param value="" assignTo="{!var1}"/>
</apex:actionFunction>


<apex:outputLabel value="Enter your search text:" >
<apex:inputText value="{!searchVar}">
</apex:inputText>
</apex:outputLabel>

<apex:commandLink value="Search" action="{!getAccounts}" />

<apex:pageBlockTable value="{!accList}" var="acc">
<apex:column headerValue="Account Name" > <apex:outputLink id="olId" onclick="toGetAccountId('{!$Component.olId}')">{!acc.name}
</apex:outputLink></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
-----------------------------------------------------
controller:
public with sharing class accountSearch {
public String olId { get; set; }
public String searchVar { get; set; }
public String var;
public String var1{get;set;}
public String var2;
public list<Account> accList = new list<Account>();

public PageReference getAccounts() {
var='%'+searchVar+'%';
system.debug('aaaaaaaaaaaa'+var);
accList = [Select name,NumberOfEmployees from account where name LIKE:var ];
system.debug('vvvvv'+accList);
return null;
}

public list<Account> getAccList(){
return accList;
}
public pagereference samepage()
{
//PageReference curPage = ApexPages.currentPage();
system.debug('lllllllllll');
var2=var1;
system.debug('dddddddddddddd'+var2);
PageReference curPage = new Pagereference('/apex/testpage2');
curPage.setRedirect(true);
return curPage ;
}
}

After the list of accounts returned, if I select a particular account (onclick of a output link),the javascript is getting invoked and I am getting the alerts. But the action method (samepage()) is not invoked. (for testing purpose, I am just redirecting a test page on the action method and its not working)
Also, if I try saving <apex:actionFunction name="xyz" action="{samepage}"> instead of <apex:actionFunction name="xyz" action="{!samepage}"> , its getting saved which is wrong.

I am at lost. Please help..

Thanks.

  • April 08, 2013
  • Like
  • 0