You need to sign in to do that
Don't have an account?
veeru417
Problem with saving pagereference method pls can any one help me pls
Hello every one i want to implement a fucntionality like shoping cart.In this there is a form to fill details,after filling we need to press add ,when we press add the details in form should added to pageblock table one by one but the records are not commited until we press save button.
In this i have completed adding to pageblock table but facing the problem when saving records can any one help me pls
i am attching my code too
visual force code : <apex:page standardController="Test_Case_Log__c" extensions="TestClass" > <apex:form id="form"> <apex:pageMessages /> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="save" action="{!save1}" rerender="pbtable"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" id="psi" > <apex:inputField value="{!testlog.Developer__c}" /> <apex:inputfield value="{!testlog.name}" /> <apex:inputField value="{!testlog.Priority__c}" /> <apex:inputField value="{!testlog.Test_Cases__c}" /> <apex:inputField value="{!testlog.Tester__c}" /> <apex:inputField value="{!testlog.Test_Scenario__c}" /> </apex:pageBlockSection> <apex:pageBlockSection title="Description" id="psd"> <apex:inputField value="{!testlog.Expected_Result__c}" /> <apex:inputField value="{!testlog.Test_Case_Notes__c}" /> </apex:pageBlockSection> <apex:pageBlockTable value="{!testlog1}" var="a" id="pbtable" > <apex:column value="{!a.Priority__c}" headerValue="Priority"/> <apex:column value="{!a.Developer__c}" headerValue="Developer"/> <apex:column value="{!a.Test_Cases__c}" headerValue="Expected_Result"/> <apex:column value="{!a.Test_Scenario__c}" headerValue="testscenario"/> </apex:pageBlockTable> <apex:commandButton action="{!add}" value="add" rerender="form"/> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class TestClass { public TestClass(ApexPages.StandardController controller) { testlog = (Test_Case_Log__c)Controller.getRecord(); } public list<Test_Case_Log__c> tdt = new list<Test_Case_Log__c>(); public list<Test_Case_Log__c> gettestlog1(){ return tdt; } public Test_Case_Log__c testlog{set;get;} public void add(){ tdt.add(testlog); testlog =new Test_Case_Log__c(); } public pagereference save1(){ insert tdt; PageReference pageRef = new PageReference('/apex/testpage'); return pageRef; } }
Thank you
yes i have solved the issue ,i have added
<apex:commandButton value="save" action="{!save1}" immediate="true"/>
so it will skip the validation.
Thanks for your helping behaviour,i have one more issue ,
i need to delete the individual record on the table can you help me in the above form.
i.e i need to have individual delete button for every row n when we press the button it need to delete the particular row.
All Answers
whats the problem that you are facing?
when i am saving all the records on table it is throwing validation error,form is having one master detail relation ship fild the save method is trying to save the empty form ,so it is giving validation error
r u giving the master detail value in the UI?
yes i have solved the issue ,i have added
<apex:commandButton value="save" action="{!save1}" immediate="true"/>
so it will skip the validation.
Thanks for your helping behaviour,i have one more issue ,
i need to delete the individual record on the table can you help me in the above form.
i.e i need to have individual delete button for every row n when we press the button it need to delete the particular row.
you can acheive that some thing like below
<apex:pageBlockTable value="{!testlog1}" var="a" id="pbtable" >
<apex:column value="{!a.Priority__c}" headerValue="Priority"/>
<apex:column value="{!a.Developer__c}" headerValue="Developer"/>
<apex:column value="{!a.Test_Cases__c}" headerValue="Expected_Result"/>
<apex:column value="{!a.Test_Scenario__c}" headerValue="testscenario"/>
<apex:commandButton value="Del"action="{!del}"rerender="table" >
<apex:param name="delname" value="{!a.Test_Scenario__c}" />
</apex:commandLink>
</apex:pageBlockTable>
/* your Delete functionality*/
public PageReference del() {
string delnumber =
ApexPages.CurrentPage().getParameters().get('delnumber');
system.assert( delnumber != null );
integer gone = -1;
integer i = 0;
for ( i=0; i< casenumber ="="" gone =" i;">= 0) {
todeletelist.add(listofobjectitems.remove(gone) );
}
return null;
}
Thank you kiran i will go through and inform you if i get any help.
Thanks&Regards,
Veerendranath
Hi kiran,
I have implemented the Delete functionality .But i have taken Wrapperclass I need your help in writing Test class for that.
I tried to write but it covers only 70%.Can you help me in this plss.
I am posting the Class and Can you help me in it.
Thanks In Advance
Regards,
Veeru
Awesome! Thank you so much for this comment, was looking everywhere on how to get around this. actionRegion works as well but for some reason in my case it did not.
Thank You!