+ Start a Discussion
sonatinesonatine 

passing selected values to 2nd page

guys i need some help.

i have two pages,

the first page should display the list of  Class Name and checkboxes.

it will allow the user to choose "Classes" and display them in the second page when the user click the "Submit" button.

 

my problem is: the second page should be a pop-up window.

 

i know how to do it via the controller if second page is Not a new pop-up window,

by getting the list of checked Classes, and using something like "return Page.SecondPage".

 

is it possible to display PageReference in a new window?

or do we have to use Javascript to do this?

 

can anyone help me on this please?

or tell me which tutorial or Javascript guide i should read, as i know very little about Javascript.

 

thanks in advance.

 

first page:

 

<apex:page controller="CheckboxPassValue_controller" showHeader="false">
<apex:form >
<apex:dataTable value="{!List}" var="l" >
<apex:column headerValue="Class Name" >
<apex:outputText value="{!l.cls.Name}" />
</apex:column>
<apex:column headerValue="Checkbox" >
<apex:inputCheckbox value="{!l.selected}" />
</apex:column>
</apex:dataTable>
<apex:commandButton value="Submit" action="PageTwo"/>
</apex:form>
</apex:page>

 

and this is how i did it using pagereference:

second page:

 

<apex:page controller="CheckboxPassValue_controller" showHeader="false">
<apex:form >
<apex:dataTable value="{!Selected}" var="sel" >
<apex:column headerValue="The List" >
<apex:outputText value="{!sel.Name}" />
</apex:column>
</apex:dataTable>
</apex:form>
</apex:page>

 controller:

 

public with sharing class CheckboxPassValue_controller {
public List<cClass> listOfCClass {get; set;}
public List<SFDC_Class__c> listOfCls {get; set;}

public List<cClass> getList() {
if (listOfCClass == null) {
listOfCClass = new List<cClass>();
List<SFDC_Class__c> classList = [SELECT Id, Name
FROM SFDC_Class__c LIMIT 5];
for (SFDC_Class__c c : classList) {
cClass cC = new cClass(c);
listOfCClass.add(cC);
}
}
return listOfCClass;
}

public List<SFDC_Class__c> getSelected() {
listOfCls = new List<SFDC_Class__c>();
for (cClass cC : getList()) {
if (cC.getSelected() == true) {
listOfCls.add(cC.getCls());
}
}
return listOfCls;
}

public PageReference PageTwo() {
return Page.CheckboxPassValue_pageTwo;
}

public class cClass {
SFDC_Class__c cls = new SFDC_Class__c();
public void setCls(SFDC_Class__c a) {
this.cls = a;
}
public SFDC_Class__c getCls() {
return cls;
}

Boolean selected;
public void setSelected(Boolean f) {
this.selected = f;
}
public Boolean getSelected() {
return selected;
}

public cClass() {
selected = false;
}

public cClass(SFDC_Class__c c) {
cls = c;
selected = false;
}
}
}

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
WesNolte__cWesNolte__c

Hey

 

Haven't done it for a while but I think you can use the target="_blank" on the commandLink and use CSS to style it so that it looks like a commandbutton e.g.

 

 <apex:commandLink styleClass="btn" target="_blank" value="Submit" action="{!PageTwo}"/>

 

Wes

 

 

All Answers

WesNolte__cWesNolte__c

Hey

 

Haven't done it for a while but I think you can use the target="_blank" on the commandLink and use CSS to style it so that it looks like a commandbutton e.g.

 

 <apex:commandLink styleClass="btn" target="_blank" value="Submit" action="{!PageTwo}"/>

 

Wes

 

 

This was selected as the best answer
sonatinesonatine

hey weznolte, thanks for the idea, ill try it tomorrow, its 10pm here hehe.

but if we use commandLink, is it possible to control the pop-up window appearance? size of the new window for example.

sonatinesonatine

yep, the commandLink works perfectly.

now, can anyone help me on how to customise the pop-up window?

thanks in advance.