• Mr. Met
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

On my VF page, I am rerendering the pageblock after the user selects from a picklist.  There can be variable # of rows on the page.  After the user selects a value for each row, additional columns are displayed.  The column with the required flag shows the red bar next to the input box but no error validation takes place when the user click on the save button.

 

Any ideas????

 

VF Page - 

<apex:page standardController="STG_Car_Stock_Sale_Items__c" extensions="CarStockSaleItemManageListController" >
<!-- <apex:page controller="ManageListController"> -->
<apex:form >

<apex:pageBlock title="Car Stock Sale Items">
<apex:pageMessages />
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/> 
<apex:commandButton value="Cancel" action="{!cancel}"/> 
</apex:pageBlockButtons>

<apex:pageBlockButtons location="bottom"> 
<apex:commandButton value="Save" action="{!save}"/> 
<apex:commandButton value="Cancel" action="{!cancel}"/> 
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">

<apex:column headerValue="Line #">
<apex:outputText value="{!wrapper.ident}"/>
</apex:column>
<apex:column headerValue="Car Stock Sale ID">
<apex:outputField value="{!wrapper.acc.Name}"/>
</apex:column>

<apex:column headerValue="Product">
<apex:selectList id="ProdAvail" value="{!wrapper.acc.STG_Car_Stock_Product__c}" size="1" >
<apex:actionSupport event="onchange" action="{!CSProdData}" reRender="wtable">
   <apex:param name="GetProductLine" value="{!wrapper.ident}" assignTo="{!GetProductLine}"/> 
</apex:actionSupport>
<apex:selectOptions value="{!ProdAvail}"></apex:selectOptions>
</apex:selectList>
</apex:column>

