• L037242283804838405
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
how to add a column to my table on a text field the user will fill the text field isnt bounded to any object and i want to transfer its data to controller
hi friends.
this is an urgent problem for sunday so thanks for fast answers.
i have a controller:
public class Shopping{

    public PageReference readCellMethod() {
        String id = ApexPages.currentPage().getParameters().get('rowID');
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL,id);
    ApexPages.addMessage(myMsg);
    return null;
    }


    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Name, Price__c FROM Product__c]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records
    public List<Product__c> getOpportunities() {
        return (List<Product__c>) setCon.getRecords();
    }
}

I have a visual force page:
<apex:page controller="Shopping">
<apex:form>
    <apex:actionFunction name="readCell" action="{!readCellMethod}">
        <apex:param name="rowID"/>
    </apex:actionFunction>
</apex:form>
    <apex:pageBlock >
    <apex:pageMessages />
        <apex:pageBlockTable value="{!opportunities}" var="o">
            <apex:column value="{!o.Name}"/>
            <apex:column value="{!o.Price__c }"/>
            <apex:column headerValue="Add" onclick="readCell('{!o.Id}')"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

my problem: i want to add a column with button or something that on click will add products to the customer chart.
i need to pass the product id(o.id)
to the controller.
of course i didnt success cause i am a total beginner.
what is the easiest way to do so?
thanks for your help guys :)!
hi guys,
how can i transfer input field to the controller by clicking on button
i tried that
<apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="Mahavir"
                value={!customer.Name}
                />

controller function:
public PageReference getCustomer1() {
     String a=System.currentPageReference().getParameters().get('Mahavir');
customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name =: a];
            return (new ApexPages.StandardController(customer)).view();
   
    }
its not working :(
what should i do its urgent thanks for fast answer
I am a total beginner in apex. my question is: I am trying to do a search button I have a custom object named Customer_c it has Name - string (this is the id number of the person for me)- like "12345" for example ans 2 custom attributes- address_c and full_name__c I want to make a form with 3 input fields. the first input field gonna be the Name- means again the id number of the person for me near that input field will be a button with the text find. i want to create a function in my custom controller that will find the right customer by this name and if success will return to this page the customer full name and address to the 2 correct input fields. and if not we will see a text message you are new. in both cases the user if new or old will be able to change his full name and address and save it and continue to the next page there its id will be sent as a parameter.

the issue is i dont have an idea how to write the find customer by Name method. any help ? thanks again

this is what i have done till now but it isnt working well :( if it will help you: this is the controller code:

public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
    }
     public String idNumber{
        get;
        // *** setter is NOT being called ***
        set {
            idNumber= value;
        }
    }
     public Customer__c getCustomer() {
        return customer;
    }

     public PageReference getCustomer1() {

        customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
           if(customer==null)
           {
             customer=new Customer__c();
           }
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        acctPage.setRedirect(true);
        return acctPage;

    }
    public PageReference save() {
        try {
            upsert(customer);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    }
    public PageReference getSpecificCustomer()
    {
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    }
    public PageReference gotoCompetitorSearch() {
    save();
    return Page.Shop;
}
}
this is the view code

<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                value="{!customer.Name}"
                assignTo="{!idNumber}"/>
               </apex:commandButton>
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
the find with getcustomer1 action isnt working. i am a total beginner and any help will be grateful. thanks, Liron.
hi friends
this is the controller code:
public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
    }
     public String idNumber{
        get;
        // *** setter is NOT being called ***
        set {
            idNumber= value;
        }
    }
     public Customer__c getCustomer() {
        return customer;
    }
   
     public PageReference getCustomer1() {
    
        customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
           if(customer==null)
           {
             customer=new Customer__c();
           }
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        acctPage.setRedirect(true);
        return acctPage;
   
    }
    public PageReference save() {
        try {
            upsert(customer);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    }
    public PageReference getSpecificCustomer()
    {
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    }
    public PageReference gotoCompetitorSearch() {
    save();
    return Page.Shop;
}
}

this is the view code
<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                value="{!customer.Name}"
                assignTo="{!idNumber}"/>
               </apex:commandButton>
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

the find with getcustomer1 action isnt working.
i am a total beginner and any help will be grateful.
thanks, Liron. 
I am a total beginner in apex. my question is: I am trying to do a search button I have a custom object named Customer_c it has Name - string (this is the id number of the person for me)- like "12345" for example ans 2 custom attributes- address_c and full_name__c I want to make a form with 3 input fields. the first input field gonna be the Name- means again the id number of the person for me near that input field will be a button with the text find. i want to create a function in my custom controller that will find the right customer by this name and if success will return to this page the customer full name and address to the 2 correct input fields. and if not we will see a text message you are new. in both cases the user if new or old will be able to change his full name and address and save it and continue to the next page there its id will be sent as a parameter.

the issue is i dont have an idea how to write the find customer by Name method. any help ? thanks again

this is what i have done till now but it isnt working well :( if it will help you: this is the controller code:

public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
    }
     public String idNumber{
        get;
        // *** setter is NOT being called ***
        set {
            idNumber= value;
        }
    }
     public Customer__c getCustomer() {
        return customer;
    }

     public PageReference getCustomer1() {

        customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
           if(customer==null)
           {
             customer=new Customer__c();
           }
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        acctPage.setRedirect(true);
        return acctPage;

    }
    public PageReference save() {
        try {
            upsert(customer);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    }
    public PageReference getSpecificCustomer()
    {
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    }
    public PageReference gotoCompetitorSearch() {
    save();
    return Page.Shop;
}
}
this is the view code

<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                value="{!customer.Name}"
                assignTo="{!idNumber}"/>
               </apex:commandButton>
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
the find with getcustomer1 action isnt working. i am a total beginner and any help will be grateful. thanks, Liron.
hi friends
this is the controller code:
public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
    }
     public String idNumber{
        get;
        // *** setter is NOT being called ***
        set {
            idNumber= value;
        }
    }
     public Customer__c getCustomer() {
        return customer;
    }
   
     public PageReference getCustomer1() {
    
        customer=
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
           if(customer==null)
           {
             customer=new Customer__c();
           }
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        acctPage.setRedirect(true);
        return acctPage;
   
    }
    public PageReference save() {
        try {
            upsert(customer);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    }
    public PageReference getSpecificCustomer()
    {
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    }
    public PageReference gotoCompetitorSearch() {
    save();
    return Page.Shop;
}
}

this is the view code
<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                value="{!customer.Name}"
                assignTo="{!idNumber}"/>
               </apex:commandButton>
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

the find with getcustomer1 action isnt working.
i am a total beginner and any help will be grateful.
thanks, Liron.