I don't think he was ever technically fighting that law, it was the access to that public beach through his property that he blocked off.
Yet there's a near universal consensus that "the law" (i.e. the founding statutes regarding access to coastal properties, from the time California entered the Union) mandates that this access must be maintained, for perpetuity, by whoever takes title to the property.
So in effect there's a permanent easement attached to the property (even if the term as such didn't appear in the text of the original statues).