<apex:column headerValue="Quantity On Hand" id="test">
<apex:actionRegion >
<!-- <apex:outputField value="{!wrapper.acc.Quantity_Available__c}" rendered="{!DisplayFields}" /> -->
<apex:outputField value="{!wrapper.acc.Quantity_Available__c}"/>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Quantity (# of Units)">
<apex:inputField value="{!wrapper.acc.Quantity__c}" required="{!DisplayFields}" style="display:{!IF(!DisplayFields == false,'inline', 'none')}" />
</apex:column>
<apex:column headerValue="Price (per Unit)">
<apex:inputField value="{!wrapper.acc.Unit_Price__c}" style="display:{!IF(!DisplayFields == false,'inline', 'none')}" />
</apex:column>

</apex:pageBlockTable>
</apex:pageBlock>

</apex:form>
</apex:page>

  

Controller - 

public with sharing class CarStockSaleItemManageListController 
{ 
 public List<AccountWrapper> wrappers {get; set;}
 public STG_Car_Stock_Sale__c css {get; set;}
 private String cssiname;
 Id returnCSid;
 public static Integer GetProductLine {get; set;}
 public static String GetProduct {get; set;}
 public static String GetProductscreen {get; set;}
 Public STG_Car_Stock_Product__c CSPData {get; set;}
 public static Boolean DisplayFields {get; set;}
 private Integer CountProducts;
  
 public CarStockSaleItemManageListController (ApexPages.StandardController stdController) {
    Id currentStockSaleId = ApexPages.CurrentPage().getParameters().get('carstock');
    returnCSid = currentStockSaleId;
    if(currentStockSaleId != null){
        this.css = [Select Name, Id, Number_of_Lines__c, Customer_Account__c, STG_Car_Stock__c 
                    From STG_Car_Stock_Sale__c where Id =:currentStockSaleId ];
     }                  
          
  wrappers=new List<AccountWrapper>();

  for (Integer idx=1; idx<=css.Number_of_Lines__c; idx++)
  {
   if(idx < 10){
      cssiname = css.name + '0' + idx;
   } else {
      cssiname = css.name + idx;
   }
   wrappers.add(new AccountWrapper(idx, cssiname, currentStockSaleId));
  }

 }
 
  //builds a picklist of Products based on the wholesale account
  public List<selectOption> getProdAvail() {
  
     //new list for holding all of the picklist options
     List<selectOption> options = new List<selectOption>(); 

     //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below  
     options.add(new selectOption('', '- None -')); 
     //System.debug('************ Query:11 ************ ' + scp);   

     //query for Product records 
     for (STG_Car_Stock_Product__c acctpa : [SELECT Id, Product__c FROM STG_Car_Stock_Product__c 
     WHERE STG_Car_Stock__c = :css.STG_Car_Stock__c AND Quantity_On_Hand__c > 0 ORDER BY Product__c]) { 

        //for all records found - add them to the picklist options
        options.add(new selectOption(acctpa.id, acctpa.Product__c)); 
     }
  
  //return the picklist options
  return options; 
  }
  
 public PageReference save()
 {
  System.debug('************ Query:ACTION SAVE1 ************ ' + wrappers[1].acc.Quantity__c);
  System.debug('************ Query:ACTION SAVE2 ************ ' + wrappers[0].acc.Unit_Price__c);
  List<STG_Car_Stock_Sale_Items__c> accs=new List<STG_Car_Stock_Sale_Items__c>();
  for (AccountWrapper wrap : wrappers)
  {
   accs.add(wrap.acc);
  }
  System.debug('************ Query:ACTION SAVE2 ************ ' + accs); 
  insert accs;
  
  PageReference returnPage = new PageReference('/' + returnCSid);
            returnPage.setRedirect(true);
            return returnPage; 
 }
 
 public PageReference cancel()
 {
  PageReference returnPage = new PageReference('/' + returnCSid);
            returnPage.setRedirect(true);
            return returnPage; 
 }
 
 public PageReference CSProdData(){
     GetProductLine = GetProductLine-1;
     GetProduct = Wrappers[GetProductLine].acc.STG_Car_Stock_Product__c;
     if (GetProduct != null) {
        CSPData = [SELECT Id, Last_Purchase_Price_per_Unit__c, Product__c, Quantity_On_Hand__c 
                   FROM STG_Car_Stock_Product__c
                   WHERE Id = :GetProduct.substring(0,15)];
     Wrappers[GetProductLine].acc.Quantity_Available__c = CSPData.Quantity_On_Hand__c;
     Wrappers[GetProductLine].acc.Unit_Price__c = CSPData.Last_Purchase_Price_per_Unit__c.setScale(2);
     Wrappers[GetProductLine].acc.Avg_Purchase_Price__c = CSPData.Last_Purchase_Price_per_Unit__c;
          
     DisplayFields = false;
     CountProducts = 0;
     for (Integer idx=0; idx<=(Wrappers.size()-1); idx++)
     {
       GetProduct = Wrappers[idx].acc.STG_Car_Stock_Product__c;
       if(GetProduct != null){
          CountProducts = CountProducts + 1;
       } 
     }
       if (CountProducts == Wrappers.size()) {
          DisplayFields = true;
       }
       //System.debug('************ Query:ACTION FOR7 ************ ' + CountProducts);
       //System.debug('************ Query:ACTION FOR8 ************ ' + Wrappers.size());
       //System.debug('************ Query:ACTION FOR9 ************ ' + DisplayFields); 
     } 
     return null;
 }
  
 public class AccountWrapper
 {
  public STG_Car_Stock_Sale_Items__c acc {get; private set;}
  public String iname {get; private set;}
  public String inamecss {get; private set;}
  public Integer ident {get; private set;}
  
  //public AccountWrapper(String inIdent)
  public AccountWrapper(Integer inIdent, String inName, String InNameCSS)
  {
   ident=inIdent;
   iname=inName;
   inamecss=inNameCSS;
   acc=new STG_Car_Stock_Sale_Items__c(Name = iname, Line_Number__c = ident, STG_Car_Stock_Sale__c = inamecss);
  }
 }
}

 

I am new to writing VF pages. I have a VF page and Apex Class that I have written to override the NEW button for my custom object.  However, all that displays are the buttons at the top and bottom of the page, no fields.  Can anyone take a look and point me in the right direction to correct my issue?

 

Thank you

 

VF Page - 

<apex:page standardController="STG_Payment_Requests__c" extensions="ContentNewSTGPR">
<apex:sectionHeader title="STG Payment Request" subtitle="{!STG_Payment_Requests__c.name}"/>
<apex:form >
<apex:pageBlock title="New STG Payment Request">

<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!STGPR}" var="a" id="table">

