Variational Methods for Hamiltonian PDEs