Skip to main content

Hi All,


how to handle wrapper class in skuid? I mean how to build skuid page for VF which contain wrapper class?


this page is portal page.


my visualforce screen:


!(https://us.v-cdn.net/6032350/uploads/attachments/RackMultipart20150514-25895-1lgk3zc-KMCT_Portal_Wrapper 1 inline.png “Image https//d2r1vs3d9006apcloudfrontnet/s3_images/1204337/RackMultipart20150514-25895-1lgk3zc-KMCT_Portal_Wrapper__1__inlinepng1431581793”)


below i pasted visualforce and controller code.


VF:



.customPopup{
background-color: white;
border-style: solid;
border-width: 1px;
left: 50%;
padding:10px;
position: absolute;
z-index: 9999;
/* These are the 3 css properties you will need to tweak so the pop
up displays in the center of the screen. First set the width. Then set
margin-left to negative half of what the width is. You can also add
the height property for a fixed size pop up.*/
width: 500px;
margin-left: -250px;
top:30%;
}

body .btndl{
line-height:1px;}








    <b>Data Entry Date: <img src="/img/alohaSkin/help_orange.png" title="Select the order from the drop down list"> </b> 
<selectlist value="{!selectedrecord}" multiselect="false" size="1" style="width:180px;text-align:right;">
<selectoptions value="{!items}"></selectoptions>
<actionsupport action="%7B!ViewRecordsforRoadSkills%7D" event="onchange"></actionsupport>
</selectlist>
<!-- <apex:commandButton action="{!Edit}" value="Edit" reRender="popup"><br /> <apex:param name="a" value="{!selectedrecord}" assignTo="{!EditId}"/><br /> </apex:commandButton> -->
</div>
<commandbutton action="%7B!Export%7D" value="Download" styleclass="btndl" style="width:100px; font-size:10px;"></commandbutton>
<commandbutton action="%7B!Edit%7D" value="Edit" styleclass="btndl" style="width:100px; font-size:10px;" rerender="popup">
<param name="a" value="{!selectedrecord}" assignto="{!EditId}">

</commandbutton> <b> Click here to edit data supplied </b>


<pageblocktable value="{!Recordsinner}" var="ri">
<!--<apex:column value="{!ri.schemetype}" headerValue="Scheme Type"/> -->
<column value="{!ri.childname}" headervalue="Name Of Child"></column>
<column value="{!ri.awardname}" headervalue="Award Name"></column>
</pageblocktable>
</pageblock>
<commandbutton action="%7B!Export%7D" value="Download" styleclass="btndl" style="width:100px; font-size:10px; margin-left:20px;"></commandbutton>
<commandbutton action="%7B!Edit%7D" value="Edit" styleclass="btndl" style="width:100px; font-size:10px; " rerender="popup">
<param name="a" value="{!selectedrecord}" assignto="{!EditId}">

</commandbutton> <b> Click here to edit data supplied </b>

<outputpanel id="popup">
<outputpanel styleclass="customPopup" layout="block" rendered="{!displayPopUp}" id="displayPopup" style="width:60%;">
<pageblock>
<pageblocksection title="Edit Record"></pageblocksection>
<pageblockbuttons>
<commandbutton value="Save" styleclass="btndl" style="width:100px; font-size:10px;" action="%7B!SaveClass%7D" rerender="popup,formId"></commandbutton>
<commandbutton value="Cancel" styleclass="btndl" style="width:100px; font-size:10px;" action="%7B!closePopup%7D" rerender="popup" immediate="true"></commandbutton>
</pageblockbuttons>

<pageblocksection>
<inputfield value="{!rs.Number_Of_Bronze __c}"></inputfield>
<inputfield value="{!rs.Bronze_Children_Names__ c }" style="width:220px; height:100px"></inputfield>
</pageblocksection>
<pageblocksection title="Silver Award">
<inputfield value="{!rs.Number_Of_Silver __c}"></inputfield>
<inputfield value="{!rs.Silver_Children_Names__ c }" style="width:220px; height:100px"></inputfield>
</pageblocksection>
<pageblocksection title="Gold Award">
<inputfield value="{!rs.Number_Of_Gold __c}"></inputfield>
<inputfield value="{!rs.Gold_Children_Names__ c }" style="width:220px; height:100px"></inputfield>

</pageblocksection>
</pageblock>
</outputpanel>
</outputpanel>



**Class:


** //Controller Startspublic with sharing class viewrecordsforroadskillscon

{

//----------Variables Declaration Starts

Public Road_Safety_Skill_Test_Results__c rs{get;set;}

Public list<road_safety_skill_test_results c> listrs{get;set;}

Public LIST items{get;set;}

Public list<road_safety_skill_test_results
c> totallistrs{get;set;}

Public List Recordsinner{get;set;}

Public String selectedrecord{get;set;}

public list> matforexport {get;set;}

public LIST<road_safety_skill_test_results c> totalmatchesexport{get;set;}

public LIST<road_safety_skill_test_results
c> bn{get;set;}

public Id EditId{get;set;}

public boolean displayPopup {get;set;}

public String PassedURLId {get;set;}

public User U{get;set;}

public List Con {get;set;}

public Account a{get;set;}

//Variables Declaration Ends--------------


//--Constructor Starts
public viewrecordsforroadskillscon()
{
getvalues();
ViewRecordsforRoadSkills();
displayPopup = false;
PassedURLId = ApexPages.currentPage().getParameters().get('CampaignId');
}
//Constructor Ends--

//Getting All The records into the picklist starts
public void getvalues()
{

U = new User();
U = Uselect id,firstName,LastName,ContactId,Contact.Name from user where Id =: Userinfo.getUserId()];

Con = nselect id,Accountid,Account.Name,CreatedDate from Contact where id =:U.ContactId];




LIST<road_safety_skill_test_results __c> totallistrs = new LIST <road_safety_skill_test_results__ c>();
items = new LIST<selectoption>();

if(Con .Size()> 0 )
totallistrs = sSELECT id,Name,Scheme_Type __c,CreatedDate,Bronze_Children_Names__ c,Number_Of_Bronze __c,Number_Of_Gold__ c,Gold_Children_Names __c,Number_Of_Silver__ c,Silver_Children_Names __c
FROM Road_Safety_Skill_Test_Results__ c WHERE Contact__c =: Con 0].id Order By CreatedDate ASC];

