This paper aims to study a family of deterministic optimal control problems in infinite-dimensional spaces. The peculiar feature of such problems is the presence of a positivity state constraint, which often arises in economic applications. To deal with such constraints, we set up the problem in a Banach lattice, not necessarily reflexive: a typical example is the space of continuous functions on a compact set. In this setting, which seems to be new in this context, we are able to find explicit solutions to the Hamilton--Jacobi--Bellman (HJB) equation associated to a suitable auxiliary problem and to write the corresponding optimal feedback control. Thanks to a type of infinite-dimensional Perron--Frobenius theorem, we use these results to ...