[SalesForce] Apex validations removing parameters from url

I have a VF page which has a Save and cancel button and i am using this page on Sites.

The issue that i have is
Whenever there is a validation like a Required field is not entered then an apex:message is shown that value is required. But after that the parameters in the url is lost.

For example

If the url of the VF page is
http://abc-developer-edition.ap1.force.com/Candidate?jobId=a039000000jc8koAAA

after the validation error url changes to
http://abc-developer-edition.ap1.force.com/Candidate

(It removes the parameters)

<apex:commandButton action="{!SaveResult}" value="Submit" styleclass="btn btn-primary"/>

SaveResult is a controller method where i save the record. Everything works fine when all the values are entered correct.

I am using the required in VF page this way.

<apex:inputField value="{!field_disp[f.fieldPath]}" required="{!OR(f.required, f.dbrequired)}"  styleClass="form-control"/>

Any thoughts what could be causing this?

Thanks

Best Answer

If you don't put a rerender in the commandbutton, it will rerender the entire page if null is returned from the SaveResult method. And it rerenders the page without the page parameters. I guess the same happens for the required="true" parameter.

When I had this problem I added rerender="[some id of e.g. the form]" to the commandbutton, which made it work fine because it will only rerender that part and leave the url as it is.