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
Manasa.RManasa.R 

Action of click of command button

Hi,

 

I have a VF page which has a list of email ids listed as checkboxes. I have 3 buttons:

1. TO - which adds the selected emails to TO list

2. CC - which adds the selected emails to CC list

3. Next - which redirects to Send Email page.

 

But i am facing a problem, when i click on any of the button nothing happens.... page just gets refreshed. Though i have few debug statements in my action methods nothing comes in logs. 

 

VF page is:

<apex:page controller="conAddmailsIds" >
<apex:form >
Select Emails Ids:
<!-- <apex:selectRadio value="{!emailToAdd}" > <br/> -->
<apex:selectCheckboxes value="{!emailToAdd}">
<apex:selectOption itemLabel="manasa.r@hp.com" itemValue="manasa.r@hp.com"></apex:selectOption><br/>
<apex:selectOption itemLabel="manasa.r.gupta@gmail.com" itemValue="manasa.r.gupta@gmail.com"></apex:selectOption>
<apex:selectOption itemLabel="abc@def.com" itemValue="abc@def.com"></apex:selectOption>
<apex:selectOption itemLabel="ghi@jkl.com" itemValue="ghi@jkl.com"></apex:selectOption>
<apex:selectOption itemLabel="mno@pqr.com" itemValue="mno@pqr.com"></apex:selectOption>
</apex:selectCheckboxes>
<!-- </apex:selectRadio> -->
<apex:commandButton value="To" action="{!addToList}"/>
<apex:commandButton value="CC" action="{!addCCList}"/>

<br/> Selected aditional TO email ID is : {!toList}
<!-- <apex:dataList value="{!toList}" var="c">{!c}</apex:dataList> -->
<br/> Selected CC email ID is : {!ccList} <!-- <apex:dataList value="{!ccList}" var="c">{!c}</apex:dataList> -->

<br/> <apex:commandButton value="Next" action="{!conAddEmailsIds}"/>
</apex:form>
</apex:page>

 

Apex code:

 

public class conAddmailsIds{

public String [] emailToAdd{get;set;}
public String [] toList{get;set;}
public String [] ccList{get;set;}

public Pagereference conAddEmailsIds(){
system.debug('@@@@@@ in add'+toList);
PageReference p = new PageReference('/_ui/core/email/author/EmailAuthor?p24='+toList+'&p4='+ccList);
return p;
}
public Pagereference addToList(){
system.debug('@@@@@@ in to list'+emailToAdd);
toList = emailToAdd;
return null;
}
public Pagereference addCCList(){
ccList = emailToAdd;
return null;
}
}

Can anyone help me to figure out when there no action on click of button?

 

Regards,

Manasa

bvramkumarbvramkumar
Try this

public Pagereference conAddEmailsIds(){
system.debug('@@@@@@ in add'+toList);
PageReference p = new PageReference('/_ui/core/email/author/EmailAuthor?p24='+toList+'&p4='+ccList);
p.setRedirect(true);
return p;
}
Manasa.RManasa.R

Sorry, it didnt work.

 

Value is not even getting for emailToAdd.

Action is not invoking addToListmethod itself.

Rahul SharmaRahul Sharma
Manasa.R, You need to add rerender attribute to apex:commandbutton's.
The page simply refreshes by default when you don't add them.
S DigalS Digal

Hey

 

I have modified some of it. Check it out.

 

<apex:page controller="conAddmailsIds" >
<apex:form id="formid">
Select Emails Ids:
<!-- <apex:selectRadio value="{!emailToAdd}" > <br/> -->
<apex:selectCheckboxes value="{!emailToAdd}" id="selectcheckboxid">
<apex:selectOption itemLabel="manasa.r@hp.com" itemValue="manasa.r@hp.com"></apex:selectOption> 
<apex:selectOption itemLabel="manasa.r.gupta@gmail.com" itemValue="manasa.r.gupta@gmail.com"> </apex:selectoption>
<apex:selectOption itemLabel="abc@def.com" itemValue="abc@def.com"></apex:selectOption>
<apex:selectOption itemLabel="ghi@jkl.com" itemValue="ghi@jkl.com"></apex:selectOption>
<apex:selectOption itemLabel="mno@pqr.com" itemValue="mno@pqr.com"></apex:selectOption>
</apex:selectCheckboxes>
<!-- </apex:selectRadio> -->
<apex:commandButton value="To" action="{!addTOList}" reRender="toid"/>
<apex:commandButton value="CC" action="{!addCCList}" reRender="ccid"/>

<apex:outputPanel id="toid">
<br/> Selected aditional TO email ID is : {!emailToAdd}
</apex:outputPanel>
<!-- <apex:dataList value="{!toList}" var="c">{!c}</apex:dataList> -->
<apex:outputPanel id="ccid">
<br/> Selected CC email ID is : {!emailToAdd} <!-- <apex:dataList value="{!ccList}" var="c">{!c}</apex:dataList> -->
</apex:outputPanel>

<br/> <apex:commandButton value="Next" action="{!conAddEmailsIds}"/>
</apex:form>
</apex:page>

 

public class conAddmailsIds{

    String[] emailToAdd = new String[]{};
    String[] toList;
    String[] ccList;

    public String[] getEmailToAdd() {
        return emailToAdd;
    }

    public void setEmailToAdd(String[] emailToAdd) {
        this.emailToAdd = emailToAdd;
    }

    public PageReference addTOList() {
    system.debug('Inside TOList:-'+emailToAdd);
    toList = emailToAdd;
        return null;
    }

    public PageReference addCCList() {
    system.debug('Inside CCList:-'+emailToAdd);
    ccList = emailToAdd;
        return null;
    }

    public Pagereference conAddEmailsIds(){
    system.debug('Inside Next To List:-'+toList);
    system.debug('Inside Next CC List:-'+ccList);    
    PageReference p = new PageReference('/_ui/core/email/author/EmailAuthor?p24='+toList+'&p4='+ccList);
    return p;
    }
}

 Try to execute the above VF page and Apex class, it works now. I did some changes to your code.