You need to sign in to do that
Don't have an account?
dou
save method
Hi,
I'm trying to built a saving method into my apex controller.
I have a few fiels in my visualforce page, like this :
And I want to save the value the user enter in this fields, with a button like this :
So, in my apex controller I have to add the "enregistrer" method for saving the values :
I'm trying to built a saving method into my apex controller.
I have a few fiels in my visualforce page, like this :
<apex:form > <div id="colonne1"> <p id="oeuvreEtOpportunite"> <span>Oeuvre</span> <apex:inputText value="{!droit.Oeuvre__r.Name}"></apex:inputText> <span>Opportunité</span> <apex:inputText value="{!droit.Opportunite__r.Name}"></apex:inputText> </p> <p id="dateDebutDetention"> <span>Date de début de détention</span> <apex:inputText id="datepicker" value="{!choixDate}"></apex:inputText> </p> <p id="dureeDetention"> <span>Durée de détention</span> <apex:inputText value="{!droit.Duree_de_detention__c}"></apex:inputText> </p> </div> <div id="colonne2"> <p> <apex:inputCheckbox value="{!droit.Accord_producteur__c}" id="accordProd"></apex:inputCheckbox> <span>Accord producteur</span> </p> <p> <apex:inputCheckbox value="{!droit.Exclusivite__c}" id="exclusivite"></apex:inputCheckbox> <span>Exclusivité</span> </p> <p> <apex:inputCheckbox value="{!droit.Option__c}" id="option"></apex:inputCheckbox> <span>Option</span> </p> </div> </apex:form>
And I want to save the value the user enter in this fields, with a button like this :
<apex:form id="dummy"> <apex:commandButton value="Enregistrer" action="{!enregistrer}" /> <apex:commandButton value="Annuler" onclick="window.close();"/> </apex:form>
So, in my apex controller I have to add the "enregistrer" method for saving the values :
public Droit__c droit {get; set;} public String choixDate {get; set;} public String droitId {get; set;} public GestionDroitsController() { droitId = ApexPages.currentPage().getParameters().get('droitId'); droit = [SELECT Id, Oeuvre__r.Name, Opportunite__r.Name, Duree_de_detention__c, Accord_producteur__c, Exclusivite__c, Option__c, Date_de_debut_de_detention__c FROM Droit__c WHERE Id = :droitId LIMIT 1]; } public void enregistrer(){ if(droitId != null){ //Droit__c droit; droit.Date_de_debut_de_detention__c = getDateFromString(choixDate); update droit; } }But I don't know how to make the method working, so if you know how to make that, thank you for your answers ! :)
All Answers