<apex:pageBlockSection title="Information" columns="2">

<apex:outputField value="{!a.Account_Name__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Name}"/>
<apex:inputField value="{!a.Quantity__c}" required="true"/>
<apex:outputField value="{!a.STG_Promotion__c}"/>
<apex:outputField value="{!a.Payment_Amount__c}"/>
<apex:outputField value="{!a.Lane_Vendor_Number__c}"/>
<apex:inputField value="{!a.Reference_for_remittance__c}" required="false"/>
<apex:outputField value="{!a.Promoted_Brand__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotion_Type__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotional_Rate__c}"/>
<apex:inputField value="{!a.Comments__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Senior_Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Director_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.File_Attached_to_Payment_Request__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Paid__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:OutputField value="{!a.Paid_Date__c}"/>

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

 

Apex Class -

public class ContentNewSTGPR {

public ContentNewSTGPR(ApexPages.StandardController controller) {

}


public List<STG_Payment_Requests__c> STGPR {get; set;}

public ContentNewSTGPR(){
STGPR = new List<STG_Payment_Requests__c>();
STGPR.add(new STG_Payment_Requests__c());
}

public void addrow(){
STGPR.add(new STG_Payment_Requests__c());
}

public PageReference save(){
insert STGPR;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}
}

  • September 09, 2013
  • Like
  • 0

I am new to writing VF pages. I have a VF page and Apex Class that I have written to override the NEW button for my custom object.  However, all that displays are the buttons at the top and bottom of the page, no fields.  Can anyone take a look and point me in the right direction to correct my issue?

 

Thank you

 

VF Page - 

<apex:page standardController="STG_Payment_Requests__c" extensions="ContentNewSTGPR">
<apex:sectionHeader title="STG Payment Request" subtitle="{!STG_Payment_Requests__c.name}"/>
<apex:form >
<apex:pageBlock title="New STG Payment Request">

<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Update" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!STGPR}" var="a" id="table">

<apex:pageBlockSection title="Information" columns="2">

<apex:outputField value="{!a.Account_Name__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Name}"/>
<apex:inputField value="{!a.Quantity__c}" required="true"/>
<apex:outputField value="{!a.STG_Promotion__c}"/>
<apex:outputField value="{!a.Payment_Amount__c}"/>
<apex:outputField value="{!a.Lane_Vendor_Number__c}"/>
<apex:inputField value="{!a.Reference_for_remittance__c}" required="false"/>
<apex:outputField value="{!a.Promoted_Brand__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotion_Type__c}"/>
<apex:pageBlockSectionItem />
<apex:outputField value="{!a.Promotional_Rate__c}"/>
<apex:inputField value="{!a.Comments__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Senior_Manager_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Director_Approved__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.File_Attached_to_Payment_Request__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:inputField value="{!a.Paid__c}" required="false"/>
<apex:pageBlockSectionItem />
<apex:OutputField value="{!a.Paid_Date__c}"/>

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

 

Apex Class -

public class ContentNewSTGPR {

public ContentNewSTGPR(ApexPages.StandardController controller) {

}


public List<STG_Payment_Requests__c> STGPR {get; set;}

public ContentNewSTGPR(){
STGPR = new List<STG_Payment_Requests__c>();
STGPR.add(new STG_Payment_Requests__c());
}

public void addrow(){
STGPR.add(new STG_Payment_Requests__c());
}

public PageReference save(){
insert STGPR;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}
}

  • September 09, 2013
  • Like
  • 0