You need to sign in to do that
Don't have an account?
Save Button in Visualforce Page Issue
I have this Save Button code.
<apex:pageBlockButtons > <apex:commandLink value="Save" action="{!save}" id="savebutton" styleClass="btn" style="text-decoration:none;padding:4px;"></apex:commandlink> </apex:pageBlockButtons>
I have a lot of issues and bugs on "Saving" data in my visualforce page. And was wondering if you guys can shed some light on how to fix it. It's been bugging me and becoming a show stopper in my development.
Problems when pressing "Save"
Problem 1 - If I enter data in a text field and press "Save", it reloads but doesnt save the data. But when I enter data in a text field AND click out and save... it saves it. I cant have that. I'm getting complaints on that. Especially when they keep entering data then just presses save and it doesnt save the last data get really annoying.
Problem 2 - when putting Target="_self" it saves it inside that iFrame. If I do Target="_parent" it saves it but just showing the VF Page and I lose my headers, search, etc... I just want to press save and stay in the SAME tab. Instead, it reloads in the first tab and you get more mad when you click on the tab you want and the data doesnt save.
I just want to save the data and refresh in the same tab. Thats all I need. Please help
Problem 1:
For inputField tag value is required and it will automatically bind into that object's field.
For inputText tag value is not required and it may not bind into the object's field.
Problem 2:
To return to the same page, you can reset the object and return null from the save method.
If you are expecting more detailed explanation, please paste your VF and controller here and can explain in more detailed.
Please do let me know if it helps you.
Regards,
Mahesh
Please check the below sample code.
Visualforce Page
Controller
Hope this helps you!
Best Regards,
Jyothsna
I got problem 1 solved. Using this code... <apex:commandButton value="save" action="{!save}"/>
I'm stuck on problem 2. When I use rerender, it renders but doesnt save... I updated the <apex:form id="PropertyTab4"> and added <apex:commandButton action="{!Save}" value="Save" rerender="PropertyTab4"/>
it renders but doesnt save
In the save() method you can redirect to the same page after completion of your save operation.
Please do let me know if it helps you.
Regards,
Mahesh
Also paste first line of your VF page.
Regards,
Mahesh
Current Extension
VF Page
Where should I paste them?
Please find the below code:
Here replace "UrVFPage" this with your VF Page Name.
Please do let me know if it helps you.
Regards,
Mahesh
This was my controller
Then better to use the old code for save() method.
Onething I identified here is, in the VF page you shouldn't use
Property__c. --- This is the object name
it should be
property. ---- This is the member variable in your controller.
Always use the member variable and your second problem of saving will be resolved.
Take a backup of your current VF page and replace and replace Property__c with property in the whole VF page.
Please do let me know if it helps you.
Regards,
Mahesh
Here you also need to change the Constructor, I am not sure whether you changed it or not.
Please paste the latest after this modification along with actual error message.
Regards,
Mahesh