• jack2000
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi there. I m newbie in developement via this platform, so be patient.

 

I trying to create simple Visualforce page that contains a table with my merchandises (like a Warehouse testing app in workbook) and control buttons on this page. Control buttons are "Edit", "Save", "New", "Find", "Delete" and others like in standart controllers.

How to create logic to this buttons? I was created "Find' button and added logic. Thiis was simple.

But how to create logic in apex class to save edited row in table? In each colomn i added   <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>, so i can edit some rows in some columns that i need.

But how to insert changes in table? Where i need to find variables, that contains number of row edited and name of the column?

 

So, please help me - tell, or show the sources, how to realise that logic.

Same problems with  "Add new object to table"   and "Delete object from table" logic .

My Visualforce page source code:

<apex:page standardStylesheets="false" showHeader="false" sidebar="false"
           controller="VRP_controller" >
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
    <h1>Headphones Shop</h1>
    <apex:form >
   <apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
        <apex:column headerValue="Product">
            <apex:outputfield value="{!pitem.merchandise.name}">
            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
        </apex:column>         
        <apex:column headerValue="Product type">
            <apex:outputField value="{!pitem.merchandise.Product_Type__c}">
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
        </apex:column>
        <apex:column headerValue="Count in Stock">
            <apex:outputField value="{!pitem.merchandise.Product_Count__c}">
             <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
           </apex:column>
        <apex:column headerValue="Available">
            <apex:outputText value="{!pitem.merchandise.In_Stock__c}"/>
                     </apex:column>
        <apex:column headerValue="Release Date">
            <apex:outputText value="{0,date,yyyy.MM.dd}">
 <apex:param value="{!pitem.merchandise.Release_Date__c}" />
     
   </apex:outputText>
        </apex:column>
        <apex:column headerValue="Date Added">
            <apex:outputField value="{!pitem.merchandise.Date_Added__c}">
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
         </apex:column>
        <apex:column headerValue="Description">
            <apex:outputField value="{!pitem.merchandise.Description__c}"/>
       
        </apex:column>
       
        
</apex:dataTable>
<br />
<apex:PageBlock >

                <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" /> 

</apex:PageBlock>


<apex:inputText value="{!textarea}" />
   
<apex:commandButton action="{!find}" value="Find" />
<apex:commandButton action="{!back}" value="Back" />


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

 My Apex cusom controller code:

public class VRP_controller {

    public PageReference cancel() {
        return null;
    }

  
    
    public String message { get; set; }
    public String eval { get {return eval;} set{eval ='%'+value+'%';} }
   public String textarea { get {return textarea;} set{textarea = value;} }
    public PageReference back() {
      products=null;
       getProducts();
       return null;
    }
   
     public PageReference save() {
   for (DisplayMerchandise item :
            products) {

             insert item.merchandise;
             }
       return null;
    }
     public PageReference find() {
         eval=textarea;
       findProducts();
                
     return null;
    }  
        
    DisplayMerchandise[] products;
    DisplayMerchandise[] findedProducts;
    DisplayMerchandise[] backupProducts;
    public static boolean lock=false;
     
    
      
    public class DisplayMerchandise {
           
         public VRP_testing_app__c merchandise { get; set; }
        public DisplayMerchandise(VRP_testing_app__c item) {
            this.merchandise = item;
        }
   
    }

    public DisplayMerchandise[] getProducts() {
        if(products==null){
          products = new DisplayMerchandise[]{};
           for (VRP_testing_app__c item :
            [SELECT Name, Product_Type__c, Product_Count__c, In_Stock__c, Release_Date__c,Date_Added__c,Description__c
             FROM VRP_testing_app__c
             WHERE  In_Stock__c=true]) {

               products.add(new DisplayMerchandise(item));
             }
         }
     return products;      
    }
    
    public DisplayMerchandise[] findProducts(){
           
           findedProducts = new DisplayMerchandise[]{};
             for (VRP_testing_app__c item :
            [SELECT Name, Product_Type__c, Product_Count__c, In_Stock__c, Release_Date__c,Date_Added__c,Description__c
             FROM VRP_testing_app__c
             WHERE  (Name LIKE :eval)]){
              findedProducts.add(new DisplayMerchandise(item));
           }
         products=findedProducts;
     return findedProducts;      
    }
        
    }

 I know that is the bad style programming code, but i'm only studying.

Sorry for bad english - is not my native language.