if(!totallistrs.isEmpty() &amp;&amp; totallistrs.size() > 0 &amp;&amp; totallistrs.size()!=Null )
{
for (Road_Safety_Skill_Test_Results__c rst: totallistrs)
{
if(rst.id != null)
{
Items.add(new SelectOption(rst.id, string.valueof(rst.CreatedDate.format('dd/MM/yyyy hh:mm'))));
selectedrecord = rst.id;
}
}
}
}
//Getting All The records into the picklist Ends

//Splitting the Names with Commas(,) code begins
public void ViewRecordsforRoadSkills(){
try{

U = new User();
U = Uselect id,firstName,LastName,ContactId,Contact.Name from user where Id =: Userinfo.getUserId()];

Con = nselect id,Accountid,Account.Name,CreatedDate from Contact where id =:U.ContactId];



listrs =rSELECT id,Name,Scheme_Type __c,CreatedDate,Bronze_Children_Names__ c,Number_Of_Bronze __c,Number_Of_Gold__ c,Gold_Children_Names __c,Number_Of_Silver__ c,Silver_Children_Names __c
FROM Road_Safety_Skill_Test_Results__ c
WHERE id =: selectedrecord ORDER BY CreatedDate];
Recordsinner = new LIST<viewrecordsinner>();
String child;
String award;
for(Road_Safety_Skill_Test_Results__c ss : listrs){
if(ss.Bronze_Children_Names__c.contains(',')){
for(String s : ss.Bronze_Children_Names__c.split(',')){
child = s;
award = 'Bronze Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
}
else{
child = ss.Bronze_Children_Names__c;
award = 'Bronze Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
if(ss.Silver_Children_Names__c.contains(',')){
for(String s : ss.Silver_Children_Names__c.split(',')){
child = s;
award = 'Silver Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
}
else{
child = ss.Silver_Children_Names__c;
award = 'Silver Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
if(ss.Gold_Children_Names__c.contains(',')){
for(String s : ss.Gold_Children_Names__c.split(',')){
child = s;
award = 'Gold Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
}
else{
child = ss.Gold_Children_Names__c;
award = 'Gold Award';
ViewRecordsInner vri = new ViewRecordsInner(ss,child,award);
Recordsinner.add(vri);
}
}
}
catch(exception ex){
}
}
//Splitting the Names with Commas(,) code Ends

//Inner Class for displaying Name and Award code Begins
Public Class ViewRecordsInner{
public string childname{get;set;}
public string awardname{get;set;}
public String Schemetype{get;set;}
public ViewRecordsInner(Road_Safety_Skill_Test_Results__c sch,String child,String award)
{
Schemetype = sch.Scheme_Type__c;
childname = child;
awardname = award;
}
}
//Inner Class for displaying Name and Award code Ends

//Download a record code begins

public pagereference export()

{

matforexport = new list>();

totalmatchesexport = tSELECT id,Name,Scheme_Type c,Bronze_Children_Names c,Number_Of_Bronze c,Number_Of_Gold c,Gold_Children_Names c,Number_Of_Silver c,Silver_Children_Names c

FROM Road_Safety_Skill_Test_Results
c];

bn = new list<road_safety_skill_test_results__c>();

for(Road_Safety_Skill_Test_Results__c s: totalmatchesexport )

{

//s.Bronze_Children_Names__c = escape(s.Bronze_Children_Names__c);

//s.Gold_Children_Names__c = escape(s.Gold_Children_Names__c);

//s.Silver_Children_Names__c = escape(s.Silver_Children_Names__c);


   bn.add(s);
}
matforexport .add(bn);
pagereference pg =page.ExportSchedule;
return pg;

}

//Download a record code Ends


//Edit button Code Begins

public void Edit()

{


if(Con .Size()> 0 )

rs= SELECT id,Name,Scheme_Type c,Bronze_Children_Names c,Number_Of_Bronze c,Number_Of_Gold c,Gold_Children_Names c,Number_Of_Silver c,Silver_Children_Names c

FROM Road_Safety_Skill_Test_Results
c

WHERE id =: selectedrecord];

displayPopup = true;

}

//Edit button Code Ends


//Page reference for view records starts
public pagereference Viewrec()
{
pagereference pg= new pagereference('/apex/viewrecordsforroadskills?campaignId='+PassedURLId);
pg.setRedirect(true);
return pg;
}
//Page reference for view records Ends

//Page reference for Entering Data starts
public pagereference enter()
{
pagereference pg= new pagereference('/apex/roadsafetyskillstest?CampaignId='+PassedURLId);
pg.setRedirect(true);
return pg;
}
//Page reference for Entering Data Ends

//Save Method for pop up when click on Edit button- code starts

public void SaveClass()

{

if(rs != null)

update rs;

displayPopup = false;

ViewRecordsforRoadSkills();

}

//Save Method for pop up when click on Edit button- code Ends


//Closing pop up method starts

public void closePopup()

{

displayPopup = false;

}

//Closing pop up method Ends

}

//Controller Ends



Thanks,

Shaik.</road_safety_skill_test_results c></road_safety_skill_test_results c></road_safety_skill_test_results c></road_safety_skill_test_results c></road_safety_skill_test_results c></road_safety_skill_test_results c></road_safety_skill_test_results__c>


He Shaik, I’m having a little trouble understanding exactly what you are doing here. Are you attempting to have a Skuid page be served up progromatically by Apex into your Visualforce page?


Hi Andrew,

Above screen and code was Total functionality of the visualforce page, In that they wrote wrapper class (Recordsinner) like stuff. result shown on screen was from wrapper class.

In the same way How we can handle Wrapper stuff in SKUID?

Thanks,
Shaik.


Shaik,

The short answer is Skuid models require an actual sObject, and there isn’t an “out of the box” way to attach them to a wrapper class. They have a tight correspondence to SOQL queries. Splitting the “Child Names” fields and multiple award types out into multiple records is the real sticking point. In order to really get this to work with Skuid, those will need to be actual records in an sObject, or you’d have to replicate that logic in JavaScript and provide your own UI. A custom table view comes to mind as way to accomplish this.

I know that’s not the happiest answer, but hopefully it helps.


Reply