how to handle wrapper classes in skuid?

  • 1
  • Question
  • Updated 3 years ago
  • (Edited)
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:





below i pasted visualforce and controller code.

VF:

<apex:page controller="viewrecordsforroadskillscon" showHeader="True" ><style type="text/css">
           .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;}
        </style>


  <apex:form id="formId" >
  <apex:commandButton action="{!enter}" StyleClass="btndl" style="width:170px; font-size:10px;" value="Road Safety Skills Data"/>
  <apex:commandButton action="{!Viewrec}" StyleClass="btndl" style="width:170px; font-size:10px" value="Previously Submitted Data"/>
  <apex:pageBlock title="View Records">      
        <div style="float:
        leftt;height:30px;">
        <b>Data Entry Date: <img src="/img/alohaSkin/help_orange.png" title="Select the order from the drop down list"/> </b>&nbsp;
        <apex:selectList value="{!selectedrecord}" multiselect="false" size="1" style="width:180px;text-align:right;">
                <apex:selectOptions value="{!items}"/>
                <apex:actionSupport action="{!ViewRecordsforRoadSkills}" event="onchange"/>
        </apex:selectList>
       <!-- <apex:commandButton action="{!Edit}" value="Edit" reRender="popup">
        <apex:param name="a" value="{!selectedrecord}" assignTo="{!EditId}"/>
         </apex:commandButton> -->
        </div>       
        <apex:commandButton action="{!Export}" value="Download" StyleClass="btndl" style="width:100px; font-size:10px;"/>
    <apex:commandButton action="{!Edit}" value="Edit" StyleClass="btndl" style="width:100px; font-size:10px;" reRender="popup">
    <apex:param name="a" value="{!selectedrecord}" assignTo="{!EditId}"/>
    </apex:commandButton> <B> Click here to edit data supplied </B>

        
        <apex:pageBlockTable value="{!Recordsinner}" var="ri">
            <!--<apex:column value="{!ri.schemetype}" headerValue="Scheme Type"/> --> 
            <apex:column value="{!ri.childname}" headerValue="Name Of Child"/> 
            <apex:column value="{!ri.awardname}" headerValue="Award Name"/>             
        </apex:pageBlockTable>         
    </apex:pageBlock> 
    <apex:commandButton action="{!Export}" value="Download" StyleClass="btndl" style="width:100px; font-size:10px; margin-left:20px;"/>
    <apex:commandButton action="{!Edit}" value="Edit" StyleClass="btndl" style="width:100px; font-size:10px; " reRender="popup"> 
        <apex:param name="a" value="{!selectedrecord}" assignTo="{!EditId}"/>
    </apex:commandButton> <B> Click here to edit data supplied </B>
    
    <apex:outputPanel id="popup">
                  <apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}" id="displayPopup" style="width:60%;">
                      <apex:pageBlock > 
                        <apex:pageBlockSection title="Edit Record" ></apex:pageBlockSection>
                            <apex:pageBlockButtons >
                                <apex:commandButton value="Save" StyleClass="btndl" style="width:100px; font-size:10px;" action="{!SaveClass}" rerender="popup,formId"/>
                                <apex:commandButton value="Cancel" StyleClass="btndl" style="width:100px; font-size:10px;" action="{!closePopup}" rerender="popup" immediate="true"/>                                
                            </apex:pageBlockButtons>
                    
                            <apex:pageBlockSection >
                            <apex:inputField value="{!rs.Number_Of_Bronze__c}"/>
                              <apex:inputField value="{!rs.Bronze_Children_Names__c }" style="width:220px; height:100px"/>
                              </apex:pageBlockSection>
                              <apex:pageBlockSection title="Silver Award">
                              <apex:inputField value="{!rs.Number_Of_Silver__c}"/>
                              <apex:inputField value="{!rs.Silver_Children_Names__c }" style="width:220px; height:100px"/>
                              </apex:pageBlockSection>
                              <apex:pageBlockSection title="Gold Award">
                              <apex:inputField value="{!rs.Number_Of_Gold__c}"/>
                              <apex:inputField value="{!rs.Gold_Children_Names__c }" style="width:220px; height:100px"/>

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

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<selectoption> items{get;set;}
    Public list<Road_Safety_Skill_Test_Results__c> totallistrs{get;set;}
    Public List<ViewRecordsInner> Recordsinner{get;set;}
    Public String selectedrecord{get;set;}
    public list<list<Road_Safety_Skill_Test_Results__c>> 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<Contact>  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 = [select id,firstName,LastName,ContactId,Contact.Name from user where Id =: Userinfo.getUserId()];
       
        Con = [select 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 = [SELECT 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() && totallistrs.size() > 0 && 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 = [select id,firstName,LastName,ContactId,Contact.Name from user where Id =: Userinfo.getUserId()];
       
        Con = [select id,Accountid,Account.Name,CreatedDate from Contact where id =:U.ContactId ];  
        
    
    
     listrs =[SELECT 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<list<Road_Safety_Skill_Test_Results__c>>();    
      totalmatchesexport = [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];
      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.
Photo of Shaik

Shaik

  • 370 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Andrew Duensing

Andrew Duensing, Employee

  • 740 Points 500 badge 2x thumb
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?
Photo of Shaik

Shaik

  • 370 Points 250 badge 2x thumb
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.
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
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.