When a command link is clicked on page it is refreshing the whole page and asking to enter require fields. But I want to enter required fields only after clicking the command link.
Note:Command link is used to open a new VF page
VF Page:
<apex:inputField value="{!Account.Name}" required = true>
</apex:inputField>
<apex:outputPanel >
<apex:outputField value="{!Account.Input__c}" />
<apex:commandLink action="{!redirectToVFPage}" target="_blank">
</apex:commandLink>
</apex:outputPanel>
Best Answer
You have two things going on here:
Here is the most basic example to help you out, put it in your org and play with it a bit to see the effect of different options.
Class
VF Page
Note you need to add the Page Messages component to see the required validation error when using rerender. Also, displaying the error at the field level requires you to NOT use the rerender attribute.
Its all a bit confusing.....
This will not refresh the page but will refresh the output panel to show the update. You could leave the
rerender=none
and debug the values in the controller and see that it works.If you remove the rerender from the command link, you will see your issue return.
Using
Immediate=true
will not send the value to the controller and thethePanel
panel will be blank on rerender.Another item to review would be action regions, but may not be applicable in your use case. If you need to submit part of the form and not the others (having required fields) look into that.