IceFaces Cancel Button with immediate true

Putting ‘immediate=”true”‘ in a cancel button in an icefaces form will pass the validation process. But to get old form values in place we have to do something in our back end.
After searching a whole lot of pages I found two articles to get the solution.

https://cwiki.apache.org/confluence/display/MYFACES/Clear+Input+Components
https://cwiki.apache.org/confluence/display/MYFACES/How+the+immediate+attribute+works

One way to do this is to re render the view to get old form values. But in my case the composite view has so many flags to set particular rendering of the components. So just to refresh the page was not working for me. What I did is to set the backing bean value to its old values and call a clear() method on all my UI components needed to be reset.

public void cancelCustomer(ActionEvent event) {
	Customer customer = orderEditBackingBean.getSelected().getCustomer();

	orderEditBackingBean.getSelected().setCustomerId(customer.getCustomerId());
	orderEditBackingBean.getSelected().setContactName(customer.getCustomerFirst());
	orderEditBackingBean.getSelected().setCompanyName(customer.getCompanyName());
	orderEditBackingBean.getSelected().setContactPhone(customer.getContactPhone());
	orderEditBackingBean.getSelected().setAddress1(customer.getAddress1());
	orderEditBackingBean.getSelected().setAddress2(customer.getAddress2());
	orderEditBackingBean.getSelected().setCity(customer.getCity());
	orderEditBackingBean.getSelected().setState(customer.getStateCode());
	orderEditBackingBean.getSelected().setZip(customer.getZipCode());
	orderEditBackingBean.getSelected().setCorpNode(customer.getCorpNode());
	
    event.getComponent().getParent().getParent().getParent().getChildren().clear();
    
	orderEditBackingBean.getSelected().setCustomerDisable(true);
	orderEditBackingBean.getSelected().setEditButtonVisible(true);
	orderEditBackingBean.getSelected().setSubmitButtonVisible(false);
}