Hi there. I m newbie in developement via this platform, so be patient.

 

I trying to create simple Visualforce page that contains a table with my merchandises (like a Warehouse testing app in workbook) and control buttons on this page. Control buttons are "Edit", "Save", "New", "Find", "Delete" and others like in standart controllers.

How to create logic to this buttons? I was created "Find' button and added logic. Thiis was simple.

But how to create logic in apex class to save edited row in table? In each colomn i added   <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>, so i can edit some rows in some columns that i need.

But how to insert changes in table? Where i need to find variables, that contains number of row edited and name of the column?

 

So, please help me - tell, or show the sources, how to realise that logic.

Same problems with  "Add new object to table"   and "Delete object from table" logic .

My Visualforce page source code:

<apex:page standardStylesheets="false" showHeader="false" sidebar="false"
           controller="VRP_controller" >
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
    <h1>Headphones Shop</h1>
    <apex:form >
   <apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
        <apex:column headerValue="Product">
            <apex:outputfield value="{!pitem.merchandise.name}">
            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
        </apex:column>         
        <apex:column headerValue="Product type">
            <apex:outputField value="{!pitem.merchandise.Product_Type__c}">
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
        </apex:column>
        <apex:column headerValue="Count in Stock">
            <apex:outputField value="{!pitem.merchandise.Product_Count__c}">
             <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
           </apex:column>
        <apex:column headerValue="Available">
            <apex:outputText value="{!pitem.merchandise.In_Stock__c}"/>
                     </apex:column>
        <apex:column headerValue="Release Date">
            <apex:outputText value="{0,date,yyyy.MM.dd}">
 <apex:param value="{!pitem.merchandise.Release_Date__c}" />
     
   </apex:outputText>
        </apex:column>
        <apex:column headerValue="Date Added">
            <apex:outputField value="{!pitem.merchandise.Date_Added__c}">
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
          </apex:outputField>
         </apex:column>
        <apex:column headerValue="Description">
            <apex:outputField value="{!pitem.merchandise.Description__c}"/>
       
        </apex:column>
       
        
</apex:dataTable>
<br />
<apex:PageBlock >

                <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" /> 

</apex:PageBlock>


<apex:inputText value="{!textarea}" />
   
<apex:commandButton action="{!find}" value="Find" />
<apex:commandButton action="{!back}" value="Back" />


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

 My Apex cusom controller code:

public class VRP_controller {

    public PageReference cancel() {
        return null;
    }

  
    
    public String message { get; set; }
    public String eval { get {return eval;} set{eval ='%'+value+'%';} }
   public String textarea { get {return textarea;} set{textarea = value;} }
    public PageReference back() {
      products=null;
       getProducts();
       return null;
    }
   
     public PageReference save() {
   for (DisplayMerchandise item :
            products) {

             insert item.merchandise;
             }
       return null;
    }
     public PageReference find() {
         eval=textarea;
       findProducts();
                
     return null;
    }  
        
    DisplayMerchandise[] products;
    DisplayMerchandise[] findedProducts;
    DisplayMerchandise[] backupProducts;
    public static boolean lock=false;
     
    
      
    public class DisplayMerchandise {
           
         public VRP_testing_app__c merchandise { get; set; }
        public DisplayMerchandise(VRP_testing_app__c item) {
            this.merchandise = item;
        }
   
    }

    public DisplayMerchandise[] getProducts() {
        if(products==null){
          products = new DisplayMerchandise[]{};
           for (VRP_testing_app__c item :
            [SELECT Name, Product_Type__c, Product_Count__c, In_Stock__c, Release_Date__c,Date_Added__c,Description__c
             FROM VRP_testing_app__c
             WHERE  In_Stock__c=true]) {

               products.add(new DisplayMerchandise(item));
             }
         }
     return products;      
    }
    
    public DisplayMerchandise[] findProducts(){
           
           findedProducts = new DisplayMerchandise[]{};
             for (VRP_testing_app__c item :
            [SELECT Name, Product_Type__c, Product_Count__c, In_Stock__c, Release_Date__c,Date_Added__c,Description__c
             FROM VRP_testing_app__c
             WHERE  (Name LIKE :eval)]){
              findedProducts.add(new DisplayMerchandise(item));
           }
         products=findedProducts;
     return findedProducts;      
    }
        
    }

 I know that is the bad style programming code, but i'm only studying.

Sorry for bad english - is not my